mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-26 15:55:02 +03:00
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:
+43
-29
@@ -1,29 +1,48 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
# $1 is Docker's TARGETARCH and $2 its TARGETVARIANT (v6/v7 on arm). The
|
||||||
|
# platform names match the release archives and the mtg-multi packages.
|
||||||
case $1 in
|
case $1 in
|
||||||
amd64)
|
amd64 | "")
|
||||||
ARCH="64"
|
PLATFORM="amd64"
|
||||||
FNAME="amd64"
|
|
||||||
;;
|
;;
|
||||||
i386)
|
arm64 | armv8 | aarch64)
|
||||||
ARCH="32"
|
PLATFORM="arm64"
|
||||||
FNAME="i386"
|
|
||||||
;;
|
;;
|
||||||
armv8 | arm64 | aarch64)
|
arm | arm32 | armv7)
|
||||||
ARCH="arm64-v8a"
|
PLATFORM="armv7"
|
||||||
FNAME="arm64"
|
if [ "$2" = "v6" ]; then
|
||||||
;;
|
PLATFORM="armv6"
|
||||||
armv7 | arm | arm32)
|
fi
|
||||||
ARCH="arm32-v7a"
|
|
||||||
FNAME="arm32"
|
|
||||||
;;
|
;;
|
||||||
armv6)
|
armv6)
|
||||||
ARCH="arm32-v6"
|
PLATFORM="armv6"
|
||||||
FNAME="armv6"
|
;;
|
||||||
|
386 | i386)
|
||||||
|
PLATFORM="386"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
ARCH="64"
|
echo "DockerInit: unsupported architecture '$1'" >&2
|
||||||
FNAME="amd64"
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case $PLATFORM in
|
||||||
|
amd64) XRAY_ZIP="64" ;;
|
||||||
|
arm64) XRAY_ZIP="arm64-v8a" ;;
|
||||||
|
armv7) XRAY_ZIP="arm32-v7a" ;;
|
||||||
|
armv6) XRAY_ZIP="arm32-v6" ;;
|
||||||
|
386) XRAY_ZIP="32" ;;
|
||||||
|
esac
|
||||||
|
# The panel looks binaries up by GOARCH; on arm Xray's is "arm32"
|
||||||
|
# (internal/xray/process.go) and mtg's plain "arm", as install.sh renames them.
|
||||||
|
case $PLATFORM in
|
||||||
|
armv7 | armv6)
|
||||||
|
XRAY_BIN="xray-linux-arm32"
|
||||||
|
MTG_BIN="mtg-linux-arm"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
XRAY_BIN="xray-linux-${PLATFORM}"
|
||||||
|
MTG_BIN="mtg-linux-${PLATFORM}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
MTG_MULTI_VER=$(curl -sfL "https://api.github.com/repos/mhsanaei/mtg-multi/releases/latest" | sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p' | head -n 1)
|
MTG_MULTI_VER=$(curl -sfL "https://api.github.com/repos/mhsanaei/mtg-multi/releases/latest" | sed -n 's/.*"tag_name": *"\([^"]*\)".*/\1/p' | head -n 1)
|
||||||
@@ -33,23 +52,18 @@ if [ -z "$MTG_MULTI_VER" ]; then
|
|||||||
fi
|
fi
|
||||||
mkdir -p build/bin
|
mkdir -p build/bin
|
||||||
cd build/bin
|
cd build/bin
|
||||||
curl -sfLRO "https://github.com/XTLS/Xray-core/releases/download/v26.10.21/Xray-linux-${ARCH}.zip"
|
curl -sfLRO "https://github.com/XTLS/Xray-core/releases/download/v26.10.21/Xray-linux-${XRAY_ZIP}.zip"
|
||||||
unzip "Xray-linux-${ARCH}.zip"
|
unzip "Xray-linux-${XRAY_ZIP}.zip"
|
||||||
rm -f "Xray-linux-${ARCH}.zip" geoip.dat geosite.dat
|
rm -f "Xray-linux-${XRAY_ZIP}.zip" geoip.dat geosite.dat
|
||||||
mv xray "xray-linux-${FNAME}"
|
mv xray "${XRAY_BIN}"
|
||||||
# mtg-multi (MTProto sidecar) ships prebuilt release binaries for every target
|
# mtg-multi (MTProto sidecar) ships prebuilt release binaries for every target
|
||||||
# we package, so download and unpack the matching one instead of compiling.
|
# we package, so download and unpack the matching one instead of compiling.
|
||||||
case $FNAME in
|
MTG_PKG="mtg-multi-${MTG_MULTI_VER#v}-linux-${PLATFORM}"
|
||||||
i386) MTGARCH="386" ;;
|
|
||||||
arm32) MTGARCH="armv7" ;;
|
|
||||||
*) MTGARCH="$FNAME" ;;
|
|
||||||
esac
|
|
||||||
MTG_PKG="mtg-multi-${MTG_MULTI_VER#v}-linux-${MTGARCH}"
|
|
||||||
curl -sfLRO "https://github.com/mhsanaei/mtg-multi/releases/download/${MTG_MULTI_VER}/${MTG_PKG}.tar.gz"
|
curl -sfLRO "https://github.com/mhsanaei/mtg-multi/releases/download/${MTG_MULTI_VER}/${MTG_PKG}.tar.gz"
|
||||||
tar -xzf "${MTG_PKG}.tar.gz"
|
tar -xzf "${MTG_PKG}.tar.gz"
|
||||||
mv "${MTG_PKG}/mtg-multi" "mtg-linux-${FNAME}"
|
mv "${MTG_PKG}/mtg-multi" "${MTG_BIN}"
|
||||||
rm -rf "${MTG_PKG}" "${MTG_PKG}.tar.gz"
|
rm -rf "${MTG_PKG}" "${MTG_PKG}.tar.gz"
|
||||||
chmod +x "mtg-linux-${FNAME}"
|
chmod +x "${MTG_BIN}"
|
||||||
curl -sfLRO https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat
|
curl -sfLRO https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat
|
||||||
curl -sfLRO https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
|
curl -sfLRO https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
|
||||||
curl -sfLRo geoip_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat
|
curl -sfLRo geoip_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat
|
||||||
|
|||||||
+2
-1
@@ -15,6 +15,7 @@ RUN npm run build
|
|||||||
FROM golang:1.27-alpine AS builder
|
FROM golang:1.27-alpine AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
|
ARG TARGETVARIANT
|
||||||
|
|
||||||
RUN apk --no-cache --update add \
|
RUN apk --no-cache --update add \
|
||||||
build-base \
|
build-base \
|
||||||
@@ -28,7 +29,7 @@ COPY --from=frontend /src/internal/web/dist ./internal/web/dist
|
|||||||
ENV CGO_ENABLED=1
|
ENV CGO_ENABLED=1
|
||||||
ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
|
ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
|
||||||
RUN go build -ldflags "-w -s" -o build/x-ui main.go
|
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
|
# Stage: Final Image of 3x-ui
|
||||||
|
|||||||
Reference in New Issue
Block a user