mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-13 21:54:13 +08:00
Support to build Docker image with all build tags in CI/CD
This commit is contained in:
parent
b2a18af961
commit
4c2bd0af4a
11
.github/workflows/docker.yml
vendored
11
.github/workflows/docker.yml
vendored
@ -43,3 +43,14 @@ jobs:
|
|||||||
${{ steps.tag.outputs.latest }}
|
${{ steps.tag.outputs.latest }}
|
||||||
${{ steps.tag.outputs.versioned }}
|
${{ steps.tag.outputs.versioned }}
|
||||||
push: true
|
push: true
|
||||||
|
- name: Build with all tags and release Docker images
|
||||||
|
uses: docker/build-push-action@v5
|
||||||
|
with:
|
||||||
|
platforms: linux/386,linux/amd64,linux/arm64,linux/s390x
|
||||||
|
target: dist
|
||||||
|
tags: |
|
||||||
|
${{ steps.tag.outputs.latest }}-full
|
||||||
|
${{ steps.tag.outputs.versioned }}-full
|
||||||
|
build-args: |
|
||||||
|
WITH_ALL_TAGS=1
|
||||||
|
push: true
|
||||||
|
16
Dockerfile
16
Dockerfile
@ -3,21 +3,31 @@ LABEL maintainer="nekohasekai <contact-git@sekai.icu>"
|
|||||||
COPY . /go/src/github.com/sagernet/sing-box
|
COPY . /go/src/github.com/sagernet/sing-box
|
||||||
WORKDIR /go/src/github.com/sagernet/sing-box
|
WORKDIR /go/src/github.com/sagernet/sing-box
|
||||||
ARG GOPROXY=""
|
ARG GOPROXY=""
|
||||||
|
ARG WITH_ALL_TAGS=0
|
||||||
ENV GOPROXY ${GOPROXY}
|
ENV GOPROXY ${GOPROXY}
|
||||||
ENV CGO_ENABLED=0
|
ENV CGO_ENABLED=0
|
||||||
RUN set -ex \
|
RUN set -ex \
|
||||||
&& apk add git build-base \
|
&& if [ -n "$WITH_ALL_TAGS" ] && [ "$WITH_ALL_TAGS" != "0" ]; then \
|
||||||
|
export CGO_ENABLED=1 \
|
||||||
|
&& export EXTRA_PKGS="openssl1.1-compat-dev libevent-dev zlib-dev linux-headers" \
|
||||||
|
&& export EXTRA_TAGS=",with_grpc,with_v2ray_api,with_embedded_tor,with_lwip"; \
|
||||||
|
fi \
|
||||||
|
&& apk add git build-base $EXTRA_PKGS \
|
||||||
&& export COMMIT=$(git rev-parse --short HEAD) \
|
&& export COMMIT=$(git rev-parse --short HEAD) \
|
||||||
&& export VERSION=$(go run ./cmd/internal/read_tag) \
|
&& export VERSION=$(go run ./cmd/internal/read_tag) \
|
||||||
&& go build -v -trimpath -tags with_gvisor,with_quic,with_dhcp,with_wireguard,with_ech,with_utls,with_reality_server,with_clash_api,with_acme \
|
&& go build -v -trimpath -tags with_gvisor,with_quic,with_dhcp,with_wireguard,with_ech,with_utls,with_reality_server,with_clash_api,with_acme$EXTRA_TAGS \
|
||||||
-o /go/bin/sing-box \
|
-o /go/bin/sing-box \
|
||||||
-ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -s -w -buildid=" \
|
-ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -s -w -buildid=" \
|
||||||
./cmd/sing-box
|
./cmd/sing-box
|
||||||
FROM alpine AS dist
|
FROM alpine AS dist
|
||||||
LABEL maintainer="nekohasekai <contact-git@sekai.icu>"
|
LABEL maintainer="nekohasekai <contact-git@sekai.icu>"
|
||||||
|
ARG WITH_ALL_TAGS=0
|
||||||
RUN set -ex \
|
RUN set -ex \
|
||||||
|
&& if [ -n "$WITH_ALL_TAGS" ] && [ "$WITH_ALL_TAGS" != "0" ]; then \
|
||||||
|
export EXTRA_PKGS="openssl1.1-compat libevent zlib"; \
|
||||||
|
fi \
|
||||||
&& apk upgrade \
|
&& apk upgrade \
|
||||||
&& apk add bash tzdata ca-certificates \
|
&& apk add bash tzdata ca-certificates $EXTRA_PKGS \
|
||||||
&& rm -rf /var/cache/apk/*
|
&& rm -rf /var/cache/apk/*
|
||||||
COPY --from=builder /go/bin/sing-box /usr/local/bin/sing-box
|
COPY --from=builder /go/bin/sing-box /usr/local/bin/sing-box
|
||||||
ENTRYPOINT ["sing-box"]
|
ENTRYPOINT ["sing-box"]
|
Loading…
x
Reference in New Issue
Block a user