2023-04-16 21:45:16 +00:00
|
|
|
# syntax=docker/dockerfile:1
|
2023-08-24 15:13:12 +00:00
|
|
|
FROM --platform=$BUILDPLATFORM golang:alpine AS build
|
2023-04-16 21:45:16 +00:00
|
|
|
WORKDIR /src
|
|
|
|
COPY . .
|
2024-07-29 07:36:30 +00:00
|
|
|
ARG TARGETOS
|
|
|
|
ARG TARGETARCH
|
2023-04-16 21:45:16 +00:00
|
|
|
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main
|
2024-07-29 07:36:30 +00:00
|
|
|
ADD https://github.com/v2fly/geoip/releases/latest/download/geoip.dat /v2fly/geoip.dat
|
|
|
|
ADD https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat /v2fly/geosite.dat
|
|
|
|
ADD https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat /loyalsoldier/geoip.dat
|
|
|
|
ADD https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat /loyalsoldier/geosite.dat
|
2023-04-16 21:45:16 +00:00
|
|
|
|
2024-07-29 07:36:30 +00:00
|
|
|
# chainguard/static contains only tzdata and ca-certificates, can be built with multiarch static binaries.
|
|
|
|
FROM --platform=linux/amd64 chainguard/static:latest
|
|
|
|
WORKDIR /var/log/xray
|
2023-04-16 21:45:16 +00:00
|
|
|
COPY .github/docker/files/config.json /etc/xray/config.json
|
2024-07-29 07:36:30 +00:00
|
|
|
COPY --from=build --chmod=755 /src/xray /usr/bin/xray
|
2023-04-16 21:45:16 +00:00
|
|
|
|
2024-07-29 07:36:30 +00:00
|
|
|
USER root
|
|
|
|
WORKDIR /root
|
2023-04-16 21:45:16 +00:00
|
|
|
VOLUME /etc/xray
|
2024-07-29 07:36:30 +00:00
|
|
|
ARG TZ=Asia/Shanghai
|
|
|
|
ENV TZ=$TZ
|
2023-05-09 11:25:33 +00:00
|
|
|
ENTRYPOINT [ "/usr/bin/xray" ]
|
|
|
|
CMD [ "-config", "/etc/xray/config.json" ]
|
2024-07-29 07:36:30 +00:00
|
|
|
|
|
|
|
ARG flavor=v2fly
|
2024-08-04 22:21:22 +00:00
|
|
|
COPY --from=build --chmod=644 /$flavor /usr/share/xray
|