| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 | # Use the official Golang image as the base imageFROM --platform=$BUILDPLATFORM golang:1.20 as builderARG TARGETOS TARGETARCH# Set up the working directoryWORKDIR /app# Copy the Go modules and download the dependenciesCOPY go.mod go.sum ./RUN go mod download# Copy the source codeCOPY . .RUN if [ "$TARGETARCH" = "arm64" ]; then apt update && apt install gcc-aarch64-linux-gnu -y; fi# Build the X-ui binaryRUN if [ "$TARGETARCH" = "arm64" ]; then \       CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc go build -o xui-release -v main.go; \    elif [ "$TARGETARCH" = "amd64" ]; then \       CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o xui-release -v main.go; \    fi# Start a new stage using the base imageFROM ubuntu:20.04# Set up the working directoryWORKDIR /app# Copy the X-ui binary and required files from the builder stageCOPY --from=builder /app/xui-release /app/x-ui/xui-releaseCOPY x-ui.service /app/x-ui/x-ui.serviceCOPY x-ui.sh /app/x-ui/x-ui.sh# Set up the runtime environmentRUN apt-get update && apt-get install -y \    wget \    unzip \    tzdata \    ca-certificates \ && rm -rf /var/lib/apt/lists/*WORKDIR /app/x-ui/bin# Download and set up the required filesRUN arch=$(uname -m) && \    if [ "$arch" = "aarch64" ]; then \        wget https://github.com/mhsanaei/xray-core/releases/latest/download/Xray-linux-arm64-v8a.zip \        && unzip Xray-linux-arm64-v8a.zip \        && rm -f Xray-linux-arm64-v8a.zip geoip.dat geosite.dat iran.dat \        && wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat \        && wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat \        && wget https://github.com/bootmortis/iran-hosted-domains/releases/latest/download/iran.dat \        && mv xray xray-linux-arm64; \    elif [ "$arch" = "x86_64" ]; then \        wget https://github.com/mhsanaei/Xray-core/releases/latest/download/Xray-linux-64.zip \        && unzip Xray-linux-64.zip \        && rm -f Xray-linux-64.zip geoip.dat geosite.dat iran.dat \        && wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat \        && wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat \        && wget https://github.com/bootmortis/iran-hosted-domains/releases/latest/download/iran.dat \        && mv xray xray-linux-amd64; \    fiWORKDIR /app/x-uiRUN chmod +x /app/x-ui/x-ui.sh# Set the entrypointENTRYPOINT ["/app/x-ui/xui-release"]
 |