mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-11-07 09:47:23 +00:00
上一提交只改了 prepare-core.js(npm run core:win 路径),而 docker 构建走的是 dist-win-docker.sh 里的内联 go build,产物里的内嵌核心仍是 17.8MB 带调试符号。 两处必须同步,否则"用哪种方式构建"会决定包大小:现在 Linux 与 Windows 的内嵌 核心都剥符号。
66 lines
3.0 KiB
Bash
Executable File
66 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# One-shot Windows release build for the GUI — ENTIRELY inside docker.
|
|
#
|
|
# 1) cross-compile the embedded core in docker (modelrouter.exe + lua51.dll)
|
|
# 2) electron-builder NSIS packaging ALSO inside docker (wine for the
|
|
# uninstaller step lives in the image — see Dockerfile). This is the fix
|
|
# for the 1.3.0/1.4.0 broken installers: the host had amd64-only wine
|
|
# (no syswow64 -> c0000135), which made electron-builder silently emit a
|
|
# 264 KB degenerate exe without its 86 MB payload.
|
|
#
|
|
# Outputs: cmd/build/gui-dist/"ModelRouter Setup <version>.exe"
|
|
# cmd/build/gui-dist/modelrouter-gui-<version>-x64.nsis.7z
|
|
#
|
|
# Needs: docker (any machine; no host mingw/wine/node required)
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
|
|
IMAGE="${WIN_BUILDER_IMAGE:-modelrouter/win-builder}"
|
|
PROXY="${GOPROXY:-https://goproxy.cn,direct}"
|
|
CACHE_VOL="modelrouter-eb-cache"
|
|
|
|
command -v docker >/dev/null || { echo "docker required"; exit 1; }
|
|
|
|
if ! docker image inspect "$IMAGE" >/dev/null 2>&1; then
|
|
echo "[dist-win-docker] building image $IMAGE (first run, ~5-10 min)..."
|
|
docker build -t "$IMAGE" "$ROOT/cmd/gui/docker/win-builder"
|
|
fi
|
|
|
|
docker volume create "$CACHE_VOL" >/dev/null 2>&1 || true
|
|
|
|
# 1) embedded core + 2) NSIS packaging — both inside the image so wine and node
|
|
# are the image's, never the host's. electron-builder downloads electron + nsis
|
|
# toolchains into ~/.cache on first run; the mounted volume keeps that warm so
|
|
# subsequent builds are incremental instead of re-fetching ~400 MB.
|
|
echo "[dist-win-docker] cross-compiling core + electron-builder NSIS in docker ..."
|
|
docker run --rm \
|
|
-v "$ROOT":/workspace \
|
|
-v "$CACHE_VOL":/root/.cache \
|
|
-e GOPROXY="$PROXY" \
|
|
-e ELECTRON_MIRROR="https://npmmirror.com/mirrors/electron/" \
|
|
-e ELECTRON_BUILDER_BINARIES_MIRROR="https://npmmirror.com/mirrors/electron-builder-binaries/" \
|
|
-w /workspace \
|
|
"$IMAGE" bash -c '
|
|
set -euo pipefail
|
|
cp /opt/luajit2/src/lua51.dll /workspace/cmd/gui/bin/lua51.dll
|
|
GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc \
|
|
go build -buildvcs=false -tags luajit -trimpath -ldflags "-s -w" \
|
|
-o /workspace/cmd/gui/bin/modelrouter.exe ./cmd/modelrouter
|
|
echo " -> core built"
|
|
# wine needs one prefix initialization so its wow64 runtime (syswow64/ntdll)
|
|
# exists — the exact thing that was missing on the broken host. Use a shared
|
|
# prefix in the cache volume so it is initialized only on the first run.
|
|
export WINEPREFIX=/root/.cache/wineprefix
|
|
if [ ! -f "$WINEPREFIX/drive_c/windows/syswow64/ntdll.dll" ]; then
|
|
echo " -> initializing wine prefix (first run)"
|
|
WINEDEBUG=-all wineboot -i || true
|
|
fi
|
|
cd /workspace/cmd/gui
|
|
# node_modules ships in the repo (host npm install already ran); reuse it.
|
|
npx electron-builder --win nsis
|
|
'
|
|
|
|
echo "[dist-win-docker] verifying artifacts ..."
|
|
"$ROOT/packaging/verify-dist.sh" "$ROOT/cmd/build/gui-dist"
|
|
|
|
echo "[dist-win-docker] done" |