From 9ee5c09d8f2278705ffa06fd41ff327347de6d77 Mon Sep 17 00:00:00 2001 From: Evans Mike Date: Fri, 5 May 2023 15:18:05 +0100 Subject: [PATCH 01/10] chore: mainline builder --- .../build-singbox-docker-mainline.yml | 90 +++++++++++++++++++ .github/workflows/build-singbox-docker.yml | 6 +- README.md | 45 ++++++++++ dockerfiles/Dockerfile.distroless.full | 2 +- dockerfiles/Dockerfile.distroless.minimized | 2 +- dockerfiles/Dockerfile.distroless.standard | 2 +- 6 files changed, 142 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/build-singbox-docker-mainline.yml create mode 100644 README.md diff --git a/.github/workflows/build-singbox-docker-mainline.yml b/.github/workflows/build-singbox-docker-mainline.yml new file mode 100644 index 0000000..0184fdb --- /dev/null +++ b/.github/workflows/build-singbox-docker-mainline.yml @@ -0,0 +1,90 @@ +name: Build Docker Images (Mainline) +on: + workflow_dispatch: + inputs: + branch: + description: "The branch version you want to build" + required: true + default: "main" + +jobs: + build: + strategy: + fail-fast: true + matrix: + buildType: [standard, full] + distro: [alpine] + runs-on: ubuntu-latest + steps: + - name: Checkout Source Code of 'SagerNet/sing-box' + uses: actions/checkout@v3 + with: + repository: 'SagerNet/sing-box' + ref: ${{ github.event.inputs.branch }} + submodules: true + - name: Checkout Action Repo + uses: actions/checkout@v3 + with: + path: action + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Setup QEMU for Docker Buildx + uses: docker/setup-qemu-action@v2 + - name: Login to Docker Hub Container Registry + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Docker metadata + id: metadata + uses: docker/metadata-action@v4 + with: + images: etnperlong/sing-box + - name: Select Dockerfile + id: dockerfile + run: | + if [[ "${{ matrix.buildType }}" == "full" ]]; then + if [[ "${{ matrix.distro }}" == "distroless" ]]; then + cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.full" "$GITHUB_WORKSPACE/Dockerfile" + echo "tagpost=full-distroless" >> $GITHUB_OUTPUT + else + cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.full" "$GITHUB_WORKSPACE/Dockerfile" + echo "tagpost=full" >> $GITHUB_OUTPUT + fi + elif [[ "${{ matrix.buildType }}" == "minimized" ]]; then + if [[ "${{ matrix.distro }}" == "distroless" ]]; then + cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.minimized" "$GITHUB_WORKSPACE/Dockerfile" + echo "tagpost=mini-distroless" >> $GITHUB_OUTPUT + else + cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.minimized" "$GITHUB_WORKSPACE/Dockerfile" + echo "tagpost=mini" >> $GITHUB_OUTPUT + fi + else + if [[ "${{ matrix.distro }}" == "distroless" ]]; then + cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.standard" "$GITHUB_WORKSPACE/Dockerfile" + echo "tagpost=distroless" >> $GITHUB_OUTPUT + else + cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.standard" "$GITHUB_WORKSPACE/Dockerfile" + fi + fi + - name: Get tag to build + id: tag + run: | + if [[ -z "${{ github.event.inputs.branch }}" ]]; then + echo "versioned=etnperlong/sing-box:${{ github.ref_name }}" >> $GITHUB_OUTPUT + else + if [[ -n "${{ steps.dockerfile.outputs.tagpost }}" ]]; then + echo "versioned=etnperlong/sing-box:${{ github.event.inputs.branch }}-${{ steps.dockerfile.outputs.tagpost }}" >> $GITHUB_OUTPUT + else + echo "versioned=etnperlong/sing-box:${{ github.event.inputs.branch }}" >> $GITHUB_OUTPUT + fi + fi + - name: Build and release Docker images + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64,linux/arm/v7 + target: dist + tags: | + ${{ steps.tag.outputs.versioned }} + push: true \ No newline at end of file diff --git a/.github/workflows/build-singbox-docker.yml b/.github/workflows/build-singbox-docker.yml index 6a4d9a9..e408c30 100644 --- a/.github/workflows/build-singbox-docker.yml +++ b/.github/workflows/build-singbox-docker.yml @@ -71,8 +71,10 @@ jobs: id: tag run: | if [[ "${{ matrix.distro }}" == "alpine" && "${{ matrix.buildType }}" == "standard" ]]; then - latest="etnperlong/sing-box:latest" - echo "latest=$latest" >> $GITHUB_OUTPUT + echo "latest=etnperlong/sing-box:latest" >> $GITHUB_OUTPUT + fi + if [[ "${{ matrix.distro }}" == "distroless" && "${{ matrix.buildType }}" == "standard" ]]; then + echo "latest=etnperlong/sing-box:distroless" >> $GITHUB_OUTPUT fi if [[ -z "${{ github.event.inputs.tag }}" ]]; then echo "versioned=etnperlong/sing-box:${{ github.ref_name }}" >> $GITHUB_OUTPUT diff --git a/README.md b/README.md new file mode 100644 index 0000000..88ee7a3 --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# sing-box Docker Image by etnperlong + +![Docker Stars](https://img.shields.io/docker/stars/etnperlong/sing-box.svg) ![Docker Pulls](https://img.shields.io/docker/pulls/etnperlong/sing-box.svg) + +[sing-box](https://sing-box.sagernet.org/) is a universal proxy platform for building your own proxy. + +Docker images are built for quick deployment in various computing cloud providers. + +For more information on docker and containerization technologies, refer to [official document](https://docs.docker.com/). + +## Documentation + +[https://sing-box.sagernet.org](https://sing-box.sagernet.org) + +## Community +[https://community.sagernet.org/c/sing-box/](https://community.sagernet.org/c/sing-box/) + +## Supported architectures +- amd64 +- arm64 +- arm/v7 + +## Enabled features + +- `standard` +> `with_gvisor,with_quic,with_wireguard,with_utls,with_reality_server,with_clash_api,with_acme` + +- `full` +> `with_gvisor,with_quic,with_grpc,with_dhcp,with_wireguard,with_shadowsocksr,with_ech,with_utls,with_reality_server,with_clash_api,with_v2ray_api,with_acme` + +- `mini` +> `with_quic,with_utls,with_reality_server` + +## Supported tags + +- `latest` *([latest release](https://github.com/SagerNet/sing-box/releases))* +- `main` *([main branch](https://github.com/SagerNet/sing-box/tree/main))* +- `dev` *([dev branch](https://github.com/SagerNet/sing-box/tree/dev))* +- `dev-next` *([dev-next branch](https://github.com/SagerNet/sing-box/tree/dev))* + +## Additional distro + +Add `-distroless` to the end of the tag to use the build of distroless images. + +For example, `etnperlong/sing-box:dev-next-full-distroless` is the distroless build of full feature enabled image. diff --git a/dockerfiles/Dockerfile.distroless.full b/dockerfiles/Dockerfile.distroless.full index 5d548fa..a674af3 100644 --- a/dockerfiles/Dockerfile.distroless.full +++ b/dockerfiles/Dockerfile.distroless.full @@ -13,7 +13,7 @@ RUN set -ex \ -o /go/bin/sing-box \ -ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -s -w -buildid=" \ ./cmd/sing-box -FROM gcr.io/distroless/base-debian11:nonroot AS dist +FROM gcr.io/distroless/static-debian11:nonroot AS dist LABEL maintainer="Evans Mike " COPY --from=builder /go/bin/sing-box / CMD ["/sing-box"] \ No newline at end of file diff --git a/dockerfiles/Dockerfile.distroless.minimized b/dockerfiles/Dockerfile.distroless.minimized index c389be4..c160061 100644 --- a/dockerfiles/Dockerfile.distroless.minimized +++ b/dockerfiles/Dockerfile.distroless.minimized @@ -13,7 +13,7 @@ RUN set -ex \ -o /go/bin/sing-box \ -ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -s -w -buildid=" \ ./cmd/sing-box -FROM gcr.io/distroless/base-debian11:nonroot AS dist +FROM gcr.io/distroless/static-debian11:nonroot AS dist LABEL maintainer="Evans Mike " COPY --from=builder /go/bin/sing-box / CMD ["/sing-box"] \ No newline at end of file diff --git a/dockerfiles/Dockerfile.distroless.standard b/dockerfiles/Dockerfile.distroless.standard index 52f503d..85be386 100644 --- a/dockerfiles/Dockerfile.distroless.standard +++ b/dockerfiles/Dockerfile.distroless.standard @@ -13,7 +13,7 @@ RUN set -ex \ -o /go/bin/sing-box \ -ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -s -w -buildid=" \ ./cmd/sing-box -FROM gcr.io/distroless/base-debian11:nonroot AS dist +FROM gcr.io/distroless/static-debian11:nonroot AS dist LABEL maintainer="Evans Mike " COPY --from=builder /go/bin/sing-box / CMD ["/sing-box"] \ No newline at end of file From cb8b3df2d201faf9751d9e708f557b918b3950cb Mon Sep 17 00:00:00 2001 From: Mike Evans Date: Tue, 16 May 2023 11:11:02 +0100 Subject: [PATCH 02/10] feat: full version support for mainline --- .github/workflows/build-singbox-docker-mainline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-singbox-docker-mainline.yml b/.github/workflows/build-singbox-docker-mainline.yml index 0184fdb..8cefee5 100644 --- a/.github/workflows/build-singbox-docker-mainline.yml +++ b/.github/workflows/build-singbox-docker-mainline.yml @@ -12,8 +12,8 @@ jobs: strategy: fail-fast: true matrix: - buildType: [standard, full] - distro: [alpine] + buildType: [standard, minimized, full] + distro: [alpine, distroless] runs-on: ubuntu-latest steps: - name: Checkout Source Code of 'SagerNet/sing-box' From 2971d339159273af8a950224691465d29c095e9e Mon Sep 17 00:00:00 2001 From: Mike Evans Date: Tue, 16 May 2023 12:05:26 +0100 Subject: [PATCH 03/10] fix: distroless --- dockerfiles/Dockerfile.distroless.full | 4 ++-- dockerfiles/Dockerfile.distroless.minimized | 4 ++-- dockerfiles/Dockerfile.distroless.standard | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dockerfiles/Dockerfile.distroless.full b/dockerfiles/Dockerfile.distroless.full index a674af3..59094ce 100644 --- a/dockerfiles/Dockerfile.distroless.full +++ b/dockerfiles/Dockerfile.distroless.full @@ -13,7 +13,7 @@ RUN set -ex \ -o /go/bin/sing-box \ -ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -s -w -buildid=" \ ./cmd/sing-box -FROM gcr.io/distroless/static-debian11:nonroot AS dist +FROM gcr.io/distroless/static-debian11:latest AS dist LABEL maintainer="Evans Mike " COPY --from=builder /go/bin/sing-box / -CMD ["/sing-box"] \ No newline at end of file +ENTRYPOINT ["/sing-box"] \ No newline at end of file diff --git a/dockerfiles/Dockerfile.distroless.minimized b/dockerfiles/Dockerfile.distroless.minimized index c160061..22ab799 100644 --- a/dockerfiles/Dockerfile.distroless.minimized +++ b/dockerfiles/Dockerfile.distroless.minimized @@ -13,7 +13,7 @@ RUN set -ex \ -o /go/bin/sing-box \ -ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -s -w -buildid=" \ ./cmd/sing-box -FROM gcr.io/distroless/static-debian11:nonroot AS dist +FROM gcr.io/distroless/static-debian11:latest AS dist LABEL maintainer="Evans Mike " COPY --from=builder /go/bin/sing-box / -CMD ["/sing-box"] \ No newline at end of file +ENTRYPOINT ["/sing-box"] \ No newline at end of file diff --git a/dockerfiles/Dockerfile.distroless.standard b/dockerfiles/Dockerfile.distroless.standard index 85be386..af17286 100644 --- a/dockerfiles/Dockerfile.distroless.standard +++ b/dockerfiles/Dockerfile.distroless.standard @@ -13,7 +13,7 @@ RUN set -ex \ -o /go/bin/sing-box \ -ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -s -w -buildid=" \ ./cmd/sing-box -FROM gcr.io/distroless/static-debian11:nonroot AS dist +FROM gcr.io/distroless/static-debian11:latest AS dist LABEL maintainer="Evans Mike " COPY --from=builder /go/bin/sing-box / -CMD ["/sing-box"] \ No newline at end of file +ENTRYPOINT ["/sing-box"] \ No newline at end of file From 79835f64147630b3416d55c0b9be69156a4b66cd Mon Sep 17 00:00:00 2001 From: Mike Evans Date: Thu, 22 Jun 2023 17:42:59 +0100 Subject: [PATCH 04/10] fix: enable full version alpine build only --- .../build-singbox-docker-mainline.yml | 4 ++-- .github/workflows/build-singbox-docker.yml | 8 ++++---- README.md | 18 ++++-------------- dockerfiles/Dockerfile.standard | 2 +- 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-singbox-docker-mainline.yml b/.github/workflows/build-singbox-docker-mainline.yml index 8cefee5..0620dcc 100644 --- a/.github/workflows/build-singbox-docker-mainline.yml +++ b/.github/workflows/build-singbox-docker-mainline.yml @@ -12,8 +12,8 @@ jobs: strategy: fail-fast: true matrix: - buildType: [standard, minimized, full] - distro: [alpine, distroless] + buildType: [full] + distro: [alpine] runs-on: ubuntu-latest steps: - name: Checkout Source Code of 'SagerNet/sing-box' diff --git a/.github/workflows/build-singbox-docker.yml b/.github/workflows/build-singbox-docker.yml index e408c30..4562305 100644 --- a/.github/workflows/build-singbox-docker.yml +++ b/.github/workflows/build-singbox-docker.yml @@ -12,8 +12,8 @@ jobs: strategy: fail-fast: true matrix: - buildType: [standard, minimized, full] - distro: [alpine, distroless] + buildType: [full] + distro: [alpine] runs-on: ubuntu-latest steps: - name: Checkout Source Code of 'SagerNet/sing-box' @@ -70,10 +70,10 @@ jobs: - name: Get tag to build id: tag run: | - if [[ "${{ matrix.distro }}" == "alpine" && "${{ matrix.buildType }}" == "standard" ]]; then + if [[ "${{ matrix.distro }}" == "alpine" && "${{ matrix.buildType }}" == "full" ]]; then echo "latest=etnperlong/sing-box:latest" >> $GITHUB_OUTPUT fi - if [[ "${{ matrix.distro }}" == "distroless" && "${{ matrix.buildType }}" == "standard" ]]; then + if [[ "${{ matrix.distro }}" == "distroless" && "${{ matrix.buildType }}" == "full" ]]; then echo "latest=etnperlong/sing-box:distroless" >> $GITHUB_OUTPUT fi if [[ -z "${{ github.event.inputs.tag }}" ]]; then diff --git a/README.md b/README.md index 88ee7a3..4b8a728 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ [sing-box](https://sing-box.sagernet.org/) is a universal proxy platform for building your own proxy. -Docker images are built for quick deployment in various computing cloud providers. +Docker images are designed for rapid deployment to various computing cloud providers. -For more information on docker and containerization technologies, refer to [official document](https://docs.docker.com/). +For more information on Docker and containerization technologies, read the [official document](https://docs.docker.com/). ## Documentation @@ -22,15 +22,9 @@ For more information on docker and containerization technologies, refer to [offi ## Enabled features -- `standard` -> `with_gvisor,with_quic,with_wireguard,with_utls,with_reality_server,with_clash_api,with_acme` - -- `full` +**Full version!** > `with_gvisor,with_quic,with_grpc,with_dhcp,with_wireguard,with_shadowsocksr,with_ech,with_utls,with_reality_server,with_clash_api,with_v2ray_api,with_acme` -- `mini` -> `with_quic,with_utls,with_reality_server` - ## Supported tags - `latest` *([latest release](https://github.com/SagerNet/sing-box/releases))* @@ -38,8 +32,4 @@ For more information on docker and containerization technologies, refer to [offi - `dev` *([dev branch](https://github.com/SagerNet/sing-box/tree/dev))* - `dev-next` *([dev-next branch](https://github.com/SagerNet/sing-box/tree/dev))* -## Additional distro - -Add `-distroless` to the end of the tag to use the build of distroless images. - -For example, `etnperlong/sing-box:dev-next-full-distroless` is the distroless build of full feature enabled image. +For example, `etnperlong/sing-box:dev-next` means a fully functional docker image. diff --git a/dockerfiles/Dockerfile.standard b/dockerfiles/Dockerfile.standard index bd49446..0054c9c 100644 --- a/dockerfiles/Dockerfile.standard +++ b/dockerfiles/Dockerfile.standard @@ -9,7 +9,7 @@ RUN set -ex \ && apk add git build-base \ && export COMMIT=$(git rev-parse --short HEAD) \ && export VERSION=$(go run ./cmd/internal/read_tag) \ - && go build -v -trimpath -tags with_gvisor,with_quic,with_wireguard,with_utls,with_reality_server,with_clash_api,with_acme \ + && go build -v -trimpath -tags with_gvisor,with_quic,with_dhcp,with_wireguard,with_utls,with_reality_server,with_clash_api,with_acme \ -o /go/bin/sing-box \ -ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -s -w -buildid=" \ ./cmd/sing-box From a619192278c1b0cd41e13d767f011b04e16d41cd Mon Sep 17 00:00:00 2001 From: Mike Evans Date: Tue, 8 Aug 2023 16:44:35 +0100 Subject: [PATCH 05/10] fix: docker image tag --- .github/workflows/build-singbox-docker-mainline.yml | 2 +- .github/workflows/build-singbox-docker.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-singbox-docker-mainline.yml b/.github/workflows/build-singbox-docker-mainline.yml index 0620dcc..0a56f40 100644 --- a/.github/workflows/build-singbox-docker-mainline.yml +++ b/.github/workflows/build-singbox-docker-mainline.yml @@ -49,7 +49,7 @@ jobs: echo "tagpost=full-distroless" >> $GITHUB_OUTPUT else cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.full" "$GITHUB_WORKSPACE/Dockerfile" - echo "tagpost=full" >> $GITHUB_OUTPUT + # echo "tagpost=full" >> $GITHUB_OUTPUT fi elif [[ "${{ matrix.buildType }}" == "minimized" ]]; then if [[ "${{ matrix.distro }}" == "distroless" ]]; then diff --git a/.github/workflows/build-singbox-docker.yml b/.github/workflows/build-singbox-docker.yml index 4562305..401e3dc 100644 --- a/.github/workflows/build-singbox-docker.yml +++ b/.github/workflows/build-singbox-docker.yml @@ -49,7 +49,7 @@ jobs: echo "tagpost=full-distroless" >> $GITHUB_OUTPUT else cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.full" "$GITHUB_WORKSPACE/Dockerfile" - echo "tagpost=full" >> $GITHUB_OUTPUT + # echo "tagpost=full" >> $GITHUB_OUTPUT fi elif [[ "${{ matrix.buildType }}" == "minimized" ]]; then if [[ "${{ matrix.distro }}" == "distroless" ]]; then From 9a7b4bdd3996cfd3f585a2a734ebd6deca694c48 Mon Sep 17 00:00:00 2001 From: Mike Evans Date: Mon, 6 Nov 2023 00:37:54 +0000 Subject: [PATCH 06/10] update --- dockerfiles/Dockerfile.full | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dockerfiles/Dockerfile.full b/dockerfiles/Dockerfile.full index 4022b64..a6ebe80 100644 --- a/dockerfiles/Dockerfile.full +++ b/dockerfiles/Dockerfile.full @@ -1,4 +1,4 @@ -FROM golang:1.20-alpine AS builder +FROM golang:1.21-alpine AS builder LABEL maintainer="nekohasekai " COPY . /go/src/github.com/sagernet/sing-box WORKDIR /go/src/github.com/sagernet/sing-box @@ -9,7 +9,7 @@ RUN set -ex \ && apk add git build-base \ && export COMMIT=$(git rev-parse --short HEAD) \ && export VERSION=$(go run ./cmd/internal/read_tag) \ - && go build -v -trimpath -tags with_gvisor,with_quic,with_grpc,with_dhcp,with_wireguard,with_shadowsocksr,with_ech,with_utls,with_reality_server,with_clash_api,with_v2ray_api,with_acme \ + && go build -v -trimpath -tags with_gvisor,with_quic,with_grpc,with_dhcp,with_wireguard,with_ech,with_utls,with_reality_server,with_clash_api,with_acme,with_v2ray_api \ -o /go/bin/sing-box \ -ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -s -w -buildid=" \ ./cmd/sing-box From 045af45c5690afe91bd6cf53749f4ea86887ede9 Mon Sep 17 00:00:00 2001 From: Evans Mike Date: Tue, 21 Nov 2023 12:38:03 +0000 Subject: [PATCH 07/10] add repository_dispatch --- .github/workflows/build-singbox-docker-mainline.yml | 2 ++ .github/workflows/build-singbox-docker.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/build-singbox-docker-mainline.yml b/.github/workflows/build-singbox-docker-mainline.yml index 0a56f40..fdffd67 100644 --- a/.github/workflows/build-singbox-docker-mainline.yml +++ b/.github/workflows/build-singbox-docker-mainline.yml @@ -6,6 +6,8 @@ on: description: "The branch version you want to build" required: true default: "main" + repository_dispatch: + types: [build-mainline] jobs: build: diff --git a/.github/workflows/build-singbox-docker.yml b/.github/workflows/build-singbox-docker.yml index 401e3dc..e2f38b4 100644 --- a/.github/workflows/build-singbox-docker.yml +++ b/.github/workflows/build-singbox-docker.yml @@ -6,6 +6,8 @@ on: description: "The tag version you want to build" required: true default: "main" + repository_dispatch: + types: [build-release] jobs: build: From 5eeb17a9fb0a880879025744688c671a2ccc00b8 Mon Sep 17 00:00:00 2001 From: Evans Mike Date: Tue, 21 Nov 2023 12:44:17 +0000 Subject: [PATCH 08/10] action: support client_payload --- .github/workflows/build-singbox-docker.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-singbox-docker.yml b/.github/workflows/build-singbox-docker.yml index e2f38b4..ae653c3 100644 --- a/.github/workflows/build-singbox-docker.yml +++ b/.github/workflows/build-singbox-docker.yml @@ -17,12 +17,17 @@ jobs: buildType: [full] distro: [alpine] runs-on: ubuntu-latest + env: + TAG: ${{ github.event.client_payload.tag || github.event.inputs.tag}} steps: + - name: Get Build Tags + run: | + echo "Version: ${{env.TAG}}" - name: Checkout Source Code of 'SagerNet/sing-box' uses: actions/checkout@v3 with: repository: 'SagerNet/sing-box' - ref: ${{ github.event.inputs.tag }} + ref: ${{env.TAG}} submodules: true - name: Checkout Action Repo uses: actions/checkout@v3 @@ -78,13 +83,13 @@ jobs: if [[ "${{ matrix.distro }}" == "distroless" && "${{ matrix.buildType }}" == "full" ]]; then echo "latest=etnperlong/sing-box:distroless" >> $GITHUB_OUTPUT fi - if [[ -z "${{ github.event.inputs.tag }}" ]]; then + if [[ -z "${{env.TAG}}" ]]; then echo "versioned=etnperlong/sing-box:${{ github.ref_name }}" >> $GITHUB_OUTPUT else if [[ -n "${{ steps.dockerfile.outputs.tagpost }}" ]]; then - echo "versioned=etnperlong/sing-box:${{ github.event.inputs.tag }}-${{ steps.dockerfile.outputs.tagpost }}" >> $GITHUB_OUTPUT + echo "versioned=etnperlong/sing-box:${{env.TAG}}-${{ steps.dockerfile.outputs.tagpost }}" >> $GITHUB_OUTPUT else - echo "versioned=etnperlong/sing-box:${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT + echo "versioned=etnperlong/sing-box:${{env.TAG}}" >> $GITHUB_OUTPUT fi fi - name: Build and release Docker images From fd3ed889a03406dd2a33a8a35fa420a4e545aa7d Mon Sep 17 00:00:00 2001 From: Mike Evans Date: Fri, 1 Dec 2023 12:38:37 +0000 Subject: [PATCH 09/10] action: prerelease --- .../build-singbox-docker-prerelease.yml | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 .github/workflows/build-singbox-docker-prerelease.yml diff --git a/.github/workflows/build-singbox-docker-prerelease.yml b/.github/workflows/build-singbox-docker-prerelease.yml new file mode 100644 index 0000000..22185b2 --- /dev/null +++ b/.github/workflows/build-singbox-docker-prerelease.yml @@ -0,0 +1,103 @@ +name: Build Docker Images (Release) +on: + workflow_dispatch: + inputs: + tag: + description: "The tag version you want to build" + required: true + default: "main" + repository_dispatch: + types: [build-prerelease] + +jobs: + build: + strategy: + fail-fast: true + matrix: + buildType: [full] + distro: [alpine] + runs-on: ubuntu-latest + env: + TAG: ${{ github.event.client_payload.tag || github.event.inputs.tag}} + steps: + - name: Get Build Tags + run: | + echo "Version: ${{env.TAG}}" + - name: Checkout Source Code of 'SagerNet/sing-box' + uses: actions/checkout@v3 + with: + repository: 'SagerNet/sing-box' + ref: ${{env.TAG}} + submodules: true + - name: Checkout Action Repo + uses: actions/checkout@v3 + with: + path: action + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Setup QEMU for Docker Buildx + uses: docker/setup-qemu-action@v2 + - name: Login to Docker Hub Container Registry + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Docker metadata + id: metadata + uses: docker/metadata-action@v4 + with: + images: etnperlong/sing-box + - name: Select Dockerfile + id: dockerfile + run: | + if [[ "${{ matrix.buildType }}" == "full" ]]; then + if [[ "${{ matrix.distro }}" == "distroless" ]]; then + cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.full" "$GITHUB_WORKSPACE/Dockerfile" + echo "tagpost=full-distroless" >> $GITHUB_OUTPUT + else + cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.full" "$GITHUB_WORKSPACE/Dockerfile" + # echo "tagpost=full" >> $GITHUB_OUTPUT + fi + elif [[ "${{ matrix.buildType }}" == "minimized" ]]; then + if [[ "${{ matrix.distro }}" == "distroless" ]]; then + cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.minimized" "$GITHUB_WORKSPACE/Dockerfile" + echo "tagpost=mini-distroless" >> $GITHUB_OUTPUT + else + cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.minimized" "$GITHUB_WORKSPACE/Dockerfile" + echo "tagpost=mini" >> $GITHUB_OUTPUT + fi + else + if [[ "${{ matrix.distro }}" == "distroless" ]]; then + cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.standard" "$GITHUB_WORKSPACE/Dockerfile" + echo "tagpost=distroless" >> $GITHUB_OUTPUT + else + cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.standard" "$GITHUB_WORKSPACE/Dockerfile" + fi + fi + - name: Get tag to build + id: tag + run: | + if [[ "${{ matrix.distro }}" == "alpine" && "${{ matrix.buildType }}" == "full" ]]; then + echo "latest=etnperlong/sing-box:latest" >> $GITHUB_OUTPUT + fi + if [[ "${{ matrix.distro }}" == "distroless" && "${{ matrix.buildType }}" == "full" ]]; then + echo "latest=etnperlong/sing-box:distroless" >> $GITHUB_OUTPUT + fi + if [[ -z "${{env.TAG}}" ]]; then + echo "versioned=etnperlong/sing-box:${{ github.ref_name }}" >> $GITHUB_OUTPUT + else + if [[ -n "${{ steps.dockerfile.outputs.tagpost }}" ]]; then + echo "versioned=etnperlong/sing-box:${{env.TAG}}-${{ steps.dockerfile.outputs.tagpost }}" >> $GITHUB_OUTPUT + else + echo "versioned=etnperlong/sing-box:${{env.TAG}}" >> $GITHUB_OUTPUT + fi + fi + - name: Build and release Docker images + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64,linux/arm/v7 + target: dist + tags: | + ${{ steps.tag.outputs.versioned }} + push: true \ No newline at end of file From 50b3e7f42ad61bdf07b4c41957853aa82cc572fa Mon Sep 17 00:00:00 2001 From: Mike Evans Date: Fri, 1 Dec 2023 12:39:14 +0000 Subject: [PATCH 10/10] fix: prerelease --- .github/workflows/build-singbox-docker-prerelease.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-singbox-docker-prerelease.yml b/.github/workflows/build-singbox-docker-prerelease.yml index 22185b2..da4a6ab 100644 --- a/.github/workflows/build-singbox-docker-prerelease.yml +++ b/.github/workflows/build-singbox-docker-prerelease.yml @@ -1,4 +1,4 @@ -name: Build Docker Images (Release) +name: Build Docker Images (Pre-Release) on: workflow_dispatch: inputs: @@ -92,7 +92,7 @@ jobs: echo "versioned=etnperlong/sing-box:${{env.TAG}}" >> $GITHUB_OUTPUT fi fi - - name: Build and release Docker images + - name: Build and pre-release Docker images uses: docker/build-push-action@v4 with: context: .