From a06d2ddddd8371bb0c630db8256f20ffb42ecf98 Mon Sep 17 00:00:00 2001 From: YR Chen Date: Tue, 13 Aug 2024 00:33:26 +0800 Subject: [PATCH 1/4] Add Dockerfile based on Distroless --- Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4c33391 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM golang:1.22 AS build + +WORKDIR /go/src/app +COPY . . + +RUN go mod download +RUN CGO_ENABLED=0 go build -o /go/bin/sshmux + +FROM gcr.io/distroless/static-debian12:nonroot +COPY --from=build /go/bin/sshmux / +CMD ["/sshmux"] From 78a3c5e36affe489761435d27c1c99b26a2b70c8 Mon Sep 17 00:00:00 2001 From: YR Chen Date: Tue, 13 Aug 2024 00:33:50 +0800 Subject: [PATCH 2/4] Add Docker to build workflow --- .github/workflows/build.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 61cf02d..e1db217 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,3 +41,35 @@ jobs: sshmux config.example.json sshmux.service + docker: + name: Build Docker image + runs-on: ubuntu-latest + steps: + - name: Compute Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/ustc-vlab/sshmux + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=sha + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to GHCR + if: startsWith(github.ref, 'refs/tags/') + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ github.token }} + - name: Build and push image + uses: docker/build-push-action@v6 + with: + push: ${{ startsWith(github.ref, 'refs/tags/') }} + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From d13f5882633178af141dadb5e09db0584a468d98 Mon Sep 17 00:00:00 2001 From: YR Chen Date: Tue, 13 Aug 2024 00:51:50 +0800 Subject: [PATCH 3/4] Minor tweak --- .github/workflows/build.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e1db217..15686e2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,10 +42,10 @@ jobs: config.example.json sshmux.service docker: - name: Build Docker image + name: Docker runs-on: ubuntu-latest steps: - - name: Compute Docker meta + - name: Compute Docker metadata id: meta uses: docker/metadata-action@v5 with: @@ -54,7 +54,6 @@ jobs: type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} - type=sha - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx From 6e6fb058390534173f2187231e1c557e4edfb336 Mon Sep 17 00:00:00 2001 From: YR Chen Date: Tue, 13 Aug 2024 01:14:22 +0800 Subject: [PATCH 4/4] Update .github/workflows/build.yml Co-authored-by: taoky --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 15686e2..ebfcc46 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -49,7 +49,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ghcr.io/ustc-vlab/sshmux + images: ghcr.io/ustc-vlab/sshmux tags: | type=ref,event=branch type=ref,event=pr