From 49a0a36589f2318b552f2ffe3dffd0f78f9fb2a4 Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Tue, 26 Sep 2023 22:48:33 +0200 Subject: [PATCH 1/4] chore(docker): Use more common naming Signed-off-by: Helio Chissini de Castro --- .github/workflows/docker-ort-runtime-ext.yml | 4 ++-- .github/workflows/docker-ort-runtime.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-ort-runtime-ext.yml b/.github/workflows/docker-ort-runtime-ext.yml index c1a9efbfc9a2b..908bf91236c72 100644 --- a/.github/workflows/docker-ort-runtime-ext.yml +++ b/.github/workflows/docker-ort-runtime-ext.yml @@ -15,7 +15,7 @@ # SPDX-License-Identifier: Apache-2.0 # License-Filename: LICENSE -name: Mega Docker extended image +name: Docker extended runtime image on: workflow_dispatch: @@ -31,7 +31,7 @@ on: - '*' workflow_run: workflows: - - 'Mega Docker runtime image' + - 'Docker runtime image' types: - completed diff --git a/.github/workflows/docker-ort-runtime.yml b/.github/workflows/docker-ort-runtime.yml index 63fb83751d121..2f97de52897e4 100644 --- a/.github/workflows/docker-ort-runtime.yml +++ b/.github/workflows/docker-ort-runtime.yml @@ -15,7 +15,7 @@ # SPDX-License-Identifier: Apache-2.0 # License-Filename: LICENSE -name: Mega Docker runtime image +name: Docker runtime image on: workflow_dispatch: From ec6ef1e9f07911e8fa83998d7204ec957d12d77d Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Tue, 26 Sep 2023 22:17:41 +0200 Subject: [PATCH 2/4] fix(docker): Set correct version for runtime Main version is caught in the same manner as the docker_build script, with gradlew. Tag event will create the version with defined tag. Signed-off-by: Helio Chissini de Castro --- .github/workflows/docker-ort-runtime-ext.yml | 13 ++++++++++++- .github/workflows/docker-ort-runtime.yml | 12 +++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-ort-runtime-ext.yml b/.github/workflows/docker-ort-runtime-ext.yml index 908bf91236c72..347a0d49dca8d 100644 --- a/.github/workflows/docker-ort-runtime-ext.yml +++ b/.github/workflows/docker-ort-runtime-ext.yml @@ -24,6 +24,8 @@ on: - '.versions' - 'Dockerfile' - 'Dockerfile-extended' + - '.github/workflows/docker-ort-runtime.yml' + - '.github/workflows/docker-ort-runtime-ext.yml' push: branches: - main @@ -162,6 +164,13 @@ jobs: steps: - name: Checkout default branch uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get ORT current version + run: | + ORT_VERSION=$(./gradlew -q properties --property version | sed -nr "s/version: (.+)/\1/p") + echo "ORT_VERSION=${ORT_VERSION}" >> $GITHUB_ENV - name: Set up Docker build uses: docker/setup-buildx-action@v3 @@ -180,7 +189,9 @@ jobs: images: | ${{ env.REGISTRY }}/${{ github.repository_owner }}/ort-extended tags: | - type=raw,sha,enable=true,format=short + type=schedule,pattern={{date 'YYYYMMDD'}} + type=pep440,pattern={{version}} + type=raw,value=${{ env.ORT_VERSION }} - name: Build ORT extended runtime image uses: docker/build-push-action@v5 diff --git a/.github/workflows/docker-ort-runtime.yml b/.github/workflows/docker-ort-runtime.yml index 2f97de52897e4..c86453a9d23ab 100644 --- a/.github/workflows/docker-ort-runtime.yml +++ b/.github/workflows/docker-ort-runtime.yml @@ -23,6 +23,7 @@ on: paths: - '.versions' - 'Dockerfile' + - '.github/workflows/docker-ort-runtime.yml' push: branches: - main @@ -172,11 +173,18 @@ jobs: steps: - name: Checkout default branch uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Set environment variables run: | cat .versions >> $GITHUB_ENV + - name: Get ORT current version + run: | + ORT_VERSION=$(./gradlew -q properties --property version | sed -nr "s/version: (.+)/\1/p") + echo "ORT_VERSION=${ORT_VERSION}" >> $GITHUB_ENV + - name: Set up Docker build uses: docker/setup-buildx-action@v3 @@ -194,7 +202,9 @@ jobs: images: | ${{ env.REGISTRY }}/${{ github.repository_owner }}/ort tags: | - type=raw,sha,enable=true,format=short + type=schedule,pattern={{date 'YYYYMMDD'}} + type=pep440,pattern={{version}} + type=raw,value=${{ env.ORT_VERSION }} - name: Build ORT runtime image if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} From ae1bdb3cf54f3025a7bb7c4cb57597856f4621c8 Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Wed, 27 Sep 2023 08:49:45 +0200 Subject: [PATCH 3/4] fix(docker): Add missing base image context Signed-off-by: Helio Chissini de Castro --- .github/workflows/docker-ort-runtime.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker-ort-runtime.yml b/.github/workflows/docker-ort-runtime.yml index c86453a9d23ab..100269d4fe33f 100644 --- a/.github/workflows/docker-ort-runtime.yml +++ b/.github/workflows/docker-ort-runtime.yml @@ -221,6 +221,7 @@ jobs: ${{ env.REGISTRY }}/${{ github.repository_owner }}/ort:latest labels: ${{ steps.meta.outputs.labels }} build-contexts: | + base=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/base:latest nodejs=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/nodejs:latest python=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/python:latest rust=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/rust:latest From 25642997f6178264c9487b5ea7e6d63d5cd8da86 Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Thu, 28 Sep 2023 11:08:07 +0200 Subject: [PATCH 4/4] chore(docker): Proper use gradle based ORT_VERSION Signed-off-by: Helio Chissini de Castro --- .github/workflows/docker-ort-runtime-ext.yml | 2 +- .github/workflows/docker-ort-runtime.yml | 2 +- scripts/docker_build.sh | 13 +++++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-ort-runtime-ext.yml b/.github/workflows/docker-ort-runtime-ext.yml index 347a0d49dca8d..fe84d9d585a4f 100644 --- a/.github/workflows/docker-ort-runtime-ext.yml +++ b/.github/workflows/docker-ort-runtime-ext.yml @@ -205,7 +205,7 @@ jobs: ${{ env.REGISTRY }}/${{ github.repository_owner }}/ort-extended:latest labels: ${{ steps.meta.outputs.labels }} build-contexts: | - ort=docker-image://${{ env.REGISTRY }}/${{ github.repository_owner }}/ort:latest + ort=docker-image://${{ env.REGISTRY }}/${{ github.repository_owner }}/ort:${{ env.ORT_VERSION }} android=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/android:latest swift=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/swift:latest scala=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/scala:latest diff --git a/.github/workflows/docker-ort-runtime.yml b/.github/workflows/docker-ort-runtime.yml index 100269d4fe33f..991297030eb77 100644 --- a/.github/workflows/docker-ort-runtime.yml +++ b/.github/workflows/docker-ort-runtime.yml @@ -215,7 +215,7 @@ jobs: push: true load: false build-args: | - NODEJS_VERSION=${{ env.NODEJS_VERSION }} + ORT_VERSION=${{ env.ORT_VERSION }} tags: | ${{ steps.meta-ort.outputs.tags }} ${{ env.REGISTRY }}/${{ github.repository_owner }}/ort:latest diff --git a/scripts/docker_build.sh b/scripts/docker_build.sh index 7aa091653f2eb..bfac36549d586 100755 --- a/scripts/docker_build.sh +++ b/scripts/docker_build.sh @@ -20,10 +20,10 @@ set -e -o pipefail GIT_ROOT=$(git rev-parse --show-toplevel) -GIT_REVISION=$("$GIT_ROOT/gradlew" -q properties --property version | sed -nr "s/version: (.+)/\1/p") +ORT_VERSION=$("$GIT_ROOT/gradlew" -q properties --property version | sed -nr "s/version: (.+)/\1/p") DOCKER_IMAGE_ROOT="${DOCKER_IMAGE_ROOT:-ghcr.io/oss-review-toolkit}" -echo "Setting ORT_VERSION to $GIT_REVISION." +echo "Setting ORT_VERSION to $ORT_VERSION." # shellcheck disable=SC1091 . .versions @@ -101,8 +101,8 @@ image_build golang ort/golang "$GO_VERSION" \ "$@" # Runtime ORT image -image_build run ort "$GIT_REVISION" \ - --build-arg NODEJS_VERSION="$NODEJS_VERSION" \ +image_build run ort "$ORT_VERSION" \ + --build-arg ORT_VERSION="$ORT_VERSION" \ --build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/ort/base:latest" \ --build-context "python=docker-image://${DOCKER_IMAGE_ROOT}/ort/python:latest" \ --build-context "nodejs=docker-image://${DOCKER_IMAGE_ROOT}/ort/nodejs:latest" \ @@ -155,9 +155,10 @@ image_build haskell ort/haskell "$HASKELL_STACK_VERSION" \ # Runtime extended ORT image docker buildx build \ --file Dockerfile-extended \ - --tag "${DOCKER_IMAGE_ROOT}/ort-extended:$GIT_REVISION" \ + --tag "${DOCKER_IMAGE_ROOT}/ort-extended:$ORT_VERSION" \ --tag "${DOCKER_IMAGE_ROOT}/ort-extended:latest" \ - --build-context "ort=docker-image://${DOCKER_IMAGE_ROOT}/ort:latest" \ + --build-arg ORT_VERSION="$ORT_VERSION" \ + --build-context "ort=docker-image://${DOCKER_IMAGE_ROOT}/ort:${ORT_VERSION}" \ --build-context "sbt=docker-image://${DOCKER_IMAGE_ROOT}/ort/sbt:latest" \ --build-context "dotnet=docker-image://${DOCKER_IMAGE_ROOT}/ort/dotnet:latest" \ --build-context "swift=docker-image://${DOCKER_IMAGE_ROOT}/ort/swift:latest" \