diff --git a/.github/workflows/docker-ort-android.yml b/.github/workflows/docker-ort-android.yml index 02d6914d75fa6..d46c897ddb520 100644 --- a/.github/workflows/docker-ort-android.yml +++ b/.github/workflows/docker-ort-android.yml @@ -27,7 +27,7 @@ on: branches: - main workflow_run: - workflows: ["Base Image"] + workflows: ["Runtime Image"] types: - completed diff --git a/.github/workflows/docker-ort-dart.yml b/.github/workflows/docker-ort-dart.yml index b84ee98981924..ac84045f67032 100644 --- a/.github/workflows/docker-ort-dart.yml +++ b/.github/workflows/docker-ort-dart.yml @@ -27,7 +27,7 @@ on: - '.ortversions/dart.versions' - '.github/workflows/docker-ort-base.yml' workflow_run: - workflows: ["Base Image"] + workflows: ["Scale Image"] types: - completed diff --git a/.github/workflows/docker-ort-dotnet.yml b/.github/workflows/docker-ort-dotnet.yml index 38a574922574a..158eb7ff5bd64 100644 --- a/.github/workflows/docker-ort-dotnet.yml +++ b/.github/workflows/docker-ort-dotnet.yml @@ -27,7 +27,7 @@ on: - '.ortversions/dotnet.versions' - '.github/workflows/docker-ort-base.yml' workflow_run: - workflows: ["Base Image"] + workflows: ["Dart Image"] env: REGISTRY: ghcr.io diff --git a/.github/workflows/docker-ort-golang.yml b/.github/workflows/docker-ort-golang.yml index bedfd252ae83c..2b79707ff5a64 100644 --- a/.github/workflows/docker-ort-golang.yml +++ b/.github/workflows/docker-ort-golang.yml @@ -27,7 +27,7 @@ on: - '.ortversions/golang.versions' - '.github/workflows/docker-ort-base.yml' workflow_run: - workflows: ["Base Image"] + workflows: ["Ruby Image"] types: - completed diff --git a/.github/workflows/docker-ort-haskell.yml b/.github/workflows/docker-ort-haskell.yml index 01a7c9c3365e6..0fdf52cb681a3 100644 --- a/.github/workflows/docker-ort-haskell.yml +++ b/.github/workflows/docker-ort-haskell.yml @@ -27,7 +27,7 @@ on: - '.ortversions/haskell.versions' - '.github/workflows/docker-ort-base.yml' workflow_run: - workflows: ["Base Image"] + workflows: ["Dotnet Image"] types: - completed diff --git a/.github/workflows/docker-ort-nodejs.yml b/.github/workflows/docker-ort-nodejs.yml index 437da65c1e6b9..7429a049d6324 100644 --- a/.github/workflows/docker-ort-nodejs.yml +++ b/.github/workflows/docker-ort-nodejs.yml @@ -27,7 +27,7 @@ on: - '.ortversions/nodejs.versions' - '.github/workflows/docker-ort-base.yml' workflow_run: - workflows: ["Base Image"] + workflows: ["Python Image"] types: - completed diff --git a/.github/workflows/docker-ort-ruby.yml b/.github/workflows/docker-ort-ruby.yml index 1bb9afc8d87be..b8de1d088dd6e 100644 --- a/.github/workflows/docker-ort-ruby.yml +++ b/.github/workflows/docker-ort-ruby.yml @@ -27,8 +27,9 @@ on: - '.ortversions/ruby.versions' - '.github/workflows/docker-ort-base.yml' workflow_run: - workflows: ["Base Image"] - + workflows: ["Rust Image"] + types: + - completed env: REGISTRY: ghcr.io diff --git a/.github/workflows/docker-ort-runtime-ext.yml b/.github/workflows/docker-ort-runtime-ext.yml new file mode 100644 index 0000000000000..5e067ad073cbe --- /dev/null +++ b/.github/workflows/docker-ort-runtime-ext.yml @@ -0,0 +1,88 @@ + # Copyright (C) 2023 The ORT Project Authors (see ) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# License-Filename: LICENSE + +name: Extended Image + +on: + workflow_dispatch: + pull_request: + branches: + - main + push: + branches: + - main + workflow_run: + workflows: + - 'Haskell Image' + types: + - completed + +env: + REGISTRY: ghcr.io + +permissions: write-all + +jobs: + build: + name: Build ORT Extended Image + runs-on: ubuntu-22.04 + permissions: + contents: read + packages: write + + steps: + - name: Checkout default branch + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract components metadata (tags, labels) for Ort runtime image + id: meta-ort + uses: docker/metadata-action@v4 + with: + images: | + ${{ env.REGISTRY }}/${{ github.repository_owner }}/ort-extended + tags: | + type=raw,sha,enable=true,format=short + + - name: Build ORT runtime container + uses: docker/build-push-action@v4 + with: + context: . + file: Dockerfile-extended + push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} + load: false + tags: | + ${{ steps.meta-ort.outputs.tags }} + ${{ env.REGISTRY }}/${{ github.repository_owner }}/ort-extended:latest + labels: ${{ steps.meta.outputs.labels }} + build-contexts: | + android=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/android:latest + swift=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/swift:latest + sbt=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/sbt:latest + dart=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/dart:latest + dotnet=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/dotnet:latest + haskell=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/haskell:latest + dotnet=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/dotnet:latest diff --git a/.github/workflows/docker-ort-runtime.yml b/.github/workflows/docker-ort-runtime.yml index 1eb2eb050067c..76e34226d2680 100644 --- a/.github/workflows/docker-ort-runtime.yml +++ b/.github/workflows/docker-ort-runtime.yml @@ -27,10 +27,6 @@ on: - main workflow_run: workflows: - - 'Python Image' - - 'NodeJS Image' - - 'Ruby Image' - - 'Rust Image' - 'Golang Image' types: - completed diff --git a/.github/workflows/docker-ort-rust.yml b/.github/workflows/docker-ort-rust.yml index 295a6351c196e..654c122e36594 100644 --- a/.github/workflows/docker-ort-rust.yml +++ b/.github/workflows/docker-ort-rust.yml @@ -27,7 +27,9 @@ on: - '.ortversions/rust.versions' - '.github/workflows/docker-ort-base.yml' workflow_run: - workflows: ["Base Image"] + workflows: ["NodeJS Image"] + types: + - completed env: REGISTRY: ghcr.io diff --git a/.github/workflows/docker-ort-scala.yml b/.github/workflows/docker-ort-scala.yml new file mode 100644 index 0000000000000..f091a60eb3c34 --- /dev/null +++ b/.github/workflows/docker-ort-scala.yml @@ -0,0 +1,91 @@ +# Copyright (C) 2023 The ORT Project Authors (see ) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# License-Filename: LICENSE + +name: Scala Image + +on: + workflow_dispatch: + push: + branches: + - main + pull_request: + paths: + - '.ortversions/sbt.versions' + - '.github/workflows/docker-ort-base.yml' + workflow_run: + workflows: ["Swift Image"] + types: + - completed + +env: + REGISTRY: ghcr.io + +permissions: write-all + +jobs: + build: + name: Build ORT sbt Image + runs-on: ubuntu-22.04 + permissions: + contents: read + packages: write + + steps: + - name: Checkout main repository + uses: actions/checkout@v3 + + - name: Set environment variables + run: | + cat .ortversions/sbt.versions >> $GITHUB_ENV + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract components metadata (tags, labels) for base image + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ${{ env.REGISTRY }}/${{ github.repository }}/sbt + tags: | + type=semver,pattern={{version}},value=${{ env.SBT_VERSION }} + + + - name: Build ORT sbt container + uses: docker/build-push-action@v4 + with: + context: . + target: sbt + push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} + load: false + build-args: | + SBT_VERSION=${{ env.SBT_VERSION }} + tags: | + ${{ steps.meta.outputs.tags }} + ${{ env.REGISTRY }}/${{ github.repository }}/sbt:latest + labels: ${{ steps.meta.outputs.labels }} + build-contexts: | + ort-base-image=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/base:latest + cache-from: type=gha,scope=ortsbt + cache-to: type=gha,scope=ortsbt,mode=max diff --git a/.github/workflows/docker-ort-swift.yml b/.github/workflows/docker-ort-swift.yml index 24e4ecec9347d..eeeac6d0e7c35 100644 --- a/.github/workflows/docker-ort-swift.yml +++ b/.github/workflows/docker-ort-swift.yml @@ -27,7 +27,7 @@ on: - '.ortversions/swift.versions' - '.github/workflows/docker-ort-base.yml' workflow_run: - workflows: ["Base Image"] + workflows: ["Android Image"] types: - completed diff --git a/.gitignore b/.gitignore index 02693a0aeb0d1..a7071979d01d1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ build/ out/ /local.properties /*.iml +Dockerfile.custom # Kotest temporary directory .kotest/ diff --git a/Dockerfile-extended b/Dockerfile-extended index 81a007d6cd639..3dce2517060ce 100644 --- a/Dockerfile-extended +++ b/Dockerfile-extended @@ -22,15 +22,15 @@ ENV ANDROID_HOME=/opt/android-sdk ENV ANDROID_USER_HOME=$HOME/.android ENV PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/cmdline-tools/bin ENV PATH=$PATH:$ANDROID_HOME/platform-tools -COPY --from=ghcr.io/oss-review-toolkit/android --chown=$USER:$USER $ANDROID_HOME $ANDROID_HOME -RUN chmod -R o+rw $ANDROID_HOME +COPY --from=android --chown=$USER:$USER $ANDROID_HOME $ANDROID_HOME +RUN sudo chmod -R o+rw $ANDROID_HOME RUN syft $ANDROID_HOME -o spdx-json --file /usr/share/doc/ort/ort-android.spdx.json # Swift ENV SWIFT_HOME=/opt/swift ENV PATH=$PATH:$SWIFT_HOME/bin -COPY --from=ghcr.io/oss-review-toolkit/swift --chown=$USER:$USER $SWIFT_HOME $SWIFT_HOME +COPY --from=swift --chown=$USER:$USER $SWIFT_HOME $SWIFT_HOME RUN syft $SWIFT_HOME -o spdx-json --file /usr/share/doc/ort/ort-swift.spdx.json @@ -38,14 +38,14 @@ RUN syft $SWIFT_HOME -o spdx-json --file /usr/share/doc/ort/ort-swift.spdx.json # Scala ENV SBT_HOME=/opt/sbt ENV PATH=$PATH:$SBT_HOME/bin -COPY --from=ghcr.io/oss-review-toolkit/sbt --chown=$USER:$USER $SBT_HOME $SBT_HOME +COPY --from=sbt --chown=$USER:$USER $SBT_HOME $SBT_HOME RUN syft $SBT_HOME -o spdx-json --file /usr/share/doc/ort/ort-sbt.spdx.json # Dart ENV DART_SDK=/opt/dart-sdk ENV PATH=$PATH:$DART_SDK/bin -COPY --from=ghcr.io/oss-review-toolkit/dart --chown=$USER:$USER $DART_SDK $DART_SDK +COPY --from=dart --chown=$USER:$USER $DART_SDK $DART_SDK RUN syft $DART_SDK -o spdx-json --file /usr/share/doc/ort/ort-golang.dart.json @@ -54,7 +54,7 @@ ENV DOTNET_HOME=/opt/dotnet ENV NUGET_INSPECTOR_HOME=$DOTNET_HOME ENV PATH=$PATH:$DOTNET_HOME:$DOTNET_HOME/tools:$DOTNET_HOME/bin -COPY --from=ghcr.io/oss-review-toolkit/dotnet --chown=$USER:$USER $DOTNET_HOME $DOTNET_HOME +COPY --from=dotnet --chown=$USER:$USER $DOTNET_HOME $DOTNET_HOME RUN syft $DOTNET_HOME -o spdx-json --file /usr/share/doc/ort/ort-dotnet.spdx.json @@ -77,10 +77,9 @@ ENV PATH=$PATH:/opt/php/bin RUN syft /opt/php -o spdx-json --file /usr/share/doc/ort/ort-php.spdx.json # Haskell -ARG HASKELL_STACK_VERSION=2.7.5 ENV HASKELL_HOME=/opt/haskell ENV PATH=$PATH:$HASKELL_HOME/bin -COPY --from=ghcr.io/oss-review-toolkit/haskell /opt/haskell /opt/haskell +COPY --from=haskell /opt/haskell /opt/haskell RUN syft /opt/haskell -o spdx-json --file /usr/share/doc/ort/ort-haskell.spdx.json diff --git a/scripts/docker_build.sh b/scripts/docker_build.sh index ee58e3392a234..3bf5622a4b4a1 100755 --- a/scripts/docker_build.sh +++ b/scripts/docker_build.sh @@ -20,7 +20,7 @@ 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") +GIT_REVISION=$("$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." @@ -166,3 +166,17 @@ image_build dotnet dotnet "$DOTNET_VERSION" \ image_build haskell haskell "$HASKELL_STACK_VERSION" \ --build-arg HASKELL_STACK_VERSION="$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:latest" \ + --build-context "sbt=docker-image://${DOCKER_IMAGE_ROOT}/sbt:latest" \ + --build-context "dotnet=docker-image://${DOCKER_IMAGE_ROOT}/dotnet:latest" \ + --build-context "swift=docker-image://${DOCKER_IMAGE_ROOT}/swift:latest" \ + --build-context "android=docker-image://${DOCKER_IMAGE_ROOT}/android:latest" \ + --build-context "dart=docker-image://${DOCKER_IMAGE_ROOT}/dart:latest" \ + --build-context "haskell=docker-image://${DOCKER_IMAGE_ROOT}/haskell:latest" \ + "$@" . +