Browse Source

build: Alpine already supports multi-architecture upx

v1.x.x
Dnomd343 2 years ago
parent
commit
78e3070e37
  1. 17
      Dockerfile

17
Dockerfile

@ -1,23 +1,12 @@
ARG ALPINE="alpine:3.17" ARG ALPINE="alpine:3.17"
ARG GOLANG="golang:1.20-alpine3.17" ARG GOLANG="golang:1.20-alpine3.17"
FROM ${ALPINE} AS upx
RUN apk add build-base cmake
ENV UPX="4.0.2"
RUN wget https://github.com/upx/upx/releases/download/v${UPX}/upx-${UPX}-src.tar.xz && tar xf upx-${UPX}-src.tar.xz
WORKDIR ./upx-${UPX}-src/
RUN make UPX_CMAKE_CONFIG_FLAGS=-DCMAKE_EXE_LINKER_FLAGS=-static
WORKDIR ./build/release/
RUN strip upx && mv upx /tmp/
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/refs/tags/v${XRAY}.tar.gz && tar xf v${XRAY}.tar.gz
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
COPY --from=upx /tmp/upx /usr/bin/
RUN upx -9 /tmp/xray
FROM ${GOLANG} AS xproxy FROM ${GOLANG} AS xproxy
RUN apk add git RUN apk add git
@ -25,17 +14,17 @@ 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" && mv cmd /tmp/xproxy
COPY --from=upx /tmp/upx /usr/bin/
RUN upx -9 /tmp/xproxy
FROM ${ALPINE} AS build FROM ${ALPINE} AS build
RUN apk add xz RUN apk add upx xz
WORKDIR /release/ WORKDIR /release/
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/geoip.dat" && \
wget "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat" && \ wget "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat" && \
tar cJf assets.tar.xz *.dat && rm *.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/
RUN ls | xargs -n1 -P0 upx -9
FROM ${ALPINE} FROM ${ALPINE}
RUN apk add --no-cache dhcp iptables ip6tables radvd && \ RUN apk add --no-cache dhcp iptables ip6tables radvd && \

Loading…
Cancel
Save