Skip to content

Commit 4e41ea8

Browse files
committed
Push linux/arm64 image to GHCR
1 parent 2c0c76c commit 4e41ea8

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

.github/workflows/release.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,28 @@ jobs:
2121
cd config/release
2222
kustomize edit set image fluxcd/notification-controller=fluxcd/notification-controller:${{ steps.get_version.outputs.VERSION }}
2323
kustomize build . > notification-controller.yaml
24-
- name: Push image Docker Hub
25-
uses: docker/build-push-action@v1
26-
with:
27-
username: ${{ secrets.DOCKER_FLUXCD_USER }}
28-
password: ${{ secrets.DOCKER_FLUXCD_PASSWORD }}
29-
repository: fluxcd/notification-controller
30-
tag_with_ref: true
31-
- name: Push image to GHCR
32-
uses: docker/build-push-action@v1
33-
with:
34-
username: fluxcdbot
35-
password: ${{ secrets.GHCR_TOKEN }}
36-
repository: ghcr.io/fluxcd/notification-controller
37-
tag_with_ref: true
24+
- uses: crazy-max/ghaction-docker-buildx@v1
25+
- name: Publish image
26+
run: |
27+
echo "${{ secrets.DOCKER_FLUXCD_PASSWORD }}" | docker login --username fluxcdbot --password-stdin
28+
echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io --username fluxcdbot --password-stdin
29+
30+
docker buildx build --platform "linux/amd64" \
31+
--output "type=image,push=true" \
32+
--build-arg "REVISION=${GITHUB_SHA}" \
33+
--build-arg "VERSION=${{ steps.get_version.outputs.VERSION }}" \
34+
--build-arg "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
35+
--tag "ghcr.io/fluxcd/notification-controller:${{ steps.get_version.outputs.VERSION }}" \
36+
--tag "docker.io/fluxcd/notification-controller:${{ steps.get_version.outputs.VERSION }}" \
37+
--file Dockerfile .
38+
39+
docker buildx build --platform "linux/arm64" \
40+
--output "type=image,push=true" \
41+
--build-arg "REVISION=${GITHUB_SHA}" \
42+
--build-arg "VERSION=${{ steps.get_version.outputs.VERSION }}" \
43+
--build-arg "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
44+
--tag "ghcr.io/fluxcd/notification-controller-arm64:${{ steps.get_version.outputs.VERSION }}" \
45+
--file Dockerfile .
3846
- name: Create release
3947
id: create_release
4048
uses: actions/create-release@latest

Dockerfile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.14 as builder
1+
FROM golang:1.14-alpine as builder
22

33
WORKDIR /workspace
44

@@ -16,10 +16,22 @@ COPY controllers/ controllers/
1616
COPY internal/ internal/
1717

1818
# build
19-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o notification-controller main.go
19+
RUN CGO_ENABLED=0 go build -a -o notification-controller main.go
2020

2121
FROM alpine:3.12
2222

23+
ARG BUILD_DATE
24+
ARG VERSION
25+
ARG REVISION
26+
27+
LABEL org.opencontainers.image.created=$BUILD_DATE \
28+
org.opencontainers.image.version=$VERSION \
29+
org.opencontainers.image.revision=$REVISION \
30+
org.opencontainers.image.licenses="Apache-2.0" \
31+
org.opencontainers.image.source="https://github.com/fluxcd/notification-controller" \
32+
org.opencontainers.image.documentation="https://toolkit.fluxcd.io" \
33+
org.opencontainers.image.authors="Flux CD"
34+
2335
RUN apk add --no-cache ca-certificates tini
2436

2537
COPY --from=builder /workspace/notification-controller /usr/local/bin/

0 commit comments

Comments
 (0)