DockerfileARM 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Use the official Golang image as the base image
  2. FROM golang:1.20 as builder
  3. # Set up the working directory
  4. WORKDIR /app
  5. # Copy the Go modules and download the dependencies
  6. COPY go.mod go.sum ./
  7. RUN go mod download
  8. # Copy the source code
  9. COPY . .
  10. RUN apt update && apt install gcc-aarch64-linux-gnu -y
  11. # Build the X-ui binary
  12. RUN GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc go build -o xui-release-arm64 -v main.go
  13. # Start a new stage using the base image
  14. FROM ubuntu:20.04
  15. # Set up the working directory
  16. WORKDIR /app
  17. # Copy the X-ui binary and required files from the builder stage
  18. COPY --from=builder /app/xui-release-arm64 /app/x-ui/xui-release
  19. COPY x-ui.service /app/x-ui/x-ui.service
  20. COPY x-ui.sh /app/x-ui/x-ui.sh
  21. # Set up the runtime environment
  22. RUN apt-get update && apt-get install -y \
  23. wget \
  24. unzip \
  25. tzdata \
  26. ca-certificates \
  27. && rm -rf /var/lib/apt/lists/*
  28. WORKDIR /app/x-ui/bin
  29. # Download and set up the required files
  30. RUN wget https://github.com/mhsanaei/xray-core/releases/latest/download/Xray-linux-arm64-v8a.zip \
  31. && unzip Xray-linux-arm64-v8a.zip \
  32. && rm -f Xray-linux-arm64-v8a.zip geoip.dat geosite.dat iran.dat \
  33. && wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat \
  34. && wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat \
  35. && wget https://github.com/bootmortis/iran-hosted-domains/releases/latest/download/iran.dat \
  36. && mv xray xray-linux-arm64
  37. WORKDIR /app
  38. RUN chmod +x /app/x-ui/x-ui.sh
  39. # Set the entrypoint
  40. ENTRYPOINT ["/app/x-ui/xui-release"]