Skip to content

Commit 18c6d8f

Browse files
committed
chore: use buildx for cross-platform image builds
1 parent 3c3da93 commit 18c6d8f

File tree

6 files changed

+106
-48
lines changed

6 files changed

+106
-48
lines changed

.github/workflows/release.yml

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
1212
runs-on: ubuntu-latest
1313
env:
1414
GO_VERSION: '1.20'
15-
SEIHON_VERSION: v0.8.3
1615
CGO_ENABLED: 0
1716

1817
steps:
@@ -34,27 +33,23 @@ jobs:
3433
restore-keys: |
3534
${{ runner.os }}-go-
3635
36+
- name: Docker Login
37+
env:
38+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
39+
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
40+
run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
41+
42+
- name: Set up QEMU
43+
uses: docker/setup-qemu-action@v2
44+
45+
- name: Set up Docker Buildx
46+
uses: docker/setup-buildx-action@v2
47+
3748
# https://goreleaser.com/ci/actions/
3849
- name: Run GoReleaser
3950
uses: goreleaser/goreleaser-action@v3
4051
with:
4152
version: latest
42-
args: release --rm-dist --timeout=60m
53+
args: release --clean --timeout=90m
4354
env:
4455
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_REPO }}
45-
46-
# Install Docker image multi-arch builder
47-
- name: Install Seihon ${{ env.SEIHON_VERSION }}
48-
if: startsWith(github.ref, 'refs/tags/v')
49-
run: |
50-
curl -sSfL https://raw.githubusercontent.com/ldez/seihon/master/godownloader.sh | sh -s -- -b $(go env GOPATH)/bin ${SEIHON_VERSION}
51-
seihon --version
52-
53-
- name: Docker Login
54-
env:
55-
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
56-
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
57-
run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
58-
59-
- name: Publish Docker Images (Seihon)
60-
run: make publish-images

.goreleaser.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,85 @@ archives:
5151
files:
5252
- LICENSE
5353
- CHANGELOG.md
54+
55+
docker_manifests:
56+
- name_template: 'goacme/lego:{{ .Tag }}'
57+
image_templates:
58+
- 'goacme/lego:{{ .Tag }}-amd64'
59+
- 'goacme/lego:{{ .Tag }}-arm64'
60+
- 'goacme/lego:{{ .Tag }}-armv7'
61+
- name_template: 'goacme/lego:latest'
62+
image_templates:
63+
- 'goacme/lego:{{ .Tag }}-amd64'
64+
- 'goacme/lego:{{ .Tag }}-arm64'
65+
- 'goacme/lego:{{ .Tag }}-armv7'
66+
- name_template: 'goacme/lego:v{{ .Major }}.{{ .Minor }}'
67+
image_templates:
68+
- 'goacme/lego:v{{ .Major }}.{{ .Minor }}-amd64'
69+
- 'goacme/lego:v{{ .Major }}.{{ .Minor }}-arm64'
70+
- 'goacme/lego:v{{ .Major }}.{{ .Minor }}-armv7'
71+
72+
dockers:
73+
- use: buildx
74+
goos: linux
75+
goarch: amd64
76+
dockerfile: buildx.Dockerfile
77+
image_templates:
78+
- 'goacme/lego:latest-amd64'
79+
- 'goacme/lego:{{ .Tag }}-amd64'
80+
- 'goacme/lego:v{{ .Major }}.{{ .Minor }}-amd64'
81+
build_flag_templates:
82+
- '--pull'
83+
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
84+
- '--label=org.opencontainers.image.title={{.ProjectName}}'
85+
- '--label=org.opencontainers.image.description=Lets Encrypt/ACME client and library written in Go'
86+
- '--label=org.opencontainers.image.source={{.GitURL}}'
87+
- '--label=org.opencontainers.image.url={{.GitURL}}'
88+
- '--label=org.opencontainers.image.documentation=https://go-acme.github.io/lego'
89+
- '--label=org.opencontainers.image.created={{.Date}}'
90+
- '--label=org.opencontainers.image.revision={{.FullCommit}}'
91+
- '--label=org.opencontainers.image.version={{.Version}}'
92+
- '--platform=linux/amd64'
93+
94+
- use: buildx
95+
goos: linux
96+
goarch: arm64
97+
dockerfile: buildx.Dockerfile
98+
image_templates:
99+
- 'goacme/lego:latest-arm64'
100+
- 'goacme/lego:{{ .Tag }}-arm64'
101+
- 'goacme/lego:v{{ .Major }}.{{ .Minor }}-arm64'
102+
build_flag_templates:
103+
- '--pull'
104+
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
105+
- '--label=org.opencontainers.image.title={{.ProjectName}}'
106+
- '--label=org.opencontainers.image.description=Lets Encrypt/ACME client and library written in Go'
107+
- '--label=org.opencontainers.image.source={{.GitURL}}'
108+
- '--label=org.opencontainers.image.url={{.GitURL}}'
109+
- '--label=org.opencontainers.image.documentation=https://go-acme.github.io/lego'
110+
- '--label=org.opencontainers.image.created={{.Date}}'
111+
- '--label=org.opencontainers.image.revision={{.FullCommit}}'
112+
- '--label=org.opencontainers.image.version={{.Version}}'
113+
- '--platform=linux/arm64'
114+
115+
- use: buildx
116+
goos: linux
117+
goarch: arm
118+
goarm: '7'
119+
dockerfile: buildx.Dockerfile
120+
image_templates:
121+
- 'goacme/lego:latest-armv7'
122+
- 'goacme/lego:{{ .Tag }}-armv7'
123+
- 'goacme/lego:v{{ .Major }}.{{ .Minor }}-armv7'
124+
build_flag_templates:
125+
- '--pull'
126+
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
127+
- '--label=org.opencontainers.image.title={{.ProjectName}}'
128+
- '--label=org.opencontainers.image.description=Lets Encrypt/ACME client and library written in Go'
129+
- '--label=org.opencontainers.image.source={{.GitURL}}'
130+
- '--label=org.opencontainers.image.url={{.GitURL}}'
131+
- '--label=org.opencontainers.image.documentation=https://go-acme.github.io/lego'
132+
- '--label=org.opencontainers.image.created={{.Date}}'
133+
- '--label=org.opencontainers.image.revision={{.FullCommit}}'
134+
- '--label=org.opencontainers.image.version={{.Version}}'
135+
- '--platform=linux/arm/v7'

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN go mod download
1414
COPY . .
1515
RUN make build
1616

17-
FROM alpine:3.12
17+
FROM alpine:3
1818
RUN apk update \
1919
&& apk add --no-cache ca-certificates tzdata \
2020
&& update-ca-certificates

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ image:
2626
@echo Version: $(VERSION)
2727
docker build -t $(LEGO_IMAGE) .
2828

29-
publish-images:
30-
seihon publish -v "$(TAG_NAME)" -v "latest" --image-name="$(LEGO_IMAGE)" --dry-run=false
31-
3229
test: clean
3330
go test -v -cover ./...
3431

buildx.Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# syntax=docker/dockerfile:1.4
2+
FROM alpine:3
3+
4+
RUN apk --no-cache --no-progress add git ca-certificates tzdata \
5+
&& rm -rf /var/cache/apk/*
6+
7+
COPY lego /
8+
9+
ENTRYPOINT ["/lego"]
10+
EXPOSE 80

tmpl.Dockerfile

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

0 commit comments

Comments
 (0)