From 1dc35ee3aea8dd63bf73b1600f5a6bc1db78b5bd Mon Sep 17 00:00:00 2001 From: Brian Wyka <46069296+brianwyka@users.noreply.github.com> Date: Thu, 6 Jan 2022 14:36:15 -0500 Subject: [PATCH] Docker builders (#62) * docker-builders: Docker builder updates for ghcr * docker-builders: Fix setup * docker-builders: Fix docker image references * docker-builders: Fix workflow * docker-builders: Fix push script * docker-builders: Update parent to 1.2.0 * docker-builders: Add docker logout * docker-builders: Use GITHUB_PACKAGE_TOKEN * docker-builders: Login at top of script * docker-builders: Fix secret name --- .../build-and-push-docker-builders.yml | 8 +-- .github/workflows/maven-ci.yml | 12 ++--- .github/workflows/release.yml | 16 +++--- .../docker-builders/Dockerfile-nativeimage | 2 +- .../linux/native-image-builder/Dockerfile | 4 +- distributions/linux/pom.xml | 15 +++++- distributions/rpm/Dockerfile | 2 +- distributions/rpm/pom.xml | 52 +++++++++++++++++++ ...ild-and-push-docker-builders-to-bintray.sh | 49 ----------------- .../scripts/build-and-push-docker-builders.sh | 46 ++++++++++++++++ pom.xml | 2 +- 11 files changed, 134 insertions(+), 74 deletions(-) delete mode 100755 distributions/scripts/build-and-push-docker-builders-to-bintray.sh create mode 100755 distributions/scripts/build-and-push-docker-builders.sh diff --git a/.github/workflows/build-and-push-docker-builders.yml b/.github/workflows/build-and-push-docker-builders.yml index ed0b162..2793019 100644 --- a/.github/workflows/build-and-push-docker-builders.yml +++ b/.github/workflows/build-and-push-docker-builders.yml @@ -13,9 +13,9 @@ jobs: - uses: actions/checkout@v2 with: ref: ${{ github.event.inputs.ref }} - - name: Build and Push Docker Images to Bintray + - name: Build and Push Docker Images to Github Container Registry shell: bash - run: ./distributions/scripts/build-and-push-docker-builders-to-bintray.sh + run: ./distributions/scripts/build-and-push-docker-builders.sh env: - BINTRAY_USERNAME: ${{ secrets.BINTRAY_USERNAME }} - BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }} + DOCKER_USERNAME: ${{ secrets.GIT_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.GIT_PACKAGE_TOKEN }} diff --git a/.github/workflows/maven-ci.yml b/.github/workflows/maven-ci.yml index 75c4144..aae2c26 100644 --- a/.github/workflows/maven-ci.yml +++ b/.github/workflows/maven-ci.yml @@ -39,7 +39,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: ['8', '11'] + java: ['8', '11', '17'] steps: - uses: actions/checkout@v2 - uses: actions/cache@v1 @@ -140,7 +140,7 @@ jobs: - name: Setup GraalVM uses: DeLaGuardo/setup-graalvm@master with: - graalvm-version: 20.3.0.java8 + graalvm-version: 21.2.0.java8 - name: Setup GraalVM Native Image Tool run: gu install native-image - name: Build Mac Native Image @@ -182,18 +182,18 @@ jobs: run: ren *.jar native-image.jar - name: Setup GraalVM Native Image and Visual C Build Tools run: | - Invoke-RestMethod -Uri https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-20.3.0/graalvm-ce-java11-windows-amd64-20.3.0.zip -OutFile 'graal.zip' + Invoke-RestMethod -Uri https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.3.0/graalvm-ce-java11-windows-amd64-21.3.0.zip -OutFile 'graal.zip' Expand-Archive -path 'graal.zip' -destinationpath '.' - graalvm-ce-java11-20.3.0\bin\gu.cmd install native-image + graalvm-ce-java11-21.3.0\bin\gu.cmd install native-image choco install visualstudio2017-workload-vctools - name: Build Windows Native Image if: success() shell: cmd run: | call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat" - graalvm-ce-java11-20.3.0\bin\native-image -cp .\build\native-image.jar -H:+ReportExceptionStackTraces --report-unsupported-elements-at-runtime + graalvm-ce-java11-21.3.0\bin\native-image -cp .\build\native-image.jar -H:+ReportExceptionStackTraces --report-unsupported-elements-at-runtime env: - JAVA_HOME: ./graalvm-ce-java11-20.3.0 + JAVA_HOME: ./graalvm-ce-java11-21.3.0 - name: Archive Windows Native Image if: success() continue-on-error: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9211b04..519f563 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -154,7 +154,7 @@ jobs: asset_path: ./distributions/rpm/target/sourcehawk-centos-8.rpm asset_name: sourcehawk-${{ steps.set_maven_project_version.outputs.RELEASE_VERSION }}-1.el8.x86_64.rpm asset_content_type: application/octet-stream - - name: Upload Sourcehawk Fedora 34 RPM Package + - name: Upload Sourcehawk Fedora 35 RPM Package if: success() continue-on-error: true uses: actions/upload-release-asset@v1 @@ -162,8 +162,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./distributions/rpm/target/sourcehawk-fedora-34.rpm - asset_name: sourcehawk-${{ steps.set_maven_project_version.outputs.RELEASE_VERSION }}-1.fc34.x86_64.rpm + asset_path: ./distributions/rpm/target/sourcehawk-fedora-35.rpm + asset_name: sourcehawk-${{ steps.set_maven_project_version.outputs.RELEASE_VERSION }}-1.fc35.x86_64.rpm asset_content_type: application/octet-stream - name: Publish Github Pages if: success() @@ -228,7 +228,7 @@ jobs: - name: Setup GraalVM uses: DeLaGuardo/setup-graalvm@master with: - graalvm-version: 20.3.0.java8 + graalvm-version: 21.2.0.java8 - name: Setup GraalVM Native Image Tool run: gu install native-image - name: Build Mac Native Image @@ -291,18 +291,18 @@ jobs: run: ren *.jar native-image.jar - name: Setup GraalVM Native Image and Visual C Build Tools run: | - Invoke-RestMethod -Uri https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-20.3.0/graalvm-ce-java11-windows-amd64-20.3.0.zip -OutFile 'graal.zip' + Invoke-RestMethod -Uri https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.3.0/graalvm-ce-java11-windows-amd64-21.3.0.zip -OutFile 'graal.zip' Expand-Archive -path 'graal.zip' -destinationpath '.' - graalvm-ce-java11-20.3.0\bin\gu.cmd install native-image + graalvm-ce-java11-21.3.0\bin\gu.cmd install native-image choco install visualstudio2017-workload-vctools - name: Build Windows Native Image if: success() shell: cmd run: | call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat" - graalvm-ce-java11-20.3.0\bin\native-image -cp .\build\native-image.jar -H:+ReportExceptionStackTraces --report-unsupported-elements-at-runtime + graalvm-ce-java11-21.3.0\bin\native-image -cp .\build\native-image.jar -H:+ReportExceptionStackTraces --report-unsupported-elements-at-runtime env: - JAVA_HOME: ./graalvm-ce-java11-20.3.0 + JAVA_HOME: ./graalvm-ce-java11-21.3.0 - name: Smoke Test if: success() shell: cmd diff --git a/distributions/docker-builders/Dockerfile-nativeimage b/distributions/docker-builders/Dockerfile-nativeimage index d5aa82e..d06225e 100644 --- a/distributions/docker-builders/Dockerfile-nativeimage +++ b/distributions/docker-builders/Dockerfile-nativeimage @@ -1,5 +1,5 @@ # Oracle GraalVM Java 8 Base Container -ARG FROM=oracle/graalvm-ce:20.3.0-java8 +ARG FROM=ghcr.io/graalvm/graalvm-ce:java8-21.2.0 FROM ${FROM} # Install native-image tool diff --git a/distributions/linux/native-image-builder/Dockerfile b/distributions/linux/native-image-builder/Dockerfile index 9066713..ce6898d 100644 --- a/distributions/linux/native-image-builder/Dockerfile +++ b/distributions/linux/native-image-builder/Dockerfile @@ -1,5 +1,5 @@ -ARG GRAALVM_VERSION=20.3.0-java8 -FROM optum-docker-builders.bintray.io/nativeimage:graalvm-ce-${GRAALVM_VERSION} +ARG GRAALVM_VERSION=21.3.0-java8 +FROM ghcr.io/optum/sourcehawk-ci/nativeimage:graalvm-ce-${GRAALVM_VERSION} # Build Arguments ARG NAME diff --git a/distributions/linux/pom.xml b/distributions/linux/pom.xml index 30dc442..561a2ca 100644 --- a/distributions/linux/pom.xml +++ b/distributions/linux/pom.xml @@ -236,7 +236,7 @@ 8 - 20.3.0-java8 + 21.3.0-java8 @@ -247,7 +247,18 @@ 11 - 20.3.0-java11 + 21.3.0-java11 + + + + + + native-image-build-java17 + + 11 + + + 21.3.0-java17 diff --git a/distributions/rpm/Dockerfile b/distributions/rpm/Dockerfile index d1acb16..7b8d31a 100644 --- a/distributions/rpm/Dockerfile +++ b/distributions/rpm/Dockerfile @@ -1,5 +1,5 @@ ARG FROM_TAG=centos7 -FROM optum-docker-builders.bintray.io/rpmbuild:${FROM_TAG} +FROM ghcr.io/optum/sourcehawk-ci/rpmbuild:${FROM_TAG} # Build Arguments ARG RPM_BUILD_DIRECTORY diff --git a/distributions/rpm/pom.xml b/distributions/rpm/pom.xml index a65e783..4a63270 100644 --- a/distributions/rpm/pom.xml +++ b/distributions/rpm/pom.xml @@ -244,6 +244,23 @@ true + + build-and-tag-fedora-35 + prepare-package + + build + tag + + + ${project.artifactId}-builder-fedora-35 + ${project.version} + + fedora35 + /tmp/${rpm.package}-fedora-35.rpm + + true + + @@ -342,6 +359,21 @@ + + extract-fedora-35-package + package + + exec + + + ${project.parent.basedir}/scripts/extract-file-from-docker-container.sh + + ${project.artifactId}-builder-fedora-35:${project.version} + /tmp/${rpm.package}-fedora-35.rpm + ${project.build.directory} + + + @@ -396,6 +428,11 @@ fc34.${rpm.package.architecture} rpm + + ${project.build.directory}/${rpm.package}-fedora-35.rpm + fc35.${rpm.package.architecture} + rpm + @@ -535,6 +572,21 @@ + + publish-fedora-35-package + + exec + + deploy + + ${project.basedir}/scripts/publish-package-version-to-bintray.sh + + ${project.build.directory}/${rpm.package}-fedora-35.rpm + fedora + fc35 + + + diff --git a/distributions/scripts/build-and-push-docker-builders-to-bintray.sh b/distributions/scripts/build-and-push-docker-builders-to-bintray.sh deleted file mode 100755 index 02df3ac..0000000 --- a/distributions/scripts/build-and-push-docker-builders-to-bintray.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -############################################################################################################## -# -# Push Docker Builders to Bintray -# -############################################################################################################## - -set -e - -ROOT_DIR="$( cd "$( dirname "$( dirname "$( dirname "${BASH_SOURCE[0]}" )")")" && pwd )" -DOCKER_BUILDERS_DIR="$ROOT_DIR/distributions/docker-builders" - -# Bintray Variables -BINTRAY_API_URL="https://api.bintray.com" -BINTRAY_ORG="optum" -BINTRAY_REPO="builders" -REGISTRY="optum-docker-builders.bintray.io" - -# Native Image -docker build -t $REGISTRY/nativeimage:graalvm-ce-20.3.0-java8 -f "$DOCKER_BUILDERS_DIR/Dockerfile-nativeimage" --build-arg FROM=oracle/graalvm-ce:20.3.0-java8 . -docker build -t $REGISTRY/nativeimage:graalvm-ce-20.3.0-java11 -f "$DOCKER_BUILDERS_DIR/Dockerfile-nativeimage" --build-arg FROM=oracle/graalvm-ce:20.3.0-java11 . - -# RPM Build -docker build -t $REGISTRY/rpmbuild:centos7 -f "$DOCKER_BUILDERS_DIR/Dockerfile-rpmbuild" --build-arg FROM=centos:7 . -docker build -t $REGISTRY/rpmbuild:centos8 -f "$DOCKER_BUILDERS_DIR/Dockerfile-rpmbuild" --build-arg FROM=centos:8 . -docker build -t $REGISTRY/rpmbuild:fedora32 -f "$DOCKER_BUILDERS_DIR/Dockerfile-rpmbuild" --build-arg FROM=fedora:32 . -docker build -t $REGISTRY/rpmbuild:fedora33 -f "$DOCKER_BUILDERS_DIR/Dockerfile-rpmbuild" --build-arg FROM=fedora:33 . -docker build -t $REGISTRY/rpmbuild:fedora34 -f "$DOCKER_BUILDERS_DIR/Dockerfile-rpmbuild" --build-arg FROM=fedora:34 . - -# Login to Registry -echo "${BINTRAY_API_KEY}" | docker login --username "${BINTRAY_USERNAME}" --password-stdin $REGISTRY - -# Push All Builders to Remote Registry -docker push $REGISTRY/nativeimage:graalvm-ce-20.3.0-java8 -docker push $REGISTRY/nativeimage:graalvm-ce-20.3.0-java11 -docker push $REGISTRY/rpmbuild:centos7 -docker push $REGISTRY/rpmbuild:centos8 -docker push $REGISTRY/rpmbuild:fedora32 -docker push $REGISTRY/rpmbuild:fedora33 -docker push $REGISTRY/rpmbuild:fedora34 - -# Publish Images on Bintray -curl -sfLS -X POST -u "${BINTRAY_USERNAME}:${BINTRAY_API_KEY}" $BINTRAY_API_URL/content/$BINTRAY_ORG/$BINTRAY_REPO/nativeimage/graalvm-ce-20.3.0-java8/publish -curl -sfLS -X POST -u "${BINTRAY_USERNAME}:${BINTRAY_API_KEY}" $BINTRAY_API_URL/content/$BINTRAY_ORG/$BINTRAY_REPO/nativeimage/graalvm-ce-20.3.0-java11/publish -curl -sfLS -X POST -u "${BINTRAY_USERNAME}:${BINTRAY_API_KEY}" $BINTRAY_API_URL/content/$BINTRAY_ORG/$BINTRAY_REPO/rpmbuild/centos8/publish -curl -sfLS -X POST -u "${BINTRAY_USERNAME}:${BINTRAY_API_KEY}" $BINTRAY_API_URL/content/$BINTRAY_ORG/$BINTRAY_REPO/rpmbuild/fedora32/publish -curl -sfLS -X POST -u "${BINTRAY_USERNAME}:${BINTRAY_API_KEY}" $BINTRAY_API_URL/content/$BINTRAY_ORG/$BINTRAY_REPO/rpmbuild/fedora33/publish -curl -sfLS -X POST -u "${BINTRAY_USERNAME}:${BINTRAY_API_KEY}" $BINTRAY_API_URL/content/$BINTRAY_ORG/$BINTRAY_REPO/rpmbuild/fedora34/publish \ No newline at end of file diff --git a/distributions/scripts/build-and-push-docker-builders.sh b/distributions/scripts/build-and-push-docker-builders.sh new file mode 100755 index 0000000..b0996ab --- /dev/null +++ b/distributions/scripts/build-and-push-docker-builders.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +############################################################################################################## +# +# Push Docker Builders to Remote Registry +# +############################################################################################################## + +set -e + +ROOT_DIR="$( cd "$( dirname "$( dirname "$( dirname "${BASH_SOURCE[0]}" )")")" && pwd )" +DOCKER_BUILDERS_DIR="$ROOT_DIR/distributions/docker-builders" + +# Variables +DOCKER_ORG="optum/ci" +REGISTRY="ghcr.io" + +# Login to Registry +echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin $REGISTRY + +# Native Image +docker build -t $REGISTRY/$DOCKER_ORG/nativeimage:graalvm-ce-21.2.0-java8 -f "$DOCKER_BUILDERS_DIR/Dockerfile-nativeimage" --build-arg FROM=ghcr.io/graalvm/graalvm-ce:java8-21.2.0 . +docker build -t $REGISTRY/$DOCKER_ORG/nativeimage:graalvm-ce-21.3.0-java11 -f "$DOCKER_BUILDERS_DIR/Dockerfile-nativeimage" --build-arg FROM=ghcr.io/graalvm/graalvm-ce:java11-21.3.0 . +docker build -t $REGISTRY/$DOCKER_ORG/nativeimage:graalvm-ce-21.3.0-java17 -f "$DOCKER_BUILDERS_DIR/Dockerfile-nativeimage" --build-arg FROM=ghcr.io/graalvm/graalvm-ce:java17-21.3.0 . + +# RPM Build +docker build -t $REGISTRY/$DOCKER_ORG/rpmbuild:centos7 -f "$DOCKER_BUILDERS_DIR/Dockerfile-rpmbuild" --build-arg FROM=centos:7 . +docker build -t $REGISTRY/$DOCKER_ORG/rpmbuild:centos8 -f "$DOCKER_BUILDERS_DIR/Dockerfile-rpmbuild" --build-arg FROM=centos:8 . +docker build -t $REGISTRY/$DOCKER_ORG/rpmbuild:fedora32 -f "$DOCKER_BUILDERS_DIR/Dockerfile-rpmbuild" --build-arg FROM=fedora:32 . +docker build -t $REGISTRY/$DOCKER_ORG/rpmbuild:fedora33 -f "$DOCKER_BUILDERS_DIR/Dockerfile-rpmbuild" --build-arg FROM=fedora:33 . +docker build -t $REGISTRY/$DOCKER_ORG/rpmbuild:fedora34 -f "$DOCKER_BUILDERS_DIR/Dockerfile-rpmbuild" --build-arg FROM=fedora:34 . +docker build -t $REGISTRY/$DOCKER_ORG/rpmbuild:fedora35 -f "$DOCKER_BUILDERS_DIR/Dockerfile-rpmbuild" --build-arg FROM=fedora:35 . + +# Push All Builders to Remote Registry +docker push $REGISTRY/$DOCKER_ORG/nativeimage:graalvm-ce-21.2.0-java8 +docker push $REGISTRY/$DOCKER_ORG/nativeimage:graalvm-ce-21.3.0-java11 +docker push $REGISTRY/$DOCKER_ORG/nativeimage:graalvm-ce-21.3.0-java17 +docker push $REGISTRY/$DOCKER_ORG/rpmbuild:centos7 +docker push $REGISTRY/$DOCKER_ORG/rpmbuild:centos8 +docker push $REGISTRY/$DOCKER_ORG/rpmbuild:fedora32 +docker push $REGISTRY/$DOCKER_ORG/rpmbuild:fedora33 +docker push $REGISTRY/$DOCKER_ORG/rpmbuild:fedora34 +docker push $REGISTRY/$DOCKER_ORG/rpmbuild:fedora35 + +# Log out of registry +docker logout $REGISTRY \ No newline at end of file diff --git a/pom.xml b/pom.xml index f552ae7..8ecf522 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.optum.sourcehawk sourcehawk-jar-parent - 1.1.10 + 1.2.0