feat: Add Dockerfile for tunnel service and integrate its build and push into the CD workflow.

lemon-mint committed Nov 20, 2025 at 07:17 UTC 0f819ccb25046ed5c26e4b15418b48003fd54eed
2 files changed +69
.github/workflows/cd.yml
+48
@@ -60,6 +60,54 @@ jobs:
60 cache-from: type=gha,mode=max
61 cache-to: type=gha,mode=max
62
63 + build-and-push-tunnel:
64 + name: Build and Push Tunnel Docker Image
65 + runs-on: ubuntu-latest
66 + permissions:
67 + contents: read
68 + packages: write
69 +
70 + steps:
71 + - name: Checkout code
72 + uses: actions/checkout@v5
73 +
74 + - name: Log in to Container Registry
75 + uses: docker/login-action@v3
76 + with:
77 + registry: ${{ env.REGISTRY }}
78 + username: ${{ github.actor }}
79 + password: ${{ secrets.GITHUB_TOKEN }}
80 +
81 + - name: Set up QEMU
82 + uses: docker/setup-qemu-action@v3
83 +
84 + - name: Set up Docker Buildx
85 + uses: docker/setup-buildx-action@v3
86 +
87 + - name: Extract metadata
88 + id: meta
89 + uses: docker/metadata-action@v5
90 + with:
91 + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-tunnel
92 + tags: |
93 + type=ref,event=branch
94 + type=ref,event=pr
95 + type=semver,pattern={{version}}
96 + type=semver,pattern={{major}}.{{minor}}
97 + type=semver,pattern={{major}}
98 + type=sha,enable=true,prefix=sha-,suffix=,format=short
99 +
100 + - name: Build and push Docker image
101 + uses: docker/build-push-action@v6
102 + with:
103 + file: Dockerfile.tunnel
104 + platforms: ${{ env.PLATFORMS }}
105 + push: true
106 + tags: ${{ steps.meta.outputs.tags }}
107 + labels: ${{ steps.meta.outputs.labels }}
108 + cache-from: type=gha,mode=max
109 + cache-to: type=gha,mode=max
110 +
111 deploy:
112 name: Deploy to `https://portal.iwanhae.kr`
113 if: github.ref == 'refs/heads/main' && github.event_name == 'push'
Dockerfile.tunnel new
+21
@@ -0,0 +1,21 @@
1 +# syntax=docker/dockerfile:1
2 +
3 +FROM --platform=$BUILDPLATFORM golang:1 AS builder
4 +WORKDIR /src
5 +
6 +COPY go.mod go.sum ./
7 +RUN --mount=type=cache,target=/go/pkg/mod go mod download
8 +
9 +COPY . .
10 +
11 +ARG TARGETOS
12 +ARG TARGETARCH
13 +RUN --mount=type=cache,target=/go/pkg/mod \
14 + --mount=type=cache,target=/root/.cache/go-build \
15 + GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build-tunnel
16 +
17 +FROM gcr.io/distroless/static-debian12:nonroot
18 +
19 +COPY --from=builder /src/bin/portal-tunnel /usr/bin/portal-tunnel
20 +
21 +ENTRYPOINT ["/usr/bin/portal-tunnel"]