Skip to content

Commit

Permalink
Switching to docker buildx to build multi arch image
Browse files Browse the repository at this point in the history
Signed-off-by: cmoulliard <cmoulliard@redhat.com>
  • Loading branch information
cmoulliard committed Dec 4, 2023
1 parent 67d91bb commit 8651ae1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/build-push-image-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@ on:
branches: [ main ]
push:
branches:
- main
#- main
- 'issue-*'
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: Install go 1.16
# uses: actions/setup-go@v2
# with:
# go-version: 1.16

- name: Login to Quay.io Hub
uses: docker/login-action@v1
Expand All @@ -27,7 +31,7 @@ jobs:
- 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 .
docker buildx build --platform linux/amd64,linux/arm64 -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}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
with:
fetch-depth: 0

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

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
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

0 comments on commit 8651ae1

Please sign in to comment.