diff --git a/.github/workflows/build-images.yml b/.github/workflows/build-images.yml index 7d0a721f..9df1c32e 100644 --- a/.github/workflows/build-images.yml +++ b/.github/workflows/build-images.yml @@ -1,61 +1,102 @@ -name: Continuous Integration Build +name: Build on: pull_request: branches: - main push: - branches: - - main paths-ignore: - '.build/**' + deployment: + schedule: + - cron: '0 0 * * 0' + workflow_dispatch: jobs: build-images: - name: Build images + name: Build and Push images runs-on: ubuntu-latest strategy: fail-fast: false matrix: include: - - name: "base images" - modules: "quarkus-distroless-base-image,quarkus-micro-base-image" - args: "" - - name: "s2i images" - modules: "quarkus-binary-s2i,quarkus-native-s2i" - args: "" - - name: "mandrel builder images" - modules: "quarkus-mandrel-builder-image" - args: "" - - name: "mandrel builder images 21 and 22.0" - modules: "quarkus-mandrel-builder-image" - args: "-Polder-mandrel" - - name: "graalvm ce builder images" - modules: "quarkus-graalvm-builder-image" - args: "" - - name: "graalvm ce builder images 21 and 22.0" - modules: "quarkus-graalvm-builder-image" - args: "-Polder-graalvm" + # Distroless image + - modules: quarkus-distroless-base-image + + # Default UBI base image + - modules: quarkus-micro-base-image + ubi: default + - modules: quarkus-binary-s2i,quarkus-native-s2i + ubi: default + - modules: quarkus-mandrel-builder-image + ubi: default + - modules: quarkus-mandrel-builder-image + args: -Polder-mandrel + ubi: default + - modules: quarkus-graalvm-builder-image + ubi: default + - modules: quarkus-graalvm-builder-image + args: -Polder-graalvm + ubi: default + + # UBI 9 base image + - modules: quarkus-micro-base-image + ubi: "9.1" + - modules: quarkus-binary-s2i,quarkus-native-s2i + ubi: "9.1" + - modules: quarkus-mandrel-builder-image + ubi: "9.1" + - modules: quarkus-mandrel-builder-image + args: -Polder-mandrel + ubi: "9.1" + - modules: quarkus-graalvm-builder-image + ubi: "9.1" + - modules: quarkus-graalvm-builder-image + args: -Polder-graalvm + ubi: "9.1" steps: - - run: | + - id: prepare + run: | # Re-claim some disk space sudo swapoff -a sudo rm -f /swapfile sudo apt-get clean - docker rmi $(docker image ls -aq) + docker image ls -aq | xargs -r docker rmi df -h - - uses: actions/checkout@v1 + + # Set up UBI params + if [ -n "${{ matrix.ubi }}" ] && [ "${{ matrix.ubi }}" != "default" ]; then + IFS='.' read -r ubi_major ubi_minor <<< "${{ matrix.ubi }}" + echo "ubi-args=-Dubi.tag=ubi${ubi_major} -Dubi.rel.major=${ubi_major} -Dubi.rel.minor=${ubi_minor}" >> "$GITHUB_OUTPUT" + else + echo "ubi-args=" >> "$GITHUB_OUTPUT" + fi + + # Should publish images? + publish_types=(deployment schedule workflow_dispatch) + inarray=$(echo ${publish_types[@]} | grep -o "${{ github.event_name }}" | wc -w) + if (( inarray )) || \ + [ "${{ github.event_name }}" == "push" ] && \ + [ "${{ github.repository }}" == 'quarkusio/quarkus-images' ] && \ + [ "${{ github.ref }}" == 'main' ]; then + echo "publish=true" >> "$GITHUB_OUTPUT" + echo 'publish-args=-Ppush' >> "$GITHUB_OUTPUT + else + echo "publish=false" >> "$GITHUB_OUTPUT" + echo 'publish-args=' >> "$GITHUB_OUTPUT + fi + - uses: actions/checkout@v3 - uses: actions/setup-java@v3 with: distribution: 'temurin' java-version: '17' - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 with: install: true - name: Inspect builder @@ -65,8 +106,24 @@ jobs: echo "Status: ${{ steps.buildx.outputs.status }}" echo "Flags: ${{ steps.buildx.outputs.flags }}" echo "Platforms: ${{ steps.buildx.outputs.platforms }}" - - name: Build ${{ matrix.name }} - run: mvn install --projects ${{ matrix.modules }} --also-make -DskipTests ${{ matrix.args }} + + - name: Login to GitHub Container Registry + if: ${{ steps.prepare.outputs.publish == 'true' }} + uses: docker/login-action@v2 + with: + registry: quay.io + username: ${{ secrets.QUAY_USER }} + password: ${{ secrets.QUAY_TOKEN }} + + - name: Build ${{ matrix.name }} on ${{ matrix.ubi }} + run: + mvn install + --projects ${{ matrix.modules }} + --also-make + -DskipTests + ${{ matrix.args }} + ${{ steps.prepare.outputs.ubi-args }} + ${{ steps.prepare.outputs.publish-args }} - name: Print ${{ matrix.name}} if: always() run: docker images \ No newline at end of file diff --git a/.github/workflows/push-images.yml b/.github/workflows/push-images.yml deleted file mode 100644 index d87b736f..00000000 --- a/.github/workflows/push-images.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: Push Images to Quay -on: - deployment: - schedule: - - cron: '0 0 * * 0' - workflow_dispatch: - -jobs: - - build-images: - name: Build and Push images - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - name: "base images" - modules: "quarkus-distroless-base-image,quarkus-micro-base-image" - args: "" - - name: "s2i images" - modules: "quarkus-binary-s2i,quarkus-native-s2i" - args: "" - - name: "mandrel builder images" - modules: "quarkus-mandrel-builder-image" - args: "" - - name: "mandrel builder images 21 and 22.0" - modules: "quarkus-mandrel-builder-image" - args: "-Polder-mandrel" - - name: "graalvm ce builder images" - modules: "quarkus-graalvm-builder-image" - args: "" - - name: "graalvm ce builder images 21 and 22.0" - modules: "quarkus-graalvm-builder-image" - args: "-Polder-graalvm" - steps: - - run: | - # Re-claim some disk space - sudo swapoff -a - sudo rm -f /swapfile - sudo apt-get clean - docker rmi $(docker image ls -aq) - df -h - - uses: actions/checkout@v1 - - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v1 - with: - install: true - - name: Inspect builder - run: | - echo "Name: ${{ steps.buildx.outputs.name }}" - echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" - echo "Status: ${{ steps.buildx.outputs.status }}" - echo "Flags: ${{ steps.buildx.outputs.flags }}" - echo "Platforms: ${{ steps.buildx.outputs.platforms }}" - - name: Login to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: quay.io - username: ${{ secrets.QUAY_USER }} - password: ${{ secrets.QUAY_TOKEN }} - - name: Build images - run: mvn install --projects ${{ matrix.modules }} --also-make -DskipTests -Ppush ${{ matrix.args }} - - name: Print ${{ matrix.name}} - if: always() - run: | - df -h - docker images \ No newline at end of file diff --git a/pom.xml b/pom.xml index 8666f940..9afaffdd 100644 --- a/pom.xml +++ b/pom.xml @@ -33,10 +33,17 @@ 17 17 - - registry.access.redhat.com/ubi8/ubi-minimal:8.7 - - registry.access.redhat.com/ubi8-micro:8.7 + + + 8 + 7 + + + ubi + ${ubi.rel.major}.${ubi.rel.minor} + + registry.access.redhat.com/ubi${ubi.rel.major}/ubi-minimal:${ubi.release} + registry.access.redhat.com/ubi${ubi.rel.major}-micro:${ubi.release} false diff --git a/quarkus-binary-s2i/pom.xml b/quarkus-binary-s2i/pom.xml index f3157822..d39d0008 100644 --- a/quarkus-binary-s2i/pom.xml +++ b/quarkus-binary-s2i/pom.xml @@ -33,7 +33,7 @@ --dockerfile-dir=${project.basedir}/target/docker --ubi-minimal=${ubi-min.base} - --out=quay.io/quarkus/ubi-quarkus-native-binary-s2i:2.0 + --out=quay.io/quarkus/${ubi.tag}-quarkus-native-binary-s2i:2.0 --basedir=${project.basedir} --dry-run=${jdock.dry-run} diff --git a/quarkus-graalvm-builder-image/pom.xml b/quarkus-graalvm-builder-image/pom.xml index 4fe5491b..8959ee59 100644 --- a/quarkus-graalvm-builder-image/pom.xml +++ b/quarkus-graalvm-builder-image/pom.xml @@ -34,7 +34,7 @@ --dockerfile-dir=${project.basedir}/target/docker --ubi-minimal=${ubi-min.base} - --out=quay.io/quarkus/ubi-quarkus-graalvmce-builder-image + --out=quay.io/quarkus/${ubi.tag}-quarkus-graalvmce-builder-image --in=${images.file} --dry-run=${jdock.dry-run} diff --git a/quarkus-mandrel-builder-image/pom.xml b/quarkus-mandrel-builder-image/pom.xml index 04fad72a..c75771a4 100644 --- a/quarkus-mandrel-builder-image/pom.xml +++ b/quarkus-mandrel-builder-image/pom.xml @@ -34,7 +34,7 @@ --dockerfile-dir=${project.basedir}/target/docker --ubi-minimal=${ubi-min.base} - --out=quay.io/quarkus/ubi-quarkus-mandrel-builder-image + --out=quay.io/quarkus/${ubi.tag}-quarkus-mandrel-builder-image --in=${images.file} --dry-run=${jdock.dry-run} diff --git a/quarkus-micro-base-image/pom.xml b/quarkus-micro-base-image/pom.xml index 0d94940f..30e4259c 100644 --- a/quarkus-micro-base-image/pom.xml +++ b/quarkus-micro-base-image/pom.xml @@ -34,6 +34,7 @@ --dockerfile-dir=${pom.basedir}/target/docker --ubi-minimal=${ubi-min.base} --ubi-micro=${ubi-micro.base} + --ubi-tag=${ubi.tag} --out=quay.io/quarkus/quarkus-micro-image:2.0 --dry-run=${jdock.dry-run} diff --git a/quarkus-micro-base-image/src/main/java/io/quarkus/images/Build.java b/quarkus-micro-base-image/src/main/java/io/quarkus/images/Build.java index 99c929c0..b7f8be85 100644 --- a/quarkus-micro-base-image/src/main/java/io/quarkus/images/Build.java +++ b/quarkus-micro-base-image/src/main/java/io/quarkus/images/Build.java @@ -18,6 +18,9 @@ public class Build implements Callable { @CommandLine.Option(names = { "--ubi-micro" }, description = "The UBI Micro base image") private String micro; + @CommandLine.Option(names = { "--ubi-tag" }, description = "The tag to add to the output image tag") + private String ubiTag; + @CommandLine.Option(names = { "--out" }, description = "The output image") private String output; @@ -31,7 +34,7 @@ public class Build implements Callable { @Override public Integer call() throws Exception { JDock.setDockerFileDir(dockerFileDir); - QuarkusMicro.define(minimal, micro, output) + QuarkusMicro.define(minimal, micro, output, ubiTag) .buildLocalImages(dryRun); return 0; diff --git a/quarkus-micro-base-image/src/main/java/io/quarkus/images/Push.java b/quarkus-micro-base-image/src/main/java/io/quarkus/images/Push.java index 99acb97f..af73c637 100644 --- a/quarkus-micro-base-image/src/main/java/io/quarkus/images/Push.java +++ b/quarkus-micro-base-image/src/main/java/io/quarkus/images/Push.java @@ -18,6 +18,9 @@ public class Push implements Callable { @CommandLine.Option(names = { "--ubi-micro" }, description = "The UBI Micro base image") private String micro; + @CommandLine.Option(names = { "--ubi-tag" }, description = "The tag to add to the output image tag") + private String ubiTag; + @CommandLine.Option(names = { "--out" }, description = "The output image") private String output; @@ -31,7 +34,7 @@ public class Push implements Callable { @Override public Integer call() throws Exception { JDock.setDockerFileDir(dockerFileDir); - QuarkusMicro.define(minimal, micro, output) + QuarkusMicro.define(minimal, micro, output, ubiTag) .buildAndPush(); return 0; } diff --git a/quarkus-micro-base-image/src/main/java/io/quarkus/images/QuarkusMicro.java b/quarkus-micro-base-image/src/main/java/io/quarkus/images/QuarkusMicro.java index 06282057..326b28da 100644 --- a/quarkus-micro-base-image/src/main/java/io/quarkus/images/QuarkusMicro.java +++ b/quarkus-micro-base-image/src/main/java/io/quarkus/images/QuarkusMicro.java @@ -4,7 +4,7 @@ public class QuarkusMicro { - static MultiArchImage define(String minimal, String micro, String output) { + static MultiArchImage define(String minimal, String micro, String output, String ubiTag) { MultiStageDockerFile img = Dockerfile.multistages() .stage("ubi", Dockerfile.from(minimal)) .stage("scratch", Dockerfile.from(micro)) @@ -12,6 +12,9 @@ static MultiArchImage define(String minimal, String micro, String output) { .copyFromStage("ubi", "/usr/lib64/libgcc_s.so.1") .copyFromStage("ubi", "/usr/lib64/libstdc++.so.6") .copyFromStage("ubi", "/usr/lib64/libz.so.1")); + if (!"ubi".equals(ubiTag)) { + output = output + '-' + ubiTag; + } return new MultiArchImage(output, Map.of( "arm64", img, "amd64", img)); diff --git a/quarkus-native-s2i/pom.xml b/quarkus-native-s2i/pom.xml index 9f0c8b59..7a26d6cf 100644 --- a/quarkus-native-s2i/pom.xml +++ b/quarkus-native-s2i/pom.xml @@ -33,7 +33,7 @@ --dockerfile-dir=${project.basedir}/target/docker --ubi-minimal=${ubi-min.base} - --out=quay.io/quarkus/ubi-quarkus-graalvmce-s2i + --out=quay.io/quarkus/${ubi.tag}-quarkus-graalvmce-s2i --in=${project.basedir}/graalvm.yaml --basedir=${project.basedir} --dry-run=${jdock.dry-run}