From 6bf1bc45aaec78792178a7655fcc3dc726d66f16 Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Sat, 16 Sep 2023 17:36:20 +0200 Subject: [PATCH] feat(simplify): Use jobs over workflow dependency Workflow dependencies relies on a single workflow, which make build pipelines for multiple docker containers complex and most of the time erratic. Move to single jobs dependency based with a internal action to check and build images if needed improve the logic of the process and allow to visually see the running pipeline. The pipeline will run on following cases: - On pull_request if .versions file was touches, but not publishing images on the registry. - On push or workflow_dispatch, publishing to ghcr.io registry. Signed-off-by: Helio Chissini de Castro --- .github/actions/ortdocker/action.yml | 100 +++++++++++++ .github/actions/ortdocker/check_image.py | 46 ++++++ .github/workflows/docker-ort-android.yml | 91 ------------ .github/workflows/docker-ort-base.yml | 83 ----------- .github/workflows/docker-ort-dart.yml | 91 ------------ .github/workflows/docker-ort-dotnet.yml | 89 ----------- .github/workflows/docker-ort-golang.yml | 92 ------------ .github/workflows/docker-ort-haskell.yml | 91 ------------ .github/workflows/docker-ort-nodejs.yml | 93 ------------ .github/workflows/docker-ort-python.yml | 96 ------------ .github/workflows/docker-ort-ruby.yml | 93 ------------ .github/workflows/docker-ort-runtime-ext.yml | 122 ++++++++++++++- .github/workflows/docker-ort-runtime.yml | 147 +++++++++++++++++-- .github/workflows/docker-ort-rust.yml | 91 ------------ .github/workflows/docker-ort-sbt.yml | 91 ------------ .github/workflows/docker-ort-scala.yml | 91 ------------ .github/workflows/docker-ort-swift.yml | 91 ------------ .ortversions/android.versions | 1 - .ortversions/base.versions | 2 - .ortversions/dart.versions | 1 - .ortversions/dotnet.versions | 2 - .ortversions/golang.versions | 2 - .ortversions/haskell.versions | 1 - .ortversions/nodejs.versions | 5 - .ortversions/php.versions | 2 - .ortversions/python.versions | 8 - .ortversions/ruby.versions | 2 - .ortversions/rust.versions | 1 - .ortversions/sbt.versions | 1 - .ortversions/swift.versions | 1 - .versions | 29 ++++ Dockerfile | 34 ++--- scripts/docker_build.sh | 47 ++---- 33 files changed, 461 insertions(+), 1276 deletions(-) create mode 100644 .github/actions/ortdocker/action.yml create mode 100644 .github/actions/ortdocker/check_image.py delete mode 100644 .github/workflows/docker-ort-android.yml delete mode 100644 .github/workflows/docker-ort-base.yml delete mode 100644 .github/workflows/docker-ort-dart.yml delete mode 100644 .github/workflows/docker-ort-dotnet.yml delete mode 100644 .github/workflows/docker-ort-golang.yml delete mode 100644 .github/workflows/docker-ort-haskell.yml delete mode 100644 .github/workflows/docker-ort-nodejs.yml delete mode 100644 .github/workflows/docker-ort-python.yml delete mode 100644 .github/workflows/docker-ort-ruby.yml delete mode 100644 .github/workflows/docker-ort-rust.yml delete mode 100644 .github/workflows/docker-ort-sbt.yml delete mode 100644 .github/workflows/docker-ort-scala.yml delete mode 100644 .github/workflows/docker-ort-swift.yml delete mode 100644 .ortversions/android.versions delete mode 100644 .ortversions/base.versions delete mode 100644 .ortversions/dart.versions delete mode 100644 .ortversions/dotnet.versions delete mode 100644 .ortversions/golang.versions delete mode 100644 .ortversions/haskell.versions delete mode 100644 .ortversions/nodejs.versions delete mode 100644 .ortversions/php.versions delete mode 100644 .ortversions/python.versions delete mode 100644 .ortversions/ruby.versions delete mode 100644 .ortversions/rust.versions delete mode 100644 .ortversions/sbt.versions delete mode 100644 .ortversions/swift.versions create mode 100644 .versions diff --git a/.github/actions/ortdocker/action.yml b/.github/actions/ortdocker/action.yml new file mode 100644 index 0000000000000..02c732ec79f76 --- /dev/null +++ b/.github/actions/ortdocker/action.yml @@ -0,0 +1,100 @@ +# 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: "ORT Docker Image" +description: "Check and create docker image for Ort components" +author: "Helio Chissini de Castro " + +inputs: + registry: + description: "GitHub Container Registry" + default: "ghcr.io" + token: + description: "GitHub token" + required: true + name: + description: "Image name" + required: true + version: + description: "Image version" + required: true + build-args: + description: "List of build-time variables" + required: false + +runs: + using: "composite" + + steps: + - name: Install Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + cache: 'pip' + + - name: Check if Docker image tag exists + id: check_image + shell: bash + env: + INPUT_REGISTRY: ${{ inputs.registry }} + INPUT_TOKEN: ${{ inputs.token }} + INPUT_NAME: ${{ inputs.name }} + INPUT_VERSION: ${{ inputs.version }} + run: | + pip install -q -U pip requests + + result=$(python ./.github/actions/ortdocker/check_image.py) + echo $result + echo "result=$result" >> $GITHUB_OUTPUT + + - name: Set up Docker Buildx + if: steps.check_image.outputs.result != 'found' + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + if: steps.check_image.outputs.result != 'found' + uses: docker/login-action@v2 + with: + registry: ${{ inputs.registry }} + username: ${{ github.actor }} + password: ${{ inputs.token }} + + - name: Extract components metadata (tags, labels) for base image + if: steps.check_image.outputs.result != 'found' + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ${{ env.REGISTRY }}/${{ github.repository }}/${{ inputs.name }} + tags: + type=raw,value=${{ inputs.version }} + + - name: Build ORT Base container + if: steps.check_image.outputs.result != 'found' + uses: docker/build-push-action@v4 + with: + context: . + target: ${{ inputs.name }} + push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} + load: false + build-args: ${{ inputs.build-args }} + tags: | + ${{ steps.meta.outputs.tags }} + ${{ env.REGISTRY }}/${{ github.repository }}/${{ inputs.name }}:latest + labels: ${{ steps.meta.outputs.labels }} + + diff --git a/.github/actions/ortdocker/check_image.py b/.github/actions/ortdocker/check_image.py new file mode 100644 index 0000000000000..98846b0671d93 --- /dev/null +++ b/.github/actions/ortdocker/check_image.py @@ -0,0 +1,46 @@ +# 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 + +import os + +import requests + +token = os.getenv("INPUT_TOKEN") +org = os.getenv("GITHUB_REPOSITORY_OWNER") +name = os.getenv("INPUT_NAME") +version = os.getenv("INPUT_VERSION") + +url = f"https://api.github.com/orgs/{org}/packages/container/ort%2F{name}/versions" + +headers = { + "Accept": "application/vnd.github+json", + "Authorization": f"Bearer {token}", +} +response = requests.get(url, headers=headers) +if response.status_code == 404: + print("none") +else: + versions = [ + item + for sublist in [v["metadata"]["container"]["tags"] for v in response.json()] + if sublist + for item in sublist + ] + if version in versions: + print("found") + else: + print("none") diff --git a/.github/workflows/docker-ort-android.yml b/.github/workflows/docker-ort-android.yml deleted file mode 100644 index d46c897ddb520..0000000000000 --- a/.github/workflows/docker-ort-android.yml +++ /dev/null @@ -1,91 +0,0 @@ -# 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: Android Image - -on: - workflow_dispatch: - pull_request: - paths: - - '.ortversions/android.versions' - - '.github/workflows/docker-ort-base.yml' - push: - branches: - - main - workflow_run: - workflows: ["Runtime Image"] - types: - - completed - -env: - REGISTRY: ghcr.io - -permissions: write-all - -jobs: - build: - name: Build ORT Android 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/android.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 }}/android - tags: | - type=semver,pattern={{version}},value=${{ env.ANDROID_CMD_VERSION }} - - - - name: Build ORT Android container - uses: docker/build-push-action@v4 - with: - context: . - target: android - push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} - load: false - build-args: | - ANDROID_CMD_VERSION=${{ env.ANDROID_CMD_VERSION }} - tags: | - ${{ steps.meta.outputs.tags }} - ${{ env.REGISTRY }}/${{ github.repository }}/android:latest - labels: ${{ steps.meta.outputs.labels }} - build-contexts: | - ort-base-image=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/base:latest - cache-from: type=gha,scope=ortandroid - cache-to: type=gha,scope=ortandroid,mode=max diff --git a/.github/workflows/docker-ort-base.yml b/.github/workflows/docker-ort-base.yml deleted file mode 100644 index 5f0589ce94d18..0000000000000 --- a/.github/workflows/docker-ort-base.yml +++ /dev/null @@ -1,83 +0,0 @@ -# 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: Base Image - -on: - workflow_dispatch: - pull_request: - paths: - - '.ortversions/base.versions' - - 'Dockerfile' - push: - branches: - - main - -env: - REGISTRY: ghcr.io - -jobs: - build: - name: Build ORT Base 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/base.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 }}/base - tags: - type=raw,value=${{ env.JAVA_VERSION }}-jdk-${{ env.UBUNTU_VERSION }} - - - name: Build ORT Base container - uses: docker/build-push-action@v4 - with: - context: . - target: ort-base-image - push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} - load: false - build-args: | - JAVA_VERSION=${{ env.JAVA_VERSION }} - UBUNTU_VERSION=${{ env.UBUNTU_VERSION }} - tags: | - ${{ steps.meta.outputs.tags }} - ${{ env.REGISTRY }}/${{ github.repository }}/base:latest - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha,scope=ortbase - cache-to: type=gha,scope=ortbase,mode=max diff --git a/.github/workflows/docker-ort-dart.yml b/.github/workflows/docker-ort-dart.yml deleted file mode 100644 index ac84045f67032..0000000000000 --- a/.github/workflows/docker-ort-dart.yml +++ /dev/null @@ -1,91 +0,0 @@ -# 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: Dart Image - -on: - workflow_dispatch: - push: - branches: - - main - pull_request: - paths: - - '.ortversions/dart.versions' - - '.github/workflows/docker-ort-base.yml' - workflow_run: - workflows: ["Scale Image"] - types: - - completed - -env: - REGISTRY: ghcr.io - -permissions: write-all - -jobs: - build: - name: Build ORT Dart 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/dart.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 }}/dart - tags: | - type=semver,pattern={{version}},value=${{ env.DART_VERSION }} - - - - name: Build ORT Dart container - uses: docker/build-push-action@v4 - with: - context: . - target: dart - push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} - load: false - build-args: | - DART_VERSION=${{ env.DART_VERSION }} - tags: | - ${{ steps.meta.outputs.tags }} - ${{ env.REGISTRY }}/${{ github.repository }}/dart:latest - labels: ${{ steps.meta.outputs.labels }} - build-contexts: | - ort-base-image=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/base:latest - cache-from: type=gha,scope=ortdart - cache-to: type=gha,scope=ortdart,mode=max diff --git a/.github/workflows/docker-ort-dotnet.yml b/.github/workflows/docker-ort-dotnet.yml deleted file mode 100644 index 158eb7ff5bd64..0000000000000 --- a/.github/workflows/docker-ort-dotnet.yml +++ /dev/null @@ -1,89 +0,0 @@ -# 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: Dotnet Image - -on: - workflow_dispatch: - push: - branches: - - main - pull_request: - paths: - - '.ortversions/dotnet.versions' - - '.github/workflows/docker-ort-base.yml' - workflow_run: - workflows: ["Dart Image"] - -env: - REGISTRY: ghcr.io - -permissions: write-all - -jobs: - build: - name: Build ORT Dotnet 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/dotnet.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 }}/dotnet - tags: | - type=raw,value=${{ env.DOTNET_VERSION }} - - - name: Build ORT Dotnet container - uses: docker/build-push-action@v4 - with: - context: . - target: dotnet - push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} - load: false - build-args: | - DOTNET_VERSION=${{ env.DOTNET_VERSION }} - NUGET_INSPECTOR_VERSION=${{ env.NUGET_INSPECTOR_VERSION }} - tags: | - ${{ steps.meta.outputs.tags }} - ${{ env.REGISTRY }}/${{ github.repository }}/dotnet:latest - labels: ${{ steps.meta.outputs.labels }} - build-contexts: | - ort-base-image=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/base:latest - cache-from: type=gha,scope=ortdotnet - cache-to: type=gha,scope=ortdotnet,mode=max diff --git a/.github/workflows/docker-ort-golang.yml b/.github/workflows/docker-ort-golang.yml deleted file mode 100644 index 2b79707ff5a64..0000000000000 --- a/.github/workflows/docker-ort-golang.yml +++ /dev/null @@ -1,92 +0,0 @@ -# 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: Golang Image - -on: - workflow_dispatch: - push: - branches: - - main - pull_request: - paths: - - '.ortversions/golang.versions' - - '.github/workflows/docker-ort-base.yml' - workflow_run: - workflows: ["Ruby Image"] - types: - - completed - -env: - REGISTRY: ghcr.io - -permissions: write-all - -jobs: - build: - name: Build ORT Golang 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/golang.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 }}/golang - tags: | - type=semver,pattern={{version}},value=${{ env.GO_VERSION }} - - - - name: Build ORT Golang container - uses: docker/build-push-action@v4 - with: - context: . - target: golang - push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} - load: false - build-args: | - GO_DEP_VERSION=${{ env.GO_DEP_VERSION }} - GO_VERSION=${{ env.GO_VERSION }} - tags: | - ${{ steps.meta.outputs.tags }} - ${{ env.REGISTRY }}/${{ github.repository }}/golang:latest - labels: ${{ steps.meta.outputs.labels }} - build-contexts: | - ort-base-image=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/base:latest - cache-from: type=gha,scope=ortgolang - cache-to: type=gha,scope=ortgolang,mode=max diff --git a/.github/workflows/docker-ort-haskell.yml b/.github/workflows/docker-ort-haskell.yml deleted file mode 100644 index 0fdf52cb681a3..0000000000000 --- a/.github/workflows/docker-ort-haskell.yml +++ /dev/null @@ -1,91 +0,0 @@ -# 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: Haskell Image - -on: - workflow_dispatch: - push: - branches: - - main - pull_request: - paths: - - '.ortversions/haskell.versions' - - '.github/workflows/docker-ort-base.yml' - workflow_run: - workflows: ["Dotnet Image"] - types: - - completed - -env: - REGISTRY: ghcr.io - -permissions: write-all - -jobs: - build: - name: Build ORT Haskell 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/haskell.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 }}/haskell - tags: | - type=semver,pattern={{version}},value=${{ env.HASKELL_STACK_VERSION }} - - - - name: Build ORT Haskell container - uses: docker/build-push-action@v4 - with: - context: . - target: haskell - push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} - load: false - build-args: | - HASKELL_STACK_VERSION=${{ env.HASKELL_STACK_VERSION }} - tags: | - ${{ steps.meta.outputs.tags }} - ${{ env.REGISTRY }}/${{ github.repository }}/haskell:latest - labels: ${{ steps.meta.outputs.labels }} - build-contexts: | - ort-base-image=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/base:latest - cache-from: type=gha,scope=orthaskell - cache-to: type=gha,scope=orthaskell,mode=max diff --git a/.github/workflows/docker-ort-nodejs.yml b/.github/workflows/docker-ort-nodejs.yml deleted file mode 100644 index 7429a049d6324..0000000000000 --- a/.github/workflows/docker-ort-nodejs.yml +++ /dev/null @@ -1,93 +0,0 @@ -# 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: NodeJS Image - -on: - workflow_dispatch: - push: - branches: - - main - pull_request: - paths: - - '.ortversions/nodejs.versions' - - '.github/workflows/docker-ort-base.yml' - workflow_run: - workflows: ["Python Image"] - types: - - completed - -env: - REGISTRY: ghcr.io - -permissions: write-all - -jobs: - build: - name: Build ORT NodeJS 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/nodejs.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 }}/nodejs - tags: | - type=raw,value=${{ env.NODEJS_VERSION }} - - - name: Build ORT NodeJS container - uses: docker/build-push-action@v4 - with: - context: . - target: nodejs - push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} - load: false - build-args: | - NODEJS_VERSION=${{ env.NODEJS_VERSION }} - NPM_VERSION=${{ env.NPM_VERSION }} - PNPM_VERSION=${{ env.PNPM_VERSION }} - YARN_VERSION=${{ env.YARN_VERSION }} - tags: | - ${{ steps.meta.outputs.tags }} - ${{ env.REGISTRY }}/${{ github.repository }}/nodejs:latest - labels: ${{ steps.meta.outputs.labels }} - build-contexts: | - ort-base-image=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/base:latest - cache-from: type=gha,scope=ortnodejs - cache-to: type=gha,scope=ortnodejs,mode=max diff --git a/.github/workflows/docker-ort-python.yml b/.github/workflows/docker-ort-python.yml deleted file mode 100644 index 783e3fc4d3bec..0000000000000 --- a/.github/workflows/docker-ort-python.yml +++ /dev/null @@ -1,96 +0,0 @@ -# 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: Python Image - -on: - workflow_dispatch: - push: - branches: - - main - pull_request: - paths: - - '.ortversions/python.versions' - - '.github/workflows/docker-ort-base.yml' - workflow_run: - workflows: ["Base Image"] - types: - - completed - -env: - REGISTRY: ghcr.io - -permissions: write-all - -jobs: - build: - name: Build ORT Python 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/python.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 }}/python - tags: | - type=raw,value=${{ env.PYTHON_VERSION }} - - - name: Build ORT Python container - uses: docker/build-push-action@v4 - with: - context: . - target: python - push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} - load: false - build-args: | - CONAN_VERSION=${{ env.CONAN_VERSION }} - PIPTOOL_VERSION=${{ env.PIPTOOL_VERSION }} - PYENV_GIT_TAG=${{ env.PYENV_GIT_TAG }} - PYTHON_INSPECTOR_VERSION=${{ env.PYTHON_INSPECTOR_VERSION }} - PYTHON_PIPENV_VERSION=${{ env.PYTHON_PIPENV_VERSION }} - PYTHON_POETRY_VERSION=${{ env.PYTHON_POETRY_VERSION }} - PYTHON_VERSION=${{ env.PYTHON_VERSION }} - SCANCODE_VERSION=${{ env.SCANCODE_VERSION }} - tags: | - ${{ steps.meta.outputs.tags }} - ${{ env.REGISTRY }}/${{ github.repository }}/python:${{ env.PYTHON_VERSION }} - ${{ env.REGISTRY }}/${{ github.repository }}/python:latest - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha,scope=ortpython - cache-to: type=gha,scope=ortpython,mode=max diff --git a/.github/workflows/docker-ort-ruby.yml b/.github/workflows/docker-ort-ruby.yml deleted file mode 100644 index b8de1d088dd6e..0000000000000 --- a/.github/workflows/docker-ort-ruby.yml +++ /dev/null @@ -1,93 +0,0 @@ -# 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: Ruby Image - -on: - workflow_dispatch: - push: - branches: - - main - pull_request: - paths: - - '.ortversions/ruby.versions' - - '.github/workflows/docker-ort-base.yml' - workflow_run: - workflows: ["Rust Image"] - types: - - completed - -env: - REGISTRY: ghcr.io - -permissions: write-all - -jobs: - build: - name: Build ORT Ruby 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/ruby.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 }}/ruby - tags: | - type=semver,pattern={{version}},value=${{ env.RUBY_VERSION }} - - - - name: Build ORT Ruby container - if: github.event_name == 'push' - uses: docker/build-push-action@v4 - with: - context: . - target: ruby - push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} - load: false - build-args: | - RUBY_VERSION=${{ env.RUBY_VERSION }} - COCOAPODS_VERSION=${{ env.COCOAPODS_VERSION }} - tags: | - ${{ steps.meta.outputs.tags }} - ${{ env.REGISTRY }}/${{ github.repository }}/ruby:latest - labels: ${{ steps.meta.outputs.labels }} - build-contexts: | - ort-base-image=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/base:latest - cache-from: type=gha,scope=ortruby - cache-to: type=gha,scope=ortruby,mode=max diff --git a/.github/workflows/docker-ort-runtime-ext.yml b/.github/workflows/docker-ort-runtime-ext.yml index 5e067ad073cbe..3d4c6e76f6063 100644 --- a/.github/workflows/docker-ort-runtime-ext.yml +++ b/.github/workflows/docker-ort-runtime-ext.yml @@ -15,19 +15,21 @@ # SPDX-License-Identifier: Apache-2.0 # License-Filename: LICENSE -name: Extended Image +name: MegaDocker Extended Image on: workflow_dispatch: pull_request: - branches: - - main + paths: + - '.versions' push: branches: - main + tags: + - '*' workflow_run: workflows: - - 'Haskell Image' + - 'MegaDocker Runtime Image' types: - completed @@ -37,8 +39,118 @@ env: permissions: write-all jobs: - build: + android_image: + name: Android Image + runs-on: ubuntu-22.04 + steps: + - name: Checkout default branch + uses: actions/checkout@v3 + - name: Set environment variables + run: | + cat .versions >> $GITHUB_ENV + - name: Build Android Image + uses: ./.github/actions/ortdocker + with: + name: android + token: ${{ secrets.GITHUB_TOKEN }} + version: "${{ env.ANDROID_CMD_VERSION }}" + build-args: | + ANDROID_CMD_VERSION=${{ env.ANDROID_CMD_VERSION }} + + dart_image: + name: Dart Image + runs-on: ubuntu-22.04 + steps: + - name: Checkout default branch + uses: actions/checkout@v3 + - name: Set environment variables + run: | + cat .versions >> $GITHUB_ENV + - name: Build Dart Image + uses: ./.github/actions/ortdocker + with: + name: android + token: ${{ secrets.GITHUB_TOKEN }} + version: "${{ env.DART_VERSION }}" + build-args: | + DART_VERSION=${{ env.DART_VERSION }} + + dotnet_image: + name: Dotnet Image + runs-on: ubuntu-22.04 + steps: + - name: Checkout default branch + uses: actions/checkout@v3 + - name: Set environment variables + run: | + cat .versions >> $GITHUB_ENV + - name: Build Dotnet Image + uses: ./.github/actions/ortdocker + with: + name: dotnet + token: ${{ secrets.GITHUB_TOKEN }} + version: "${{ env.DOTNET_VERSION }}" + build-args: | + DOTNET_VERSION=${{ env.DOTNET_VERSION }} + NUGET_INSPECTOR_VERSION=${{ env.NUGET_INSPECTOR_VERSION }} + + haskell_image: + name: Haskell Image + runs-on: ubuntu-22.04 + steps: + - name: Checkout default branch + uses: actions/checkout@v3 + - name: Set environment variables + run: | + cat .versions >> $GITHUB_ENV + - name: Build Haskell Image + uses: ./.github/actions/ortdocker + with: + name: haskell + token: ${{ secrets.GITHUB_TOKEN }} + version: "${{ env.HASKELL_STACK_VERSION }}" + build-args: | + HASKELL_STACK_VERSION=${{ env.HASKELL_STACK_VERSION }} + + scala_image: + name: Scala Image + runs-on: ubuntu-22.04 + steps: + - name: Checkout default branch + uses: actions/checkout@v3 + - name: Set environment variables + run: | + cat .versions >> $GITHUB_ENV + - name: Build Scala Image + uses: ./.github/actions/ortdocker + with: + name: scala + token: ${{ secrets.GITHUB_TOKEN }} + version: "${{ env.SBT_VERSION }}" + build-args: | + SBT_VERSION=${{ env.SBT_VERSION }} + + swift_image: + name: Swift Image + runs-on: ubuntu-22.04 + steps: + - name: Checkout default branch + uses: actions/checkout@v3 + - name: Set environment variables + run: | + cat .versions >> $GITHUB_ENV + - name: Build Swift Image + uses: ./.github/actions/ortdocker + with: + name: swift + token: ${{ secrets.GITHUB_TOKEN }} + version: "${{ env.SWIFT_VERSION }}" + build-args: | + SWIFT_VERSION=${{ env.SWIFT_VERSION }} + + runtime_extended_image: name: Build ORT Extended Image + needs: [ android_image, dart_image, dotnet_image, haskell_image, scala_image, swift_image ] runs-on: ubuntu-22.04 permissions: contents: read diff --git a/.github/workflows/docker-ort-runtime.yml b/.github/workflows/docker-ort-runtime.yml index 76e34226d2680..ae929b1b8c73f 100644 --- a/.github/workflows/docker-ort-runtime.yml +++ b/.github/workflows/docker-ort-runtime.yml @@ -15,21 +15,18 @@ # SPDX-License-Identifier: Apache-2.0 # License-Filename: LICENSE -name: Runtime Image +name: MegaDocker Runtime Image on: workflow_dispatch: pull_request: - branches: - - main + paths: + - '.versions' push: branches: - main - workflow_run: - workflows: - - 'Golang Image' - types: - - completed + tags: + - '*' env: REGISTRY: ghcr.io @@ -37,7 +34,134 @@ env: permissions: write-all jobs: - build: + base_image: + name: Base Image + runs-on: ubuntu-22.04 + steps: + - name: Checkout default branch + uses: actions/checkout@v3 + - name: Set environment variables + run: | + cat .versions >> $GITHUB_ENV + - name: Build Base Image + uses: ./.github/actions/ortdocker + with: + name: base + token: ${{ secrets.GITHUB_TOKEN }} + version: "${{ env.JAVA_VERSION }}-jdk-${{ env.UBUNTU_VERSION }}" + build-args: | + JAVA_VERSION=${{ env.JAVA_VERSION }} + UBUNTU_VERSION=${{ env.UBUNTU_VERSION }} + + nodejs_image: + name: NodeJS Image + needs: [base_image] + runs-on: ubuntu-22.04 + steps: + - name: Checkout default branch + uses: actions/checkout@v3 + - name: Set environment variables + run: | + cat .versions >> $GITHUB_ENV + - name: Build NodeJS Image + uses: ./.github/actions/ortdocker + with: + name: nodejs + token: ${{ secrets.GITHUB_TOKEN }} + version: "${{ env.NODEJS_VERSION }}" + build-args: | + NODEJS_VERSION=${{ env.NODEJS_VERSION }} + NPM_VERSION=${{ env.NPM_VERSION }} + PNPM_VERSION=${{ env.PNPM_VERSION }} + YARN_VERSION=${{ env.YARN_VERSION }} + + python_image: + name: Python Image + needs: [base_image] + runs-on: ubuntu-22.04 + steps: + - name: Checkout default branch + uses: actions/checkout@v3 + - name: Set environment variables + run: | + cat .versions >> $GITHUB_ENV + - name: Build Python Image + uses: ./.github/actions/ortdocker + with: + name: python + token: ${{ secrets.GITHUB_TOKEN }} + version: "${{ env.PYTHON_VERSION }}" + build-args: | + CONAN_VERSION=${{ env.CONAN_VERSION }} + PIPTOOL_VERSION=${{ env.PIPTOOL_VERSION }} + PYENV_GIT_TAG=${{ env.PYENV_GIT_TAG }} + PYTHON_INSPECTOR_VERSION=${{ env.PYTHON_INSPECTOR_VERSION }} + PYTHON_PIPENV_VERSION=${{ env.PYTHON_PIPENV_VERSION }} + PYTHON_POETRY_VERSION=${{ env.PYTHON_POETRY_VERSION }} + PYTHON_VERSION=${{ env.PYTHON_VERSION }} + SCANCODE_VERSION=${{ env.SCANCODE_VERSION }} + + rust_image: + name: Rust Image + needs: [base_image] + runs-on: ubuntu-22.04 + steps: + - name: Checkout default branch + uses: actions/checkout@v3 + - name: Set environment variables + run: | + cat .versions >> $GITHUB_ENV + - name: Build Rust Image + uses: ./.github/actions/ortdocker + with: + name: rust + token: ${{ secrets.GITHUB_TOKEN }} + version: "${{ env.RUST_VERSION }}" + build-args: | + RUST_VERSION=${{ env.RUST_VERSION }} + + ruby_image: + name: Ruby Image + needs: [base_image] + runs-on: ubuntu-22.04 + steps: + - name: Checkout default branch + uses: actions/checkout@v3 + - name: Set environment variables + run: | + cat .versions >> $GITHUB_ENV + - name: Build Ruby Image + uses: ./.github/actions/ortdocker + with: + name: ruby + token: ${{ secrets.GITHUB_TOKEN }} + version: "${{ env.RUBY_VERSION }}" + build-args: | + RUBY_VERSION=${{ env.RUBY_VERSION }} + COCOAPODS_VERSION=${{ env.COCOAPODS_VERSION }} + + golang_image: + name: Golang Image + needs: [base_image] + runs-on: ubuntu-22.04 + steps: + - name: Checkout default branch + uses: actions/checkout@v3 + - name: Set environment variables + run: | + cat .versions >> $GITHUB_ENV + - name: Build Golang Image + uses: ./.github/actions/ortdocker + with: + name: golang + token: ${{ secrets.GITHUB_TOKEN }} + version: "${{ env.GO_VERSION }}" + build-args: | + GO_DEP_VERSION=${{ env.GO_DEP_VERSION }} + GO_VERSION=${{ env.GO_VERSION }} + + runtime_image: + needs: [base_image, nodejs_image, python_image, rust_image, ruby_image, golang_image] name: Build ORT runtime Image runs-on: ubuntu-22.04 permissions: @@ -50,7 +174,7 @@ jobs: - name: Set environment variables run: | - cat .ortversions/nodejs.versions >> $GITHUB_ENV + cat .versions >> $GITHUB_ENV - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -72,11 +196,12 @@ jobs: type=raw,sha,enable=true,format=short - name: Build ORT runtime container + if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} uses: docker/build-push-action@v4 with: context: . target: run - push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} + push: true load: false build-args: | NODEJS_VERSION=${{ env.NODEJS_VERSION }} diff --git a/.github/workflows/docker-ort-rust.yml b/.github/workflows/docker-ort-rust.yml deleted file mode 100644 index 654c122e36594..0000000000000 --- a/.github/workflows/docker-ort-rust.yml +++ /dev/null @@ -1,91 +0,0 @@ -# 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: Rust Image - -on: - workflow_dispatch: - push: - branches: - - main - pull_request: - paths: - - '.ortversions/rust.versions' - - '.github/workflows/docker-ort-base.yml' - workflow_run: - workflows: ["NodeJS Image"] - types: - - completed - -env: - REGISTRY: ghcr.io - -permissions: write-all - -jobs: - build: - name: Build ORT Rust 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/rust.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 }}/rust - tags: | - type=raw,value=${{ env.RUST_VERSION }} - - - - name: Build ORT Rust container - uses: docker/build-push-action@v4 - with: - context: . - target: rust - push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} - load: false - build-args: | - RUST_VERSION=${{ env.RUST_VERSION }} - tags: | - ${{ steps.meta.outputs.tags }} - ${{ env.REGISTRY }}/${{ github.repository }}/rust:latest - labels: ${{ steps.meta.outputs.labels }} - build-contexts: | - ort-base-image=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/base:latest - cache-from: type=gha,scope=ortrust - cache-to: type=gha,scope=ortrust,mode=max diff --git a/.github/workflows/docker-ort-sbt.yml b/.github/workflows/docker-ort-sbt.yml deleted file mode 100644 index b4395ce1ee800..0000000000000 --- a/.github/workflows/docker-ort-sbt.yml +++ /dev/null @@ -1,91 +0,0 @@ -# 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: ["Base 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-scala.yml b/.github/workflows/docker-ort-scala.yml deleted file mode 100644 index f091a60eb3c34..0000000000000 --- a/.github/workflows/docker-ort-scala.yml +++ /dev/null @@ -1,91 +0,0 @@ -# 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 deleted file mode 100644 index eeeac6d0e7c35..0000000000000 --- a/.github/workflows/docker-ort-swift.yml +++ /dev/null @@ -1,91 +0,0 @@ -# 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: Swift Image - -on: - workflow_dispatch: - push: - branches: - - main - pull_request: - paths: - - '.ortversions/swift.versions' - - '.github/workflows/docker-ort-base.yml' - workflow_run: - workflows: ["Android Image"] - types: - - completed - -env: - REGISTRY: ghcr.io - -permissions: write-all - -jobs: - build: - name: Build ORT Swift 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/swift.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 }}/swift - tags: | - type=raw,value=${{ env.SWIFT_VERSION }} - - - - name: Build ORT Swift container - uses: docker/build-push-action@v4 - with: - context: . - target: swift - push: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} - load: false - build-args: | - SWIFT_VERSION=${{ env.SWIFT_VERSION }} - tags: | - ${{ steps.meta.outputs.tags }} - ${{ env.REGISTRY }}/${{ github.repository }}/swift:latest - labels: ${{ steps.meta.outputs.labels }} - build-contexts: | - ort-base-image=docker-image://${{ env.REGISTRY }}/${{ github.repository }}/base:latest - cache-from: type=gha,scope=ortswift - cache-to: type=gha,scope=ortswift,mode=max diff --git a/.ortversions/android.versions b/.ortversions/android.versions deleted file mode 100644 index 6a895889da72a..0000000000000 --- a/.ortversions/android.versions +++ /dev/null @@ -1 +0,0 @@ -ANDROID_CMD_VERSION=9477386 \ No newline at end of file diff --git a/.ortversions/base.versions b/.ortversions/base.versions deleted file mode 100644 index abc7cc3fac010..0000000000000 --- a/.ortversions/base.versions +++ /dev/null @@ -1,2 +0,0 @@ -JAVA_VERSION=17 -UBUNTU_VERSION=jammy diff --git a/.ortversions/dart.versions b/.ortversions/dart.versions deleted file mode 100644 index 31191f8ff697a..0000000000000 --- a/.ortversions/dart.versions +++ /dev/null @@ -1 +0,0 @@ -DART_VERSION=2.18.4 \ No newline at end of file diff --git a/.ortversions/dotnet.versions b/.ortversions/dotnet.versions deleted file mode 100644 index 29159cfc2b228..0000000000000 --- a/.ortversions/dotnet.versions +++ /dev/null @@ -1,2 +0,0 @@ -DOTNET_VERSION=6.0 -NUGET_INSPECTOR_VERSION=0.9.12 diff --git a/.ortversions/golang.versions b/.ortversions/golang.versions deleted file mode 100644 index 8625a6c84e258..0000000000000 --- a/.ortversions/golang.versions +++ /dev/null @@ -1,2 +0,0 @@ -GO_DEP_VERSION=0.5.4 -GO_VERSION=1.20.5 diff --git a/.ortversions/haskell.versions b/.ortversions/haskell.versions deleted file mode 100644 index 9e794390d449f..0000000000000 --- a/.ortversions/haskell.versions +++ /dev/null @@ -1 +0,0 @@ -HASKELL_STACK_VERSION=2.7.5 \ No newline at end of file diff --git a/.ortversions/nodejs.versions b/.ortversions/nodejs.versions deleted file mode 100644 index a278ab79d394e..0000000000000 --- a/.ortversions/nodejs.versions +++ /dev/null @@ -1,5 +0,0 @@ -BOWER_VERSION=1.8.12 -NODEJS_VERSION=18.17.1 -NPM_VERSION=8.15.1 -PNPM_VERSION=7.8.0 -YARN_VERSION=1.22.17 diff --git a/.ortversions/php.versions b/.ortversions/php.versions deleted file mode 100644 index 8114d4c2b7b06..0000000000000 --- a/.ortversions/php.versions +++ /dev/null @@ -1,2 +0,0 @@ -PHP_VERSION=8.1 -COMPOSER_VERSION=2.2 \ No newline at end of file diff --git a/.ortversions/python.versions b/.ortversions/python.versions deleted file mode 100644 index 35b83ed1ce6b0..0000000000000 --- a/.ortversions/python.versions +++ /dev/null @@ -1,8 +0,0 @@ -CONAN_VERSION=1.57.0 -PIPTOOL_VERSION=22.2.2 -PYENV_GIT_TAG=v2.3.25 -PYTHON_INSPECTOR_VERSION=0.9.8 -PYTHON_PIPENV_VERSION=2022.9.24 -PYTHON_POETRY_VERSION=1.6.1 -PYTHON_VERSION=3.10.13 -SCANCODE_VERSION=32.0.6 diff --git a/.ortversions/ruby.versions b/.ortversions/ruby.versions deleted file mode 100644 index 71b8026d9091e..0000000000000 --- a/.ortversions/ruby.versions +++ /dev/null @@ -1,2 +0,0 @@ -COCOAPODS_VERSION=1.11.2 -RUBY_VERSION=3.1.2 diff --git a/.ortversions/rust.versions b/.ortversions/rust.versions deleted file mode 100644 index 2e59451ab4622..0000000000000 --- a/.ortversions/rust.versions +++ /dev/null @@ -1 +0,0 @@ -RUST_VERSION=1.72.0 diff --git a/.ortversions/sbt.versions b/.ortversions/sbt.versions deleted file mode 100644 index 9e0c411cab528..0000000000000 --- a/.ortversions/sbt.versions +++ /dev/null @@ -1 +0,0 @@ -SBT_VERSION=1.6.1 diff --git a/.ortversions/swift.versions b/.ortversions/swift.versions deleted file mode 100644 index 46c2142b6fdb0..0000000000000 --- a/.ortversions/swift.versions +++ /dev/null @@ -1 +0,0 @@ -SWIFT_VERSION=5.8.1 diff --git a/.versions b/.versions new file mode 100644 index 0000000000000..41c33d6495d3e --- /dev/null +++ b/.versions @@ -0,0 +1,29 @@ +ANDROID_CMD_VERSION=9477386 +BOWER_VERSION=1.8.12 +COCOAPODS_VERSION=1.11.2 +COMPOSER_VERSION=2.2 +CONAN_VERSION=1.57.0 +DART_VERSION=2.18.4 +DOTNET_VERSION=6.0 +GO_DEP_VERSION=0.5.4 +GO_VERSION=1.20.5 +HASKELL_STACK_VERSION=2.7.5 +JAVA_VERSION=17 +NODEJS_VERSION=18.17.1 +NPM_VERSION=8.15.1 +NUGET_INSPECTOR_VERSION=0.9.12 +PHP_VERSION=8.1 +PIPTOOL_VERSION=22.2.2 +PNPM_VERSION=7.8.0 +PYENV_GIT_TAG=v2.3.25 +PYTHON_INSPECTOR_VERSION=0.9.8 +PYTHON_PIPENV_VERSION=2022.9.24 +PYTHON_POETRY_VERSION=1.6.1 +PYTHON_VERSION=3.10.13 +RUBY_VERSION=3.1.2 +RUST_VERSION=1.72.0 +SBT_VERSION=1.6.1 +SCANCODE_VERSION=32.0.6 +SWIFT_VERSION=5.8.1 +UBUNTU_VERSION=jammy +YARN_VERSION=1.22.17 diff --git a/Dockerfile b/Dockerfile index 9234dc5b3a4b7..a98de4635e182 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,7 +22,7 @@ ARG JAVA_VERSION=17 ARG UBUNTU_VERSION=jammy # Use OpenJDK Eclipe Temurin Ubuntu LTS -FROM eclipse-temurin:$JAVA_VERSION-jdk-$UBUNTU_VERSION as ort-base-image +FROM eclipse-temurin:$JAVA_VERSION-jdk-$UBUNTU_VERSION as base ENV LANG=en_US.UTF-8 ENV LANGUAGE=en_US:en @@ -116,7 +116,7 @@ ENTRYPOINT [ "/bin/bash" ] #------------------------------------------------------------------------ # PYTHON - Build Python as a separate component with pyenv -FROM ort-base-image AS pythonbuild +FROM base AS pythonbuild SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -174,7 +174,7 @@ COPY --from=pythonbuild /opt/python /opt/python #------------------------------------------------------------------------ # NODEJS - Build NodeJS as a separate component with nvm -FROM ort-base-image AS nodejsbuild +FROM base AS nodejsbuild ARG BOWER_VERSION=1.8.12 ARG NODEJS_VERSION=18.14.2 @@ -197,7 +197,7 @@ COPY --from=nodejsbuild /opt/nvm /opt/nvm #------------------------------------------------------------------------ # RUBY - Build Ruby as a separate component with rbenv -FROM ort-base-image AS rubybuild +FROM base AS rubybuild # hadolint ignore=DL3004 RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ @@ -232,7 +232,7 @@ COPY --from=rubybuild /opt/rbenv /opt/rbenv #------------------------------------------------------------------------ # RUST - Build as a separate component -FROM ort-base-image AS rustbuild +FROM base AS rustbuild ARG RUST_VERSION=1.72.0 @@ -246,7 +246,7 @@ COPY --from=rustbuild /opt/rust /opt/rust #------------------------------------------------------------------------ # GOLANG - Build as a separate component -FROM ort-base-image AS gobuild +FROM base AS gobuild ARG GO_DEP_VERSION=0.5.4 ARG GO_VERSION=1.20.5 @@ -263,7 +263,7 @@ COPY --from=gobuild /opt/go /opt/go #------------------------------------------------------------------------ # HASKELL STACK -FROM ort-base-image AS haskellbuild +FROM base AS haskellbuild RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ @@ -284,7 +284,7 @@ COPY --from=haskellbuild /opt/haskell /opt/haskell #------------------------------------------------------------------------ # REPO / ANDROID SDK -FROM ort-base-image AS androidbuild +FROM base AS androidbuild RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ @@ -316,7 +316,7 @@ COPY --from=androidbuild /opt/android-sdk /opt/android-sdk #------------------------------------------------------------------------ # Dart -FROM ort-base-image AS dartbuild +FROM base AS dartbuild ARG DART_VERSION=2.18.4 WORKDIR /opt/ @@ -336,7 +336,7 @@ COPY --from=dartbuild /opt/dart-sdk /opt/dart-sdk #------------------------------------------------------------------------ # SBT -FROM ort-base-image AS sbtbuild +FROM base AS scalabuild ARG SBT_VERSION=1.6.1 @@ -345,12 +345,12 @@ ENV PATH=$PATH:$SBT_HOME/bin RUN curl -L https://github.com/sbt/sbt/releases/download/v$SBT_VERSION/sbt-$SBT_VERSION.tgz | tar -C /opt -xz -FROM scratch AS sbt -COPY --from=sbtbuild /opt/sbt /opt/sbt +FROM scratch AS scala +COPY --from=scalabuild /opt/sbt /opt/sbt #------------------------------------------------------------------------ # SWIFT -FROM ort-base-image AS swiftbuild +FROM base AS swiftbuild ARG SWIFT_VERSION=5.8.1 @@ -372,7 +372,7 @@ COPY --from=swiftbuild /opt/swift /opt/swift #------------------------------------------------------------------------ # DOTNET -FROM ort-base-image AS dotnetbuild +FROM base AS dotnetbuild ARG DOTNET_VERSION=6.0 ARG NUGET_INSPECTOR_VERSION=0.9.12 @@ -401,7 +401,7 @@ COPY --from=dotnetbuild /opt/dotnet /opt/dotnet #------------------------------------------------------------------------ # ORT -FROM ort-base-image as ortbuild +FROM base as ortbuild # Set this to the version ORT should report. ARG ORT_VERSION="DOCKER-SNAPSHOT" @@ -429,7 +429,7 @@ COPY --from=ortbuild /opt/ort /opt/ort #------------------------------------------------------------------------ # Main Minimal Runtime container -FROM ort-base-image as run +FROM base as run # Remove ort build scripts RUN [ -d /etc/scripts ] && sudo rm -rf /etc/scripts @@ -486,6 +486,6 @@ USER $USER WORKDIR $HOME # Ensure that the ORT data directory exists to be able to mount the config into it with correct permissions. -RUN mkdir -p "$HOMEDIR/.ort" +RUN mkdir -p "$HOME/.ort" ENTRYPOINT ["/opt/ort/bin/ort"] diff --git a/scripts/docker_build.sh b/scripts/docker_build.sh index 3bf5622a4b4a1..0c357107c8e7c 100755 --- a/scripts/docker_build.sh +++ b/scripts/docker_build.sh @@ -25,6 +25,9 @@ DOCKER_IMAGE_ROOT="${DOCKER_IMAGE_ROOT:-ghcr.io/oss-review-toolkit}" echo "Setting ORT_VERSION to $GIT_REVISION." +# shellcheck disable=SC1091 +. .versions + # --------------------------- # image_build function # Usage ( position paramenters): @@ -46,21 +49,16 @@ image_build() { --target "$target" \ --tag "${DOCKER_IMAGE_ROOT}/$name:$version" \ --tag "${DOCKER_IMAGE_ROOT}/$name:latest" \ - --build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \ "$@" . } # Base -# shellcheck disable=SC1091 -. .ortversions/base.versions -image_build ort-base-image base "${JAVA_VERSION}-jdk-${UBUNTU_VERSION}" \ +image_build base base "${JAVA_VERSION}-jdk-${UBUNTU_VERSION}" \ --build-arg UBUNTU_VERSION="$UBUNTU_VERSION" \ --build-arg JAVA_VERSION="$JAVA_VERSION" \ "$@" # Python -# shellcheck disable=SC1091 -. .ortversions/python.versions image_build python python "$PYTHON_VERSION" \ --build-arg PYTHON_VERSION="$PYTHON_VERSION" \ --build-arg CONAN_VERSION="$CONAN_VERSION" \ @@ -69,45 +67,37 @@ image_build python python "$PYTHON_VERSION" \ --build-arg PYTHON_POETRY_VERSION="$PYTHON_POETRY_VERSION" \ --build-arg PIPTOOL_VERSION="$PIPTOOL_VERSION" \ --build-arg SCANCODE_VERSION="$SCANCODE_VERSION" \ + --build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \ "$@" # Nodejs -# shellcheck disable=SC1091 -. .ortversions/nodejs.versions image_build nodejs nodejs "$NODEJS_VERSION" \ --build-arg NODEJS_VERSION="$NODEJS_VERSION" \ --build-arg BOWER_VERSION="$BOWER_VERSION" \ --build-arg NPM_VERSION="$NPM_VERSION" \ --build-arg PNPM_VERSION="$PNPM_VERSION" \ --build-arg YARN_VERSION="$YARN_VERSION" \ + --build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \ "$@" # Rust -# shellcheck disable=SC1091 -. .ortversions/rust.versions image_build rust rust "$RUST_VERSION" \ --build-arg RUST_VERSION="$RUST_VERSION" \ + --build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \ "$@" # Ruby -# shellcheck disable=SC1091 -. .ortversions/ruby.versions image_build ruby ruby "$RUBY_VERSION" \ --build-arg RUBY_VERSION="$RUBY_VERSION" \ --build-arg COCOAPODS_VERSION="$COCOAPODS_VERSION" \ + --build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \ "$@" # Golang -# shellcheck disable=SC1091 -. .ortversions/golang.versions image_build golang golang "$GO_VERSION" \ --build-arg GO_VERSION="$GO_VERSION" \ --build-arg GO_DEP_VERSION="$GO_DEP_VERSION" \ - "$@" - -# Ort -image_build ortbin ortbin "$GIT_REVISION" \ - --build-arg ORT_VERSION="$GIT_REVISION" \ + --build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \ "$@" # Runtime ORT image @@ -118,7 +108,7 @@ image_build run ort "$GIT_REVISION" \ --build-context "rust=docker-image://${DOCKER_IMAGE_ROOT}/rust:latest" \ --build-context "golang=docker-image://${DOCKER_IMAGE_ROOT}/golang:latest" \ --build-context "ruby=docker-image://${DOCKER_IMAGE_ROOT}/ruby:latest" \ - --build-context "ortbin=docker-image://${DOCKER_IMAGE_ROOT}/ortbin:latest" \ + --build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \ "$@" # Build adjacent language containers if ALL_LANGUAGES is set. @@ -126,45 +116,40 @@ image_build run ort "$GIT_REVISION" \ # Android # shellcheck disable=SC1091 -. .ortversions/android.versions image_build android android "$ANDROID_CMD_VERSION" \ --build-arg ANDROID_CMD_VERSION="$ANDROID_CMD_VERSION" \ + --build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \ "$@" # Swift -# shellcheck disable=SC1091 -. .ortversions/swift.versions image_build swift swift "$SWIFT_VERSION" \ --build-arg SWIFT_VERSION="$SWIFT_VERSION" \ + --build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \ "$@" # SBT -# shellcheck disable=SC1091 -. .ortversions/sbt.versions image_build sbt sbt "$SBT_VERSION" \ --build-arg SBT_VERSION="$SBT_VERSION" \ + --build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \ "$@" # Dart -# shellcheck disable=SC1091 -. .ortversions/dart.versions image_build dart dart "$DART_VERSION" \ --build-arg DART_VERSION="$DART_VERSION" \ + --build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \ "$@" # Dotnet -# shellcheck disable=SC1091 -. .ortversions/dotnet.versions image_build dotnet dotnet "$DOTNET_VERSION" \ --build-arg DOTNET_VERSION="$DOTNET_VERSION" \ --build-arg NUGET_INSPECTOR_VERSION="$NUGET_INSPECTOR_VERSION" \ + --build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \ "$@" # Haskell -# shellcheck disable=SC1091 -. .ortversions/haskell.versions image_build haskell haskell "$HASKELL_STACK_VERSION" \ --build-arg HASKELL_STACK_VERSION="$HASKELL_STACK_VERSION" \ + --build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \ "$@" # Runtime Extended ORT image