Skip to content

Commit e5c8041

Browse files
committed
chore: #34 Move to multi-arch docker build
Signed-off-by: Laurent Broudoux <[email protected]>
1 parent 9a3ee9a commit e5c8041

File tree

2 files changed

+47
-9
lines changed

2 files changed

+47
-9
lines changed

.github/workflows/build-verify.yml

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
name: build-verify-package
2-
on: [push]
2+
on:
3+
push:
4+
paths-ignore:
5+
#- '.github/**'
6+
- '.gitignore'
7+
- 'LICENSE'
8+
- 'README*'
9+
pull_request:
10+
paths-ignore:
11+
- '.github/**'
12+
- '.gitignore'
13+
- 'LICENSE'
14+
- 'README*'
15+
316
jobs:
417
build-verify-package:
518
runs-on: ubuntu-latest
@@ -26,13 +39,28 @@ jobs:
2639
echo "IMAGE_TAG=$GITHUB_REF_NAME" >> "$GITHUB_ENV"
2740
fi
2841
29-
- name: Package container image for cli
30-
if: github.repository_owner == 'microcks'
31-
run: |
32-
docker build -f build/Dockerfile -t quay.io/microcks/microcks-cli:$IMAGE_TAG .
42+
- name: Set up QEMU
43+
if: github.repository_owner == 'microcks' && env.PACKAGE_IMAGE == 'true'
44+
uses: docker/setup-qemu-action@v2
45+
46+
- name: Set up Docker Buildx
47+
if: github.repository_owner == 'microcks' && env.PACKAGE_IMAGE == 'true'
48+
uses: docker/setup-buildx-action@v2
3349

34-
- name: Login and push to Quay.io Registry
35-
if: github.repository_owner == 'microcks'
50+
- name: Login to Quay.io Registry and setup multi-arch builder
51+
if: github.repository_owner == 'microcks' && env.PACKAGE_IMAGE == 'true'
3652
run: |
3753
echo ${{ secrets.QUAY_PASSWORD }} | docker login -u ${{ secrets.QUAY_USERNAME }} --password-stdin quay.io
38-
docker push quay.io/microcks/microcks-cli:$IMAGE_TAG
54+
BUILDER=buildx-multi-arch
55+
docker buildx inspect $BUILDER || docker buildx create --name=$BUILDER --driver=docker-container --driver-opt=network=host
56+
57+
- name: Build and push container image for cli
58+
if: github.repository_owner == 'microcks' && env.PACKAGE_IMAGE == 'true'
59+
run: |
60+
docker buildx build --push \
61+
--platform=linux/amd64,linux/arm64 \
62+
--builder=buildx-multi-arch \
63+
--provenance=false \
64+
--build-arg TAG=$IMAGE_TAG \
65+
--file build/Dockerfile \
66+
--tag=quay.io/microcks/microcks-cli:$IMAGE_TAG .

build/Dockerfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# Build binary
2+
FROM --platform=$BUILDPLATFORM golang:1.17.1-alpine AS build-env
3+
ADD . /app
4+
WORKDIR /app
5+
ARG TARGETOS
6+
ARG TARGETARCH
7+
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
8+
go build -ldflags="-s -w" -o microcks-cli github.com/microcks/microcks-cli
9+
10+
# Build image
111
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.2-750.1696515534
212

313
MAINTAINER Laurent Broudoux <[email protected]>
@@ -7,7 +17,7 @@ ENV CLI=/usr/local/bin/microcks-cli \
717
USER_NAME=microcks-cli
818

919
# install cli binary
10-
COPY /build/_output/microcks-cli-linux-amd64 ${CLI}
20+
COPY --from=build-env /app/microcks-cli ${CLI}
1121

1222
COPY build/bin /usr/local/bin
1323
RUN /usr/local/bin/user_setup

0 commit comments

Comments
 (0)