Browse Source

build: update docker file

v1.x.x
Dnomd343 2 years ago
parent
commit
4c89addbad
  1. 18
      Dockerfile

18
Dockerfile

@ -3,7 +3,7 @@ ARG GOLANG="golang:1.20-alpine3.17"
FROM ${GOLANG} AS xray FROM ${GOLANG} AS xray
ENV XRAY="1.8.0" ENV XRAY="1.8.0"
RUN wget https://github.com/XTLS/Xray-core/archive/refs/tags/v${XRAY}.tar.gz && tar xf v${XRAY}.tar.gz RUN wget https://github.com/XTLS/Xray-core/archive/v${XRAY}.tar.gz -O- | tar xz
WORKDIR ./Xray-core-${XRAY}/main/ WORKDIR ./Xray-core-${XRAY}/main/
RUN go get RUN go get
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" && mv main /tmp/xray RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-s -w" && mv main /tmp/xray
@ -13,14 +13,18 @@ RUN apk add git
COPY ./ /XProxy/ COPY ./ /XProxy/
WORKDIR /XProxy/cmd/ WORKDIR /XProxy/cmd/
RUN go get RUN go get
RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.version=$(git describe --tag) -s -w" && mv cmd /tmp/xproxy RUN env CGO_ENABLED=0 go build -v -trimpath -ldflags "-X main.version=$(git describe --tag) -s -w"
RUN mv cmd /tmp/xproxy
FROM ${ALPINE} AS geo-data
RUN apk add xz
RUN wget "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat"
RUN wget "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat"
RUN tar cJf /tmp/assets.tar.xz geoip.dat geosite.dat
FROM ${ALPINE} AS build FROM ${ALPINE} AS build
RUN apk add upx xz RUN apk add upx
WORKDIR /release/ COPY --from=geo-data /tmp/assets.tar.xz /release/
RUN 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" && \
tar cJf assets.tar.xz *.dat && rm *.dat
COPY --from=xproxy /tmp/xproxy /release/usr/bin/ COPY --from=xproxy /tmp/xproxy /release/usr/bin/
COPY --from=xray /tmp/xray /release/usr/bin/ COPY --from=xray /tmp/xray /release/usr/bin/
WORKDIR /release/usr/bin/ WORKDIR /release/usr/bin/

Loading…
Cancel
Save