Xray-core/.github/docker/Dockerfile

29 lines
1.2 KiB
Docker
Raw Normal View History

2023-04-16 21:45:16 +00:00
# syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM golang:alpine AS build
2023-04-16 21:45:16 +00:00
WORKDIR /src
COPY . .
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
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
# 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
COPY --from=build --chmod=755 /src/xray /usr/bin/xray
2023-04-16 21:45:16 +00:00
USER root
WORKDIR /root
2023-04-16 21:45:16 +00:00
VOLUME /etc/xray
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" ]
ARG flavor=v2fly
COPY --from=build --chmod=644 /$flavor /usr/share/xray