Dockerfile 941 B

12345678910111213141516171819
  1. # syntax=docker/dockerfile:1
  2. FROM golang:1.24-alpine AS builder
  3. WORKDIR /go/src
  4. ARG GOPROXY=""
  5. ENV GOPROXY=${GOPROXY}
  6. ENV CGO_ENABLED=1
  7. RUN set -ex && \
  8. apk add git build-base linux-headers libcap-dev libbpf-dev wireguard-tools cmake libqrencode-dev && \
  9. export COMMIT=$(git rev-parse --short HEAD) && \
  10. export VERSION=$(wget -qO- https://api.github.com/repos/sagernet/sing-box/tags | grep '"name":' | head -n 1 | sed -E 's/.*"([^"]+)".*/\1/') && \
  11. git clone --depth 1 --branch dev-next https://github.com/sagernet/sing-box.git . && \
  12. go build -v -trimpath -tags \
  13. "with_gvisor,with_quic,with_wireguard,with_utls,with_acme,with_clash_api,with_grpc" \
  14. -o /go/bin/sing-box \
  15. -ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -s -w -buildid=" \
  16. ./cmd/sing-box
  17. FROM playn/alpine AS dist
  18. COPY --from=builder /go/bin/sing-box /usr/local/bin/sing-box
  19. ENTRYPOINT ["sing-box"]