Dockerfile 903 B

1234567891011121314151617181920212223
  1. FROM golang:1.19-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 HEAD) \
  11. && go build -v -trimpath -tags 'with_quic,with_wireguard,with_clash_api' \
  12. -o /go/bin/sing-box \
  13. -ldflags "-X github.com/sagernet/sing-box/constant.Commit=${COMMIT} -w -s -buildid=" \
  14. ./cmd/sing-box
  15. FROM alpine AS dist
  16. LABEL maintainer="nekohasekai <[email protected]>"
  17. RUN [ ! -e /etc/nsswitch.conf ] && echo 'hosts: files dns' > /etc/nsswitch.conf
  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"]