From 443a91cbeea41f986362f0a8b52d7d93efdf4306 Mon Sep 17 00:00:00 2001 From: Aleksander Cynarski Date: Sat, 17 May 2025 11:14:16 +0200 Subject: [PATCH] Initial commit Signed-off-by: Aleksander Cynarski --- .gitea/install_latest_buildah.sh | 3 + .gitea/workflows/build.yml | 94 ++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 .gitea/install_latest_buildah.sh create mode 100644 .gitea/workflows/build.yml 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..53194b9 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,94 @@ +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 + strategy: + fail-fast: false + matrix: + install_latest: [ true, false ] + + steps: + + # Checkout buildah action github repository + - name: Checkout Buildah action + uses: actions/checkout@v4 + with: + path: "buildah-build" + + - name: Install latest buildah + if: matrix.install_latest + 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 + + # Checkout spring-petclinic github repository + - name: Checkout spring-petclinic project + uses: actions/checkout@v4 + with: + repository: "spring-projects/spring-petclinic" + path: ${{ env.PROJECT_DIR }} + + # Setup java. + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + cache: 'maven' + + # Run maven to build the project + - name: Maven + working-directory: ${{ env.PROJECT_DIR }} + run: | + mvn package -ntp -B + + - name: Build Image + id: build_image_multiarch + uses: https://github.com/marketplace/actions/buildah-build@v2 + with: + image: ${{ env.IMAGE_NAME }} + tags: ${{ env.IMAGE_TAG }} + base-image: 'registry.access.redhat.com/openjdk/openjdk-11-rhel7' + archs: amd64, i386, ppc64le + # To avoid hardcoding a particular version of the binary. + content: | + ./spring-petclinic/target/spring-petclinic-*.jar + entrypoint: | + java + -jar + spring-petclinic-*.jar + 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