Skip to content

Commit

Permalink
Create multi-arch native image
Browse files Browse the repository at this point in the history
Fixes #80
  • Loading branch information
edeandrea committed Oct 17, 2022
1 parent c54419d commit 235947b
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 39 deletions.
37 changes: 6 additions & 31 deletions .github/workflows/build-push-container-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
- rest-villains
arch:
- amd64
# - arm64
- arm64
name: "Build Native images (${{ matrix.arch}}-${{ matrix.project }}-java${{ matrix.java }})"
steps:
- name: Calculate Branch (workflow_run event)
Expand Down Expand Up @@ -273,80 +273,66 @@ jobs:
name: "Push app images (${{ matrix.arch}}-${{ matrix.project }}-${{ matrix.kind }}java${{ matrix.java }})"
steps:
- name: Calculate Branch (workflow_run event)
if: ((matrix.arch == 'amd64') || (matrix.kind != 'native-')) && (github.event_name == 'workflow_run')
if: github.event_name == 'workflow_run'
run: |
echo "REF=${{ github.event.workflow_run.head_commit.id }}" >> $GITHUB_ENV
echo "BRANCH=${{ github.event.workflow_run.head_branch }}" >> $GITHUB_ENV
- name: Calculate Branch (workflow_dispatch event)
if: ((matrix.arch == 'amd64') || (matrix.kind != 'native-')) && (github.event_name == 'workflow_dispatch')
if: github.event_name == 'workflow_dispatch'
run: |
echo "REF=${{ github.sha }}" >> $GITHUB_ENV
echo "BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Checkout from ${{ env.REF }}
if: (matrix.arch == 'amd64') || (matrix.kind != 'native-')
uses: actions/checkout@v3
with:
ref: ${{ env.REF }}

- name: Setup Java
if: (matrix.arch == 'amd64') || (matrix.kind != 'native-')
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: temurin
cache: maven

- name: Create env vars
if: (matrix.arch == 'amd64') || (matrix.kind != 'native-')
working-directory: ${{ matrix.project }}
run: |
echo "QUARKUS_VERSION=$(./mvnw help:evaluate -Dexpression=quarkus.platform.version -q -DforceStdout)" >> $GITHUB_ENV &&
echo "APP_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
- name: Create container tags (main branch)
if: (env.BRANCH == 'main') && ((matrix.arch == 'amd64') || (matrix.kind != 'native-'))
if: env.BRANCH == 'main'
working-directory: ${{ matrix.project }}
run: |
echo "CONTAINER_TAG=${{ env.APP_VERSION }}-quarkus-${{ env.QUARKUS_VERSION }}-${{ matrix.kind }}java${{ matrix.java }}" >> $GITHUB_ENV &&
echo "ADDITIONAL_TAG=${{ matrix.kind }}java${{ matrix.java }}-${{ env.LATEST_IMAGE_TAG }}" >> $GITHUB_ENV
- name: Create container tags (other branch)
if: (env.BRANCH != 'main') && ((matrix.arch == 'amd64') || (matrix.kind != 'native-'))
if: env.BRANCH != 'main'
working-directory: ${{ matrix.project }}
run: |
echo "CONTAINER_TAG=${{ env.APP_VERSION }}-quarkus-${{ env.QUARKUS_VERSION }}-${{ matrix.kind }}java${{ matrix.java }}" >> $GITHUB_ENV &&
echo "ADDITIONAL_TAG=${{ matrix.kind }}java${{ matrix.java }}-${{ env.LATEST_IMAGE_TAG }}-${{ env.BRANCH }}" >> $GITHUB_ENV
- name: Get saved images (${{ matrix.project }}-${{ matrix.kind }}java${{ matrix.java }}-${{ matrix.arch }})
if: (matrix.arch == 'amd64') || (matrix.kind != 'native-')
uses: ishworkh/docker-image-artifact-download@v1
with:
image: "${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.CONTAINER_TAG }}-${{ matrix.arch }}"

- name: Login to quay
if: (matrix.arch == 'amd64') || (matrix.kind != 'native-')
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_REPO_USERNAME }}
password: ${{ secrets.QUAY_REPO_TOKEN }}

- name: Tag image
if: (matrix.arch == 'amd64') || (matrix.kind != 'native-')
working-directory: ${{ matrix.project }}
run: "docker tag ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.CONTAINER_TAG }}-${{ matrix.arch }} ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.ADDITIONAL_TAG }}-${{ matrix.arch }}"

- name: Tag native image (amd64)
if: (matrix.arch == 'amd64') && (matrix.kind == 'native-')
working-directory: ${{ matrix.project }}
run: |
docker tag ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.CONTAINER_TAG }}-${{ matrix.arch }} ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.ADDITIONAL_TAG }}
docker tag ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.CONTAINER_TAG }}-${{ matrix.arch }} ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.CONTAINER_TAG }}
- name: Push images
if: (matrix.arch == 'amd64') || (matrix.kind != 'native-')
working-directory: ${{ matrix.project }}
run: "docker push -a ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}"

Expand Down Expand Up @@ -432,7 +418,7 @@ jobs:
- '17'
kind:
- ""
# - "native-"
- "native-"
project:
- event-statistics
- rest-fights
Expand Down Expand Up @@ -503,17 +489,6 @@ jobs:
-a ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.ADDITIONAL_TAG }}-arm64
docker manifest push ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.ADDITIONAL_TAG }}
# - name: Create and push single-arch native manifests
# if: matrix.kind == 'native-'
# shell: bash
# run: |
# docker manifest create ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.CONTAINER_TAG }} \
# -a ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.CONTAINER_TAG }}-amd64
# docker manifest push ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.CONTAINER_TAG }}
# docker manifest create ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.ADDITIONAL_TAG }} \
# -a ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.ADDITIONAL_TAG }}-amd64
# docker manifest push ${{ env.IMAGE_BASE_NAME }}/${{ matrix.project }}:${{ env.ADDITIONAL_TAG }}

create-ui-multiarch-manifests:
if: ((github.event_name == 'workflow_dispatch') || ((github.event_name == 'workflow_run') && ((github.event.workflow_run.event == 'push') || (github.event.workflow_run.event == 'workflow_dispatch')) && (github.event.workflow_run.conclusion == 'success'))) && ((github.repository == 'quarkusio/quarkus-super-heroes') && ((github.event.workflow_run.head_branch == 'main') || (github.event.workflow_run.head_branch == 'rhbq-2.7')))
needs: push-ui-images
Expand Down
2 changes: 1 addition & 1 deletion event-statistics/src/main/docker/Dockerfile.native
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# docker run -i --rm -p 8085:8085 quarkus/event-statistics
#
###
FROM quay.io/quarkus/quarkus-micro-image:1.0
FROM quay.io/quarkus/quarkus-micro-image:2.0
WORKDIR /work/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# docker run -i --rm -p 8085:8085 quarkus/event-statistics
#
###
FROM quay.io/quarkus/quarkus-distroless-image:1.0
FROM quay.io/quarkus/quarkus-distroless-image:2.0
COPY target/*-runner /application

EXPOSE 8085
Expand Down
2 changes: 1 addition & 1 deletion rest-fights/src/main/docker/Dockerfile.native
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# docker run -i --rm -p 8082:8082 quarkus/rest-fights
#
###
FROM quay.io/quarkus/quarkus-micro-image:1.0
FROM quay.io/quarkus/quarkus-micro-image:2.0
WORKDIR /work/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
Expand Down
2 changes: 1 addition & 1 deletion rest-fights/src/main/docker/Dockerfile.native-distroless
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# docker run -i --rm -p 8082:8082 quarkus/rest-fights
#
###
FROM quay.io/quarkus/quarkus-distroless-image:1.0
FROM quay.io/quarkus/quarkus-distroless-image:2.0
COPY target/*-runner /application

EXPOSE 8082
Expand Down
2 changes: 1 addition & 1 deletion rest-heroes/src/main/docker/Dockerfile.native
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# docker run -i --rm -p 8083:8083 quarkus/rest-heroes
#
###
FROM quay.io/quarkus/quarkus-micro-image:1.0
FROM quay.io/quarkus/quarkus-micro-image:2.0
WORKDIR /work/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
Expand Down
2 changes: 1 addition & 1 deletion rest-heroes/src/main/docker/Dockerfile.native-distroless
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# docker run -i --rm -p 8083:8083 quarkus/rest-heroes
#
###
FROM quay.io/quarkus/quarkus-distroless-image:1.0
FROM quay.io/quarkus/quarkus-distroless-image:2.0
COPY target/*-runner /application

EXPOSE 8083
Expand Down
2 changes: 1 addition & 1 deletion rest-villains/src/main/docker/Dockerfile.native
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# docker run -i --rm -p 8084:8084 quarkus/rest-villains
#
###
FROM quay.io/quarkus/quarkus-micro-image:1.0
FROM quay.io/quarkus/quarkus-micro-image:2.0
WORKDIR /work/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
Expand Down
2 changes: 1 addition & 1 deletion rest-villains/src/main/docker/Dockerfile.native-distroless
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# docker run -i --rm -p 8084:8084 quarkus/rest-villains
#
###
FROM quay.io/quarkus/quarkus-distroless-image:1.0
FROM quay.io/quarkus/quarkus-distroless-image:2.0
COPY target/*-runner /application

EXPOSE 8084
Expand Down

0 comments on commit 235947b

Please sign in to comment.