Dockerfile 1.1 KB

12345678910111213141516171819202122232425262728
  1. # syntax=docker/dockerfile:1
  2. FROM --platform=$BUILDPLATFORM golang:alpine AS build
  3. WORKDIR /src
  4. COPY . .
  5. ARG TARGETOS
  6. ARG TARGETARCH
  7. RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main
  8. ADD https://github.com/v2fly/geoip/releases/latest/download/geoip.dat /v2fly/geoip.dat
  9. ADD https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat /v2fly/geosite.dat
  10. ADD https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat /loyalsoldier/geoip.dat
  11. ADD https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat /loyalsoldier/geosite.dat
  12. # chainguard/static contains only tzdata and ca-certificates, can be built with multiarch static binaries.
  13. FROM --platform=linux/amd64 chainguard/static:latest
  14. WORKDIR /var/log/xray
  15. COPY .github/docker/files/config.json /etc/xray/config.json
  16. COPY --from=build --chmod=755 /src/xray /usr/bin/xray
  17. USER root
  18. WORKDIR /root
  19. VOLUME /etc/xray
  20. ARG TZ=Asia/Shanghai
  21. ENV TZ=$TZ
  22. ENTRYPOINT [ "/usr/bin/xray" ]
  23. CMD [ "-confdir", "/etc/xray/" ]
  24. ARG flavor=v2fly
  25. COPY --from=build --chmod=644 /$flavor /usr/share/xray