init
This commit is contained in:
		
						commit
						8cef4e15bf
					
				
					 7 changed files with 224 additions and 0 deletions
				
			
		
							
								
								
									
										98
									
								
								.github/workflows/build-singbox-docker.yml
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								.github/workflows/build-singbox-docker.yml
									
										
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,98 @@
 | 
				
			||||||
 | 
					name: Build Docker Images
 | 
				
			||||||
 | 
					on:
 | 
				
			||||||
 | 
					  workflow_dispatch:
 | 
				
			||||||
 | 
					    inputs:
 | 
				
			||||||
 | 
					      tag:
 | 
				
			||||||
 | 
					        description: "The tag version or branch you want to build"
 | 
				
			||||||
 | 
					        required: true
 | 
				
			||||||
 | 
					        default: "main"
 | 
				
			||||||
 | 
					      buildType:
 | 
				
			||||||
 | 
					        description: "The type of build you want to build"
 | 
				
			||||||
 | 
					        required: true
 | 
				
			||||||
 | 
					        default: 'standard'
 | 
				
			||||||
 | 
					        type: choice
 | 
				
			||||||
 | 
					        options:
 | 
				
			||||||
 | 
					          - standard
 | 
				
			||||||
 | 
					          - minimized
 | 
				
			||||||
 | 
					          - full
 | 
				
			||||||
 | 
					      distro:
 | 
				
			||||||
 | 
					        description: "The distro you want to build"
 | 
				
			||||||
 | 
					        required: true
 | 
				
			||||||
 | 
					        default: 'alpine'
 | 
				
			||||||
 | 
					        type: choice
 | 
				
			||||||
 | 
					        options:
 | 
				
			||||||
 | 
					          - alpine
 | 
				
			||||||
 | 
					          - distroless
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					jobs:
 | 
				
			||||||
 | 
					  build:
 | 
				
			||||||
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					    steps:
 | 
				
			||||||
 | 
					      - name: Checkout Action Repo
 | 
				
			||||||
 | 
					        uses: actions/checkout@v3
 | 
				
			||||||
 | 
					        with:
 | 
				
			||||||
 | 
					          path: action
 | 
				
			||||||
 | 
					      - 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: Setup Docker Buildx
 | 
				
			||||||
 | 
					        uses: docker/setup-buildx-action@v2
 | 
				
			||||||
 | 
					      - name: Setup QEMU for Docker Buildx
 | 
				
			||||||
 | 
					        uses: docker/setup-qemu-action@v2
 | 
				
			||||||
 | 
					      - name: Select Dockerfile
 | 
				
			||||||
 | 
					        run: |
 | 
				
			||||||
 | 
					          if [[ "${{ github.event.inputs.buildType }}" == "full" ]]; then
 | 
				
			||||||
 | 
					            if [[ "${{ github.event.inputs.distro }}" == "distroless" ]]; then
 | 
				
			||||||
 | 
					              cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.full" > Dockerfile
 | 
				
			||||||
 | 
					              echo "tag_postfix=-full-distroless" >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					              cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.full" > Dockerfile
 | 
				
			||||||
 | 
					              echo "tag_postfix=-full" >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					              if [[ "${{ github.event.inputs.distro }}" == "distroless" ]]; then
 | 
				
			||||||
 | 
					            fi
 | 
				
			||||||
 | 
					          elif [[ "${{ github.event.inputs.buildType }}" == "minimized" ]]; then
 | 
				
			||||||
 | 
					            if [[ "${{ github.event.inputs.distro }}" == "distroless" ]]; then
 | 
				
			||||||
 | 
					              cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.minimized" > Dockerfile
 | 
				
			||||||
 | 
					              echo "tag_postfix=-mini-distroless" >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					              cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.minimized" > Dockerfile
 | 
				
			||||||
 | 
					              echo "tag_postfix=-mini" >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					            fi
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            if [[ "${{ github.event.inputs.distro }}" == "distroless" ]]; then
 | 
				
			||||||
 | 
					              cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.distroless.standard" > Dockerfile
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					              cp "$GITHUB_WORKSPACE/action/dockerfiles/Dockerfile.standard" > Dockerfile
 | 
				
			||||||
 | 
					            fi
 | 
				
			||||||
 | 
					          fi
 | 
				
			||||||
 | 
					      - 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: Get tag to build
 | 
				
			||||||
 | 
					        id: tag
 | 
				
			||||||
 | 
					        run: |
 | 
				
			||||||
 | 
					          echo "latest=etnperlong/sing-box:latest" >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					          if [[ -z "${{ github.event.inputs.tag }}" ]]; then
 | 
				
			||||||
 | 
					            echo "versioned=etnperlong/sing-box:${{ github.ref_name }}" >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					          else
 | 
				
			||||||
 | 
					            echo "versioned=etnperlong/sing-box:${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
 | 
				
			||||||
 | 
					          fi
 | 
				
			||||||
 | 
					      - name: Build and release Docker images
 | 
				
			||||||
 | 
					        uses: docker/build-push-action@v4
 | 
				
			||||||
 | 
					        with:
 | 
				
			||||||
 | 
					          platforms: linux/386,linux/amd64,linux/arm64,linux/arm/v7,linux/s390x
 | 
				
			||||||
 | 
					          target: dist
 | 
				
			||||||
 | 
					          tags: |
 | 
				
			||||||
 | 
					            ${{ steps.tag.outputs.latest }}
 | 
				
			||||||
 | 
					            ${{ steps.tag.outputs.versioned }}
 | 
				
			||||||
 | 
					          push: true
 | 
				
			||||||
							
								
								
									
										19
									
								
								dockerfiles/Dockerfile.distroless.full
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								dockerfiles/Dockerfile.distroless.full
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,19 @@
 | 
				
			||||||
 | 
					FROM golang:1.20-alpine AS builder
 | 
				
			||||||
 | 
					LABEL maintainer="nekohasekai <contact-git@sekai.icu>"
 | 
				
			||||||
 | 
					COPY . /go/src/github.com/sagernet/sing-box
 | 
				
			||||||
 | 
					WORKDIR /go/src/github.com/sagernet/sing-box
 | 
				
			||||||
 | 
					ARG GOPROXY=""
 | 
				
			||||||
 | 
					ENV GOPROXY ${GOPROXY}
 | 
				
			||||||
 | 
					ENV CGO_ENABLED=0
 | 
				
			||||||
 | 
					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 \
 | 
				
			||||||
 | 
					        -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
 | 
				
			||||||
 | 
					LABEL maintainer="Evans Mike <etnperlong@gmail.com>"
 | 
				
			||||||
 | 
					COPY --from=builder /go/bin/sing-box /
 | 
				
			||||||
 | 
					CMD ["/sing-box"]
 | 
				
			||||||
							
								
								
									
										19
									
								
								dockerfiles/Dockerfile.distroless.minimized
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								dockerfiles/Dockerfile.distroless.minimized
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,19 @@
 | 
				
			||||||
 | 
					FROM golang:1.20-alpine AS builder
 | 
				
			||||||
 | 
					LABEL maintainer="nekohasekai <contact-git@sekai.icu>"
 | 
				
			||||||
 | 
					COPY . /go/src/github.com/sagernet/sing-box
 | 
				
			||||||
 | 
					WORKDIR /go/src/github.com/sagernet/sing-box
 | 
				
			||||||
 | 
					ARG GOPROXY=""
 | 
				
			||||||
 | 
					ENV GOPROXY ${GOPROXY}
 | 
				
			||||||
 | 
					ENV CGO_ENABLED=0
 | 
				
			||||||
 | 
					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_quic,with_utls,with_reality_server \
 | 
				
			||||||
 | 
					        -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
 | 
				
			||||||
 | 
					LABEL maintainer="Evans Mike <etnperlong@gmail.com>"
 | 
				
			||||||
 | 
					COPY --from=builder /go/bin/sing-box /
 | 
				
			||||||
 | 
					CMD ["/sing-box"]
 | 
				
			||||||
							
								
								
									
										19
									
								
								dockerfiles/Dockerfile.distroless.standard
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								dockerfiles/Dockerfile.distroless.standard
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,19 @@
 | 
				
			||||||
 | 
					FROM golang:1.20-alpine AS builder
 | 
				
			||||||
 | 
					LABEL maintainer="nekohasekai <contact-git@sekai.icu>"
 | 
				
			||||||
 | 
					COPY . /go/src/github.com/sagernet/sing-box
 | 
				
			||||||
 | 
					WORKDIR /go/src/github.com/sagernet/sing-box
 | 
				
			||||||
 | 
					ARG GOPROXY=""
 | 
				
			||||||
 | 
					ENV GOPROXY ${GOPROXY}
 | 
				
			||||||
 | 
					ENV CGO_ENABLED=0
 | 
				
			||||||
 | 
					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 \
 | 
				
			||||||
 | 
					        -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
 | 
				
			||||||
 | 
					LABEL maintainer="Evans Mike <etnperlong@gmail.com>"
 | 
				
			||||||
 | 
					COPY --from=builder /go/bin/sing-box /
 | 
				
			||||||
 | 
					CMD ["/sing-box"]
 | 
				
			||||||
							
								
								
									
										23
									
								
								dockerfiles/Dockerfile.full
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								dockerfiles/Dockerfile.full
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,23 @@
 | 
				
			||||||
 | 
					FROM golang:1.20-alpine AS builder
 | 
				
			||||||
 | 
					LABEL maintainer="nekohasekai <contact-git@sekai.icu>"
 | 
				
			||||||
 | 
					COPY . /go/src/github.com/sagernet/sing-box
 | 
				
			||||||
 | 
					WORKDIR /go/src/github.com/sagernet/sing-box
 | 
				
			||||||
 | 
					ARG GOPROXY=""
 | 
				
			||||||
 | 
					ENV GOPROXY ${GOPROXY}
 | 
				
			||||||
 | 
					ENV CGO_ENABLED=0
 | 
				
			||||||
 | 
					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 \
 | 
				
			||||||
 | 
					        -o /go/bin/sing-box \
 | 
				
			||||||
 | 
					        -ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -s -w -buildid=" \
 | 
				
			||||||
 | 
					        ./cmd/sing-box
 | 
				
			||||||
 | 
					FROM alpine AS dist
 | 
				
			||||||
 | 
					LABEL maintainer="nekohasekai <contact-git@sekai.icu>"
 | 
				
			||||||
 | 
					RUN set -ex \
 | 
				
			||||||
 | 
					    && apk upgrade \
 | 
				
			||||||
 | 
					    && apk add bash tzdata ca-certificates \
 | 
				
			||||||
 | 
					    && rm -rf /var/cache/apk/*
 | 
				
			||||||
 | 
					COPY --from=builder /go/bin/sing-box /usr/local/bin/sing-box
 | 
				
			||||||
 | 
					ENTRYPOINT ["sing-box"]
 | 
				
			||||||
							
								
								
									
										23
									
								
								dockerfiles/Dockerfile.minimized
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								dockerfiles/Dockerfile.minimized
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,23 @@
 | 
				
			||||||
 | 
					FROM golang:1.20-alpine AS builder
 | 
				
			||||||
 | 
					LABEL maintainer="nekohasekai <contact-git@sekai.icu>"
 | 
				
			||||||
 | 
					COPY . /go/src/github.com/sagernet/sing-box
 | 
				
			||||||
 | 
					WORKDIR /go/src/github.com/sagernet/sing-box
 | 
				
			||||||
 | 
					ARG GOPROXY=""
 | 
				
			||||||
 | 
					ENV GOPROXY ${GOPROXY}
 | 
				
			||||||
 | 
					ENV CGO_ENABLED=0
 | 
				
			||||||
 | 
					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_quic,with_utls,with_reality_server \
 | 
				
			||||||
 | 
					        -o /go/bin/sing-box \
 | 
				
			||||||
 | 
					        -ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -s -w -buildid=" \
 | 
				
			||||||
 | 
					        ./cmd/sing-box
 | 
				
			||||||
 | 
					FROM alpine AS dist
 | 
				
			||||||
 | 
					LABEL maintainer="nekohasekai <contact-git@sekai.icu>"
 | 
				
			||||||
 | 
					RUN set -ex \
 | 
				
			||||||
 | 
					    && apk upgrade \
 | 
				
			||||||
 | 
					    && apk add bash tzdata ca-certificates \
 | 
				
			||||||
 | 
					    && rm -rf /var/cache/apk/*
 | 
				
			||||||
 | 
					COPY --from=builder /go/bin/sing-box /usr/local/bin/sing-box
 | 
				
			||||||
 | 
					ENTRYPOINT ["sing-box"]
 | 
				
			||||||
							
								
								
									
										23
									
								
								dockerfiles/Dockerfile.standard
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								dockerfiles/Dockerfile.standard
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,23 @@
 | 
				
			||||||
 | 
					FROM golang:1.20-alpine AS builder
 | 
				
			||||||
 | 
					LABEL maintainer="nekohasekai <contact-git@sekai.icu>"
 | 
				
			||||||
 | 
					COPY . /go/src/github.com/sagernet/sing-box
 | 
				
			||||||
 | 
					WORKDIR /go/src/github.com/sagernet/sing-box
 | 
				
			||||||
 | 
					ARG GOPROXY=""
 | 
				
			||||||
 | 
					ENV GOPROXY ${GOPROXY}
 | 
				
			||||||
 | 
					ENV CGO_ENABLED=0
 | 
				
			||||||
 | 
					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 \
 | 
				
			||||||
 | 
					        -o /go/bin/sing-box \
 | 
				
			||||||
 | 
					        -ldflags "-X \"github.com/sagernet/sing-box/constant.Version=$VERSION\" -s -w -buildid=" \
 | 
				
			||||||
 | 
					        ./cmd/sing-box
 | 
				
			||||||
 | 
					FROM alpine AS dist
 | 
				
			||||||
 | 
					LABEL maintainer="nekohasekai <contact-git@sekai.icu>"
 | 
				
			||||||
 | 
					RUN set -ex \
 | 
				
			||||||
 | 
					    && apk upgrade \
 | 
				
			||||||
 | 
					    && apk add bash tzdata ca-certificates \
 | 
				
			||||||
 | 
					    && rm -rf /var/cache/apk/*
 | 
				
			||||||
 | 
					COPY --from=builder /go/bin/sing-box /usr/local/bin/sing-box
 | 
				
			||||||
 | 
					ENTRYPOINT ["sing-box"]
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue