diff --git a/.gitea/install_latest_buildah.sh b/.gitea/install_latest_buildah.sh new file mode 100644 index 0000000..b779f78 --- /dev/null +++ b/.gitea/install_latest_buildah.sh @@ -0,0 +1,3 @@ +sudo apt-key add - < Release.key +sudo apt-get update -qq +sudo apt-get -qq -y install buildah diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..4d15b2d --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,64 @@ +name: Multiarch build +on: + push: + pull_request: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' # every day at midnight + +env: + PROJECT_DIR: spring-petclinic + MVN_REPO_DIR: ~/.m2/repository + IMAGE_TAG: latest + +jobs: + build-multiarch-scratch: + name: Build multi-architecture image from scratch + env: + IMAGE_NAME: spring-petclinic-multiarch + runs-on: ubuntu-22.04 + + steps: + + # Checkout buildah action github repository + - name: Checkout Buildah action + uses: actions/checkout@v4 + with: + path: "buildah-build" + + - name: Install latest buildah + run: | + bash buildah-build/.gitea/install_latest_buildah.sh + + - name: Install qemu dependency + run: | + sudo apt-get update + sudo apt-get install -y qemu-user-static + + - name: Build Image + id: build_image_multiarch + uses: redhat-actions/buildah-build@v2 + with: + image: ${{ env.IMAGE_NAME }} + tags: ${{ env.IMAGE_TAG }} + base-image: 'registry.access.redhat.com/ubi9-minimal:9.5' + archs: amd64, i386, ppc64le + # To avoid hardcoding a particular version of the binary. + containerfiles: | + ./Containerfile + port: 8080 + workdir: "." + + - name: Echo Outputs + run: | + echo "Image: ${{ steps.build_image_multiarch.outputs.image }}" + echo "Tags: ${{ steps.build_image_multiarch.outputs.tags }}" + echo "Tagged Image: ${{ steps.build_image_multiarch.outputs.image-with-tag }}" + + - name: Check images created + run: buildah images | grep '${{ env.IMAGE_NAME }}' + + - name: Check manifest + run: | + set -x + buildah manifest inspect ${{ steps.build_image_multiarch.outputs.image }}:${{ env.IMAGE_TAG }} \ No newline at end of file diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..0c16253 --- /dev/null +++ b/Containerfile @@ -0,0 +1,5 @@ +FROM registry.access.redhat.com/ubi9-minimal:9.5 + +RUN yum install -y kubectl \ + && yum clean all \ + && rm -rf /var/cache/yum \ No newline at end of file