Files
sing-box-extended-mirror/Dockerfile
T

32 lines
1.4 KiB
Docker
Raw Permalink Normal View History

2026-07-18 16:40:15 +03:00
FROM --platform=$BUILDPLATFORM golang:1.26 AS builder
2026-02-22 15:50:39 +03:00
LABEL maintainer="shtorm-7"
2022-08-27 22:55:55 +08:00
COPY . /go/src/github.com/sagernet/sing-box
WORKDIR /go/src/github.com/sagernet/sing-box
2023-11-09 21:36:32 -05:00
ARG TARGETOS TARGETARCH
2022-08-27 22:55:55 +08:00
ARG GOPROXY=""
2026-07-18 16:40:15 +03:00
ARG CRONET_GO_PATH=/go/src/github.com/sagernet/sing-box/cronet-go
ENV GOPROXY=${GOPROXY}
ENV CGO_ENABLED=1
2023-11-09 21:36:32 -05:00
ENV GOOS=$TARGETOS
ENV GOARCH=$TARGETARCH
2026-07-18 16:40:15 +03:00
ENV CRONET_GO_PATH=${CRONET_GO_PATH}
2022-08-27 22:55:55 +08:00
RUN set -ex \
2026-07-18 16:40:15 +03:00
&& git config --global --add safe.directory /go/src/github.com/sagernet/sing-box \
&& export GOTOOLCHAIN=local \
&& export CGO_ENABLED=1 GOOS=$TARGETOS GOARCH=$TARGETARCH \
&& eval "$(CGO_ENABLED=0 GOOS= GOARCH= go run -C "$CRONET_GO_PATH" ./cmd/build-naive --target=$GOOS/$GOARCH --libc=musl env --export)" \
&& export CGO_LDFLAGS="$CGO_LDFLAGS -Wl,-z,notext -Wl,-z,execstack" \
&& export VERSION=$(CGO_ENABLED=0 GOOS= GOARCH= go run ./cmd/internal/read_tag) \
&& export TAGS=$(cat release/DEFAULT_BUILD_TAGS_DOCKER) \
&& export LDFLAGS_SHARED=$(cat release/LDFLAGS) \
&& go build -v -trimpath -tags "$TAGS" \
2022-08-27 22:55:55 +08:00
-o /go/bin/sing-box \
-ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" $LDFLAGS_SHARED -s -w -buildid=" \
2022-08-27 22:55:55 +08:00
./cmd/sing-box
2023-11-09 21:36:32 -05:00
FROM --platform=$TARGETPLATFORM alpine AS dist
2026-02-22 15:50:39 +03:00
LABEL maintainer="shtorm-7"
2022-08-27 22:55:55 +08:00
RUN set -ex \
2025-10-30 09:36:52 +08:00
&& apk add --no-cache --upgrade bash tzdata ca-certificates nftables
2022-08-27 22:55:55 +08:00
COPY --from=builder /go/bin/sing-box /usr/local/bin/sing-box
2023-11-09 21:36:32 -05:00
ENTRYPOINT ["sing-box"]