Skip to content

Commit

Permalink
Merge pull request #37 from snowdrop/issue-36
Browse files Browse the repository at this point in the history
Build multi-arch image
  • Loading branch information
cmoulliard authored Dec 4, 2023
2 parents 67d91bb + 254d513 commit 437e62a
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 30 deletions.
30 changes: 11 additions & 19 deletions .github/workflows/build-push-image-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,25 @@ on:
push:
branches:
- main

jobs:
build_push_image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install go 1.16
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Quay.io Hub
uses: docker/login-action@v1
- name: Build & push Docker image
uses: mr-smithers-excellent/docker-build-push@v6
with:
image: snowdrop/cert-manager-webhook-godaddy
addLatest: true
enableBuildKit: true
multiPlatform: true
platform: linux/amd64,linux/arm64
registry: quay.io
username: ${{ secrets.QUAY_ROBOT_USER }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}

- name: Build the container image
run: |
VERSION=$(git rev-parse --short HEAD 2>/dev/null)
docker build -t cert-manager-webhook-godaddy:${VERSION} -f Dockerfile .
TAG_ID=$(docker images -q cert-manager-webhook-godaddy:${VERSION})
docker tag ${TAG_ID} quay.io/snowdrop/cert-manager-webhook-godaddy:${VERSION}
docker tag ${TAG_ID} quay.io/snowdrop/cert-manager-webhook-godaddy:latest
docker push quay.io/snowdrop/cert-manager-webhook-godaddy:${VERSION}
docker push quay.io/snowdrop/cert-manager-webhook-godaddy:latest
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
36 changes: 26 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,37 @@ jobs:
echo "TAG_VERSION=${TAG_VERSION}" >> "${GITHUB_OUTPUT}"
- name: Login to Quay.io Hub
uses: docker/login-action@v1
# - name: Login to Quay.io Hub
# uses: docker/login-action@v1
# with:
# registry: quay.io
# username: ${{ secrets.QUAY_ROBOT_USER }}
# password: ${{ secrets.QUAY_ROBOT_TOKEN }}
#
# - name: Build the container image
# run: |
# NEW_VERSION="${{ steps.tag-chart.outputs.TAG_VERSION }}"
# docker build -t cert-manager-webhook-godaddy:${NEW_VERSION} -f Dockerfile .
#
# TAG_ID=$(docker images -q cert-manager-webhook-godaddy:${NEW_VERSION})
# docker tag ${TAG_ID} quay.io/snowdrop/cert-manager-webhook-godaddy:${NEW_VERSION}
# docker push quay.io/snowdrop/cert-manager-webhook-godaddy:${NEW_VERSION}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build & push Docker image
uses: mr-smithers-excellent/docker-build-push@v6
with:
image: snowdrop/cert-manager-webhook-godaddy
addLatest: true
enableBuildKit: true
multiPlatform: true
platform: linux/amd64,linux/arm64
registry: quay.io
username: ${{ secrets.QUAY_ROBOT_USER }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}

- name: Build the container image
run: |
NEW_VERSION="${{ steps.tag-chart.outputs.TAG_VERSION }}"
docker build -t cert-manager-webhook-godaddy:${NEW_VERSION} -f Dockerfile .
TAG_ID=$(docker images -q cert-manager-webhook-godaddy:${NEW_VERSION})
docker tag ${TAG_ID} quay.io/snowdrop/cert-manager-webhook-godaddy:${NEW_VERSION}
docker push quay.io/snowdrop/cert-manager-webhook-godaddy:${NEW_VERSION}

- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.5.0
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ WORKDIR /go/src/webhook-app
COPY . .
RUN --mount=type=cache,target=$HOME/go/pkg/mod go mod download

RUN CGO_ENABLED=0 go build -o /webhook-app -ldflags '-w -extldflags "-static"' .
ARG TARGETOS
ARG TARGETARCH
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /webhook-app -ldflags '-w -extldflags "-static"' .

FROM alpine:3

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Table of Contents
=================
* [Introduction](#introduction)
* [Paltform](#platform)
* [Installation](#installation)
* [Cert Manager](#cert-manager)
* [The Godaddy webhook](#the-godaddy-webhook)
Expand Down Expand Up @@ -30,6 +31,10 @@ This project supports the following versions of the certificate manager:

**Remark**: The Helm chart `AppVersion` like the image `version` are tagged according to the version used to release this project: v0.1.0, v0.2.0. When using the main branch, the Helm chart will install the latest image pushed on [quay.io](https://quay.io/repository/snowdrop/cert-manager-webhook-godaddy)

## Platform

The image built supports as Arch: am64 and arm64 since release `>= 0.2.0`

## Installation

### Cert Manager
Expand Down

0 comments on commit 437e62a

Please sign in to comment.