Skip to content

Commit f40c100

Browse files
authored
Add multi-platform build support (#8)
1 parent 923f247 commit f40c100

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

.github/workflows/build-docker-image.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ on:
66
- '*'
77

88
jobs:
9-
docker:
9+
build-and-push-image:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
packages: write
1114
steps:
1215
- name: Checkout Repository
1316
uses: actions/checkout@v3
@@ -34,11 +37,12 @@ jobs:
3437
password: ${{ secrets.GITHUB_TOKEN }}
3538

3639
- name: Build and Push Docker Image
37-
uses: docker/build-push-action@v3
40+
uses: docker/build-push-action@v6
3841
env:
3942
DOCKER_BUILDKIT: 1
4043
with:
4144
context: .
45+
platforms: linux/amd64,linux/arm64
4246
file: docker/Dockerfile
4347
push: true
4448
tags: ${{ steps.meta.outputs.tags }}

docker/Dockerfile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
FROM golang:1.25 AS builder
1+
FROM --platform=$BUILDPLATFORM golang:1.25 AS builder
2+
ARG TARGETOS
3+
ARG TARGETARCH
24
WORKDIR /opt/keepup/
3-
COPY go.mod ./
4-
COPY go.sum .
5-
COPY src ./src
5+
COPY go.mod go.sum ./
6+
COPY src ./src/
67
RUN go mod download
7-
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o helm-scraper src/main.go
8+
RUN CGO_ENABLED=0 \
9+
GOOS=$TARGETOS \
10+
GOARCH=$TARGETARCH \
11+
go build -a -installsuffix cgo -o helm-scraper src/main.go
812

9-
FROM alpine:latest
13+
FROM alpine:3
1014
WORKDIR /opt/keepup/
1115
COPY --from=builder /opt/keepup/helm-scraper .
1216
RUN chmod +x /opt/keepup/helm-scraper
13-
1417
ENTRYPOINT ["/opt/keepup/helm-scraper"]

0 commit comments

Comments
 (0)