Skip to content

Commit d927a1e

Browse files
committed
Publish amd64/arm64 images to GHCR
1 parent a266bd5 commit d927a1e

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

.github/workflows/release.yml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,44 @@ jobs:
2121
cd config/release
2222
kustomize edit set image fluxcd/source-controller=fluxcd/source-controller:${{ steps.get_version.outputs.VERSION }}
2323
kustomize build . > source-controller.yaml
24-
- name: Push image
25-
uses: docker/build-push-action@v1
24+
- name: Setup QEMU
25+
uses: docker/setup-qemu-action@master
2626
with:
27-
username: ${{ secrets.DOCKER_FLUXCD_USER }}
27+
platforms: all
28+
- name: Setup Docker Buildx
29+
id: buildx
30+
uses: docker/setup-buildx-action@master
31+
- name: Login to GitHub Container Registry
32+
uses: docker/login-action@v1
33+
with:
34+
registry: ghcr.io
35+
username: fluxcdbot
36+
password: ${{ secrets.GHCR_TOKEN }}
37+
- name: Login to Docker Hub
38+
uses: docker/login-action@v1
39+
with:
40+
username: fluxcdbot
2841
password: ${{ secrets.DOCKER_FLUXCD_PASSWORD }}
29-
repository: fluxcd/source-controller
30-
tag_with_ref: true
42+
- name: Publish amd64 image
43+
uses: docker/build-push-action@v2-build-push
44+
with:
45+
push: ${{ github.event_name != 'pull_request' }}
46+
builder: ${{ steps.buildx.outputs.name }}
47+
context: .
48+
file: ./Dockerfile
49+
platforms: linux/amd64
50+
tags: |
51+
ghcr.io/fluxcd/source-controller:${{ steps.get_version.outputs.VERSION }}
52+
docker.io/fluxcd/source-controller:${{ steps.get_version.outputs.VERSION }}
53+
- name: Publish arm64 image
54+
uses: docker/build-push-action@v2-build-push
55+
with:
56+
push: ${{ github.event_name != 'pull_request' }}
57+
builder: ${{ steps.buildx.outputs.name }}
58+
context: .
59+
file: ./Dockerfile
60+
platforms: linux/arm64
61+
tags: ghcr.io/fluxcd/source-controller-arm64:${{ steps.get_version.outputs.VERSION }}
3162
- name: Create release
3263
id: create_release
3364
uses: actions/create-release@latest

Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
FROM golang:1.14 as builder
1+
# Docker buildkit multi-arch build requires golang alpine
2+
FROM golang:1.14-alpine as builder
23

34
WORKDIR /workspace
45

@@ -18,11 +19,14 @@ COPY controllers/ controllers/
1819
COPY pkg/ pkg/
1920
COPY internal/ internal/
2021

21-
# build
22-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o source-controller main.go
22+
# build without specifing the arch
23+
RUN CGO_ENABLED=0 go build -a -o source-controller main.go
2324

2425
FROM alpine:3.12
2526

27+
# link repo to the GitHub Container Registry image
28+
LABEL org.opencontainers.image.source="https://github.com/fluxcd/source-controller"
29+
2630
RUN apk add --no-cache ca-certificates tini
2731

2832
COPY --from=builder /workspace/source-controller /usr/local/bin/

0 commit comments

Comments
 (0)