Skip to content

Commit 5eb589c

Browse files
committed
feat: Complete GoReleaser integration with dual image support
Major overhaul of build and release infrastructure: ## GoReleaser Configuration - Multi-platform binary builds (Linux, Windows, macOS) - Cross-architecture support (amd64, arm64, armv6, armv7) - Automated GitHub releases with binaries and checksums - Docker multi-architecture builds via GoReleaser ## Docker Images - **Distroless** (production): Minimal, secure images (~2MB) - **Alpine** (debug): Images with shell and tools (~7MB) - Multi-arch support: amd64, arm64, armv7 - Dual registry publishing: Docker Hub + GitHub Container Registry ## Image Tags - `latest` - Latest stable release - `vX.Y.Z`, `vX.Y`, `vX` - Semantic versions - `main` - Latest commit from main branch (unstable) - All tags available in `-alpine` variant for debugging ## GitHub Actions Workflows - **ci.yml**: Lint, build, and test on PRs and main - **release.yml**: Release workflow triggered on version tags - **main-build.yml**: Automated builds of main branch - **Removed**: docker-publish.yml (replaced by GoReleaser) ## Documentation - Added comprehensive Docker tags documentation - Installation methods: binaries, source, Docker - Clear distinction between production and debug images - Updated both README.md and README.dockerhub.md ## Credits Based on work from blueimp#24 by @mabels
1 parent 62c7399 commit 5eb589c

File tree

9 files changed

+622
-196
lines changed

9 files changed

+622
-196
lines changed

.github/workflows/ci.yml

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,49 +3,58 @@ name: CI
33
on:
44
pull_request:
55
push:
6+
branches:
7+
- main
68

79
jobs:
8-
build:
9-
name: build
10+
lint:
11+
name: Lint
1012
runs-on: ubuntu-latest
1113
steps:
1214
- uses: actions/checkout@v4
15+
1316
- uses: actions/setup-go@v5
1417
with:
1518
go-version: '1.23'
16-
- run: go install honnef.co/go/tools/cmd/staticcheck@latest
17-
- run: go vet ./...
18-
- run: go build -v ./...
19-
- run: go test -v ./...
2019

21-
test:
22-
name: Test
20+
- name: Install staticcheck
21+
run: go install honnef.co/go/tools/cmd/staticcheck@latest
22+
23+
- name: Run staticcheck
24+
run: staticcheck ./...
25+
26+
build:
27+
name: Build
2328
runs-on: ubuntu-latest
2429
steps:
2530
- uses: actions/checkout@v4
31+
2632
- uses: actions/setup-go@v5
2733
with:
2834
go-version: '1.23'
29-
- run: go test ./...
3035

31-
release:
32-
name: Release
36+
- name: Run go vet
37+
run: go vet ./...
38+
39+
- name: Build binary
40+
run: go build -v ./...
41+
42+
test:
43+
name: Test
3344
runs-on: ubuntu-latest
34-
if: startsWith(github.ref, 'refs/tags/v')
35-
needs: [build, test]
3645
steps:
3746
- uses: actions/checkout@v4
38-
with:
39-
fetch-depth: 0
47+
4048
- uses: actions/setup-go@v5
4149
with:
4250
go-version: '1.23'
43-
- name: Docker login
44-
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
45-
- name: Run GoReleaser
46-
uses: goreleaser/goreleaser-action@v5
51+
52+
- name: Run tests
53+
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
54+
55+
- name: Upload coverage to Codecov
56+
uses: codecov/codecov-action@v4
57+
if: github.event_name != 'pull_request'
4758
with:
48-
version: latest
49-
args: release --clean
50-
env:
51-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
files: ./coverage.txt
60+
fail_ci_if_error: false

.github/workflows/docker-publish.yml

Lines changed: 0 additions & 74 deletions
This file was deleted.

.github/workflows/main-build.yml

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
name: Build Main Branch
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build-main:
10+
name: Build and Push Main Images
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: '1.23'
25+
26+
- name: Set up QEMU
27+
uses: docker/setup-qemu-action@v3
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Log in to Docker Hub
33+
uses: docker/login-action@v3
34+
with:
35+
username: ${{ secrets.DOCKERHUB_USERNAME }}
36+
password: ${{ secrets.DOCKERHUB_TOKEN }}
37+
38+
- name: Log in to GitHub Container Registry
39+
uses: docker/login-action@v3
40+
with:
41+
registry: ghcr.io
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Run GoReleaser (Snapshot)
46+
uses: goreleaser/goreleaser-action@v6
47+
with:
48+
distribution: goreleaser
49+
version: '~> v2'
50+
args: release --snapshot --clean --skip=validate
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Build binaries
55+
run: |
56+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o dist/aws-smtp-relay-linux-amd64
57+
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o dist/aws-smtp-relay-linux-arm64
58+
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags="-s -w" -o dist/aws-smtp-relay-linux-armv7
59+
60+
- name: Build and push Docker images (Distroless)
61+
run: |
62+
# AMD64
63+
docker buildx build --platform linux/amd64 \
64+
--file Dockerfile \
65+
--tag kamorion/aws-smtp-relay:main-amd64 \
66+
--tag ghcr.io/kamorionlabs/aws-smtp-relay:main-amd64 \
67+
--build-arg BINARY=dist/aws-smtp-relay-linux-amd64 \
68+
--push \
69+
-f - . <<'EOF'
70+
FROM gcr.io/distroless/static-debian12:nonroot
71+
ARG BINARY
72+
COPY ${BINARY} /bin/aws-smtp-relay
73+
ENTRYPOINT ["/bin/aws-smtp-relay"]
74+
EOF
75+
76+
# ARM64
77+
docker buildx build --platform linux/arm64 \
78+
--file Dockerfile \
79+
--tag kamorion/aws-smtp-relay:main-arm64v8 \
80+
--tag ghcr.io/kamorionlabs/aws-smtp-relay:main-arm64v8 \
81+
--build-arg BINARY=dist/aws-smtp-relay-linux-arm64 \
82+
--push \
83+
-f - . <<'EOF'
84+
FROM gcr.io/distroless/static-debian12:nonroot
85+
ARG BINARY
86+
COPY ${BINARY} /bin/aws-smtp-relay
87+
ENTRYPOINT ["/bin/aws-smtp-relay"]
88+
EOF
89+
90+
# ARMv7
91+
docker buildx build --platform linux/arm/v7 \
92+
--file Dockerfile \
93+
--tag kamorion/aws-smtp-relay:main-armv7 \
94+
--tag ghcr.io/kamorionlabs/aws-smtp-relay:main-armv7 \
95+
--build-arg BINARY=dist/aws-smtp-relay-linux-armv7 \
96+
--push \
97+
-f - . <<'EOF'
98+
FROM gcr.io/distroless/static-debian12:nonroot
99+
ARG BINARY
100+
COPY ${BINARY} /bin/aws-smtp-relay
101+
ENTRYPOINT ["/bin/aws-smtp-relay"]
102+
EOF
103+
104+
- name: Build and push Docker images (Alpine)
105+
run: |
106+
# AMD64 Alpine
107+
docker buildx build --platform linux/amd64 \
108+
--tag kamorion/aws-smtp-relay:main-alpine-amd64 \
109+
--tag ghcr.io/kamorionlabs/aws-smtp-relay:main-alpine-amd64 \
110+
--build-arg BINARY=dist/aws-smtp-relay-linux-amd64 \
111+
--push \
112+
-f - . <<'EOF'
113+
FROM alpine:latest
114+
RUN apk --no-cache add ca-certificates
115+
ARG BINARY
116+
COPY ${BINARY} /bin/aws-smtp-relay
117+
USER 65534
118+
ENTRYPOINT ["/bin/aws-smtp-relay"]
119+
EOF
120+
121+
# ARM64 Alpine
122+
docker buildx build --platform linux/arm64 \
123+
--tag kamorion/aws-smtp-relay:main-alpine-arm64v8 \
124+
--tag ghcr.io/kamorionlabs/aws-smtp-relay:main-alpine-arm64v8 \
125+
--build-arg BINARY=dist/aws-smtp-relay-linux-arm64 \
126+
--push \
127+
-f - . <<'EOF'
128+
FROM alpine:latest
129+
RUN apk --no-cache add ca-certificates
130+
ARG BINARY
131+
COPY ${BINARY} /bin/aws-smtp-relay
132+
USER 65534
133+
ENTRYPOINT ["/bin/aws-smtp-relay"]
134+
EOF
135+
136+
# ARMv7 Alpine
137+
docker buildx build --platform linux/arm/v7 \
138+
--tag kamorion/aws-smtp-relay:main-alpine-armv7 \
139+
--tag ghcr.io/kamorionlabs/aws-smtp-relay:main-alpine-armv7 \
140+
--build-arg BINARY=dist/aws-smtp-relay-linux-armv7 \
141+
--push \
142+
-f - . <<'EOF'
143+
FROM alpine:latest
144+
RUN apk --no-cache add ca-certificates
145+
ARG BINARY
146+
COPY ${BINARY} /bin/aws-smtp-relay
147+
USER 65534
148+
ENTRYPOINT ["/bin/aws-smtp-relay"]
149+
EOF
150+
151+
- name: Create Docker manifests (Distroless)
152+
run: |
153+
docker buildx imagetools create -t kamorion/aws-smtp-relay:main \
154+
kamorion/aws-smtp-relay:main-amd64 \
155+
kamorion/aws-smtp-relay:main-arm64v8 \
156+
kamorion/aws-smtp-relay:main-armv7
157+
158+
docker buildx imagetools create -t ghcr.io/kamorionlabs/aws-smtp-relay:main \
159+
ghcr.io/kamorionlabs/aws-smtp-relay:main-amd64 \
160+
ghcr.io/kamorionlabs/aws-smtp-relay:main-arm64v8 \
161+
ghcr.io/kamorionlabs/aws-smtp-relay:main-armv7
162+
163+
- name: Create Docker manifests (Alpine)
164+
run: |
165+
docker buildx imagetools create -t kamorion/aws-smtp-relay:main-alpine \
166+
kamorion/aws-smtp-relay:main-alpine-amd64 \
167+
kamorion/aws-smtp-relay:main-alpine-arm64v8 \
168+
kamorion/aws-smtp-relay:main-alpine-armv7
169+
170+
docker buildx imagetools create -t ghcr.io/kamorionlabs/aws-smtp-relay:main-alpine \
171+
ghcr.io/kamorionlabs/aws-smtp-relay:main-alpine-amd64 \
172+
ghcr.io/kamorionlabs/aws-smtp-relay:main-alpine-arm64v8 \
173+
ghcr.io/kamorionlabs/aws-smtp-relay:main-alpine-armv7

.github/workflows/release.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
packages: write
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: '1.23'
25+
26+
- name: Set up QEMU
27+
uses: docker/setup-qemu-action@v3
28+
29+
- name: Set up Docker Buildx
30+
uses: docker/setup-buildx-action@v3
31+
32+
- name: Log in to Docker Hub
33+
uses: docker/login-action@v3
34+
with:
35+
username: ${{ secrets.DOCKERHUB_USERNAME }}
36+
password: ${{ secrets.DOCKERHUB_TOKEN }}
37+
38+
- name: Log in to GitHub Container Registry
39+
uses: docker/login-action@v3
40+
with:
41+
registry: ghcr.io
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Run GoReleaser
46+
uses: goreleaser/goreleaser-action@v6
47+
with:
48+
distribution: goreleaser
49+
version: '~> v2'
50+
args: release --clean
51+
env:
52+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)