Dockerfile 953 B

1234567891011121314151617181920212223
  1. FROM golang:1.21-alpine AS builder
  2. LABEL maintainer="nekohasekai <[email protected]>"
  3. COPY . /go/src/github.com/sagernet/sing-box
  4. WORKDIR /go/src/github.com/sagernet/sing-box
  5. ARG GOPROXY=""
  6. ENV GOPROXY ${GOPROXY}
  7. ENV CGO_ENABLED=0
  8. RUN set -ex \
  9. && apk add git build-base \
  10. && export COMMIT=$(git rev-parse --short HEAD) \
  11. && export VERSION=$(go run ./cmd/internal/read_tag) \
  12. && go build -v -trimpath -tags with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_reality_server,with_clash_api,with_acme \
  13. -o /go/bin/sing-box \
  14. -ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -s -w -buildid=" \
  15. ./cmd/sing-box
  16. FROM alpine AS dist
  17. LABEL maintainer="nekohasekai <[email protected]>"
  18. RUN set -ex \
  19. && apk upgrade \
  20. && apk add bash tzdata ca-certificates \
  21. && rm -rf /var/cache/apk/*
  22. COPY --from=builder /go/bin/sing-box /usr/local/bin/sing-box
  23. ENTRYPOINT ["sing-box"]