fix(docker): ship the right Xray and mtg binaries on arm and 386 images

DockerInit.sh only received TARGETARCH, matched no case for Docker's "386"
and named mtg after its own platform token instead of the panel's GOARCH
lookup, so three of the five published platforms were broken:

- linux/386 fell through to amd64: amd64 binaries named xray-linux-amd64,
  while the panel looks for xray-linux-386 / mtg-linux-386.
- linux/arm/v6 got the ARMv7 Xray and mtg builds, which die with an illegal
  instruction on ARMv6 boards.
- linux/arm/v7 and v6 named mtg mtg-linux-arm32; the panel looks for
  mtg-linux-arm (install.sh renames it the same way), so MTProto never ran.

The Dockerfile now passes TARGETVARIANT, the script maps every docker.yml
platform to the release asset and to the names the runtime looks up, and an
unknown architecture fails the build instead of silently packaging amd64.

Checked by running the old and new script for each docker.yml platform in
golang:1.27-alpine and reading every binary's GOARCH/GOARM with
`go version -m`: the old one fails 386, arm/v6 and both arm mtg names; the
new one passes all five.
This commit is contained in:
MHSanaei
2026-10-25 11:44:15 +01:00
parent 39935ed9ef
commit 4d6db99be8
2 changed files with 45 additions and 30 deletions
+2 -1
View File
@@ -15,6 +15,7 @@ RUN npm run build
FROM golang:1.27-alpine AS builder
WORKDIR /app
ARG TARGETARCH
ARG TARGETVARIANT
RUN apk --no-cache --update add \
build-base \
@@ -28,7 +29,7 @@ COPY --from=frontend /src/internal/web/dist ./internal/web/dist
ENV CGO_ENABLED=1
ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
RUN go build -ldflags "-w -s" -o build/x-ui main.go
RUN ./DockerInit.sh "$TARGETARCH"
RUN ./DockerInit.sh "$TARGETARCH" "$TARGETVARIANT"
# ========================================================
# Stage: Final Image of 3x-ui