Skip to content

Commit d3bb56c

Browse files
Build and push docker image with many platforms
Signed-off-by: roman-kiselenko <roman.kiselenko.dev@gmail.com>
1 parent c5d1a7c commit d3bb56c

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

.github/workflows/docker.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ env:
1111
jobs:
1212
build-and-push-image:
1313
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
platform:
18+
- linux/amd64
19+
- linux/arm64
1420
permissions:
1521
contents: read
1622
packages: write
@@ -36,6 +42,7 @@ jobs:
3642
with:
3743
context: .
3844
push: true
45+
platforms: ${{ matrix.platforms }}
3946
tags: ${{ steps.meta.outputs.tags }}
4047
labels: ${{ steps.meta.outputs.labels }}
4148
- name: Generate artifact attestation

.github/workflows/release_build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
with:
1717
fetch-depth: 0 # See: https://goreleaser.com/ci/actions/
1818

19-
- name: Set up Go 1.22.4
19+
- name: Set up Go 1.23
2020
uses: actions/setup-go@v2
2121
with:
22-
go-version: 1.22
22+
go-version: 1.23
2323
id: go
2424

2525
- name: Run GoReleaser

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM golang:1.23-alpine3.20 AS builder
1+
FROM --platform=$BUILDPLATFORM golang:1.23-alpine3.20 AS builder
2+
ARG TARGETOS TARGETARCH
23

34
RUN mkdir /app && mkdir -p /usr/local/src/smolgit
45
WORKDIR /usr/local/src/smolgit
@@ -7,7 +8,7 @@ ADD ./go.mod ./go.sum ./
78
RUN go mod download
89
ADD . ./
910

10-
RUN go build -v -o /build/smolgit
11+
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -v -o /build/smolgit
1112

1213
FROM alpine/git:2.45.2 AS runner
1314

0 commit comments

Comments
 (0)