Skip to content

Commit

Permalink
feat(docker): Use jobs over workflow dependency
Browse files Browse the repository at this point in the history
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 is changed, but not
  publishing images on the registry.
- On push or workflow_dispatch, publishing to defined registry.

Signed-off-by: Helio Chissini de Castro <[email protected]>
  • Loading branch information
heliocastro committed Sep 26, 2023
1 parent 0c8e6f0 commit c900e85
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 37 deletions.
4 changes: 2 additions & 2 deletions Dockerfile-extended
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
FROM ort

# Copyright (C) 2023 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>)
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,6 +15,8 @@ FROM ort
# SPDX-License-Identifier: Apache-2.0
# License-Filename: LICENSE

FROM ort

# Repo and Android
ENV ANDROID_HOME=/opt/android-sdk
ENV ANDROID_USER_HOME=$HOME/.android
Expand Down
72 changes: 37 additions & 35 deletions scripts/docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,115 +53,117 @@ image_build() {
}

# Base
image_build base base "${JAVA_VERSION}-jdk-${UBUNTU_VERSION}" \
image_build base ort/base "${JAVA_VERSION}-jdk-${UBUNTU_VERSION}" \
--build-arg UBUNTU_VERSION="$UBUNTU_VERSION" \
--build-arg JAVA_VERSION="$JAVA_VERSION" \
"$@"

# Python
image_build python python "$PYTHON_VERSION" \
image_build python ort/python "$PYTHON_VERSION" \
--build-arg PYTHON_VERSION="$PYTHON_VERSION" \
--build-arg CONAN_VERSION="$CONAN_VERSION" \
--build-arg PYTHON_INSPECTOR_VERSION="$PYTHON_INSPECTOR_VERSION" \
--build-arg PYTHON_PIPENV_VERSION="$PYTHON_PIPENV_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" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/ort/base:latest" \
"$@"

# Nodejs
image_build nodejs nodejs "$NODEJS_VERSION" \
image_build nodejs ort/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" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/ort/base:latest" \
"$@"

# Rust
image_build rust rust "$RUST_VERSION" \
image_build rust ort/rust "$RUST_VERSION" \
--build-arg RUST_VERSION="$RUST_VERSION" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/ort/base:latest" \
"$@"

# Ruby
image_build ruby ruby "$RUBY_VERSION" \
image_build ruby ort/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" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/ort/base:latest" \
"$@"

# Golang
image_build golang golang "$GO_VERSION" \
image_build golang ort/golang "$GO_VERSION" \
--build-arg GO_VERSION="$GO_VERSION" \
--build-arg GO_DEP_VERSION="$GO_DEP_VERSION" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/ort/base:latest" \
"$@"

# Runtime ORT image
image_build run ort "$GIT_REVISION" \
--build-context "python=docker-image://${DOCKER_IMAGE_ROOT}/python:latest" \
--build-arg NODEJS_VERSION="$NODEJS_VERSION" \
--build-context "nodejs=docker-image://${DOCKER_IMAGE_ROOT}/nodejs:latest" \
--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 "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \
--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" \
--build-context "rust=docker-image://${DOCKER_IMAGE_ROOT}/ort/rust:latest" \
--build-context "golang=docker-image://${DOCKER_IMAGE_ROOT}/ort/golang:latest" \
--build-context "ruby=docker-image://${DOCKER_IMAGE_ROOT}/ort/ruby:latest" \
"$@"

# Build adjacent language containers if ALL_LANGUAGES is set.
[ -z "$ALL_LANGUAGES" ] && exit 0

# Android
# shellcheck disable=SC1091
image_build android android "$ANDROID_CMD_VERSION" \
image_build android ort/android "$ANDROID_CMD_VERSION" \
--build-arg ANDROID_CMD_VERSION="$ANDROID_CMD_VERSION" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/ort/base:latest" \
"$@"

# Swift
image_build swift swift "$SWIFT_VERSION" \
image_build swift ort/swift "$SWIFT_VERSION" \
--build-arg SWIFT_VERSION="$SWIFT_VERSION" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/ort/base:latest" \
"$@"

# SBT
image_build sbt sbt "$SBT_VERSION" \
image_build scala ort/scala "$SBT_VERSION" \
--build-arg SBT_VERSION="$SBT_VERSION" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/ort/base:latest" \
"$@"

# Dart
image_build dart dart "$DART_VERSION" \
image_build dart ort/dart "$DART_VERSION" \
--build-arg DART_VERSION="$DART_VERSION" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/ort/base:latest" \
"$@"

# Dotnet
image_build dotnet dotnet "$DOTNET_VERSION" \
image_build dotnet ort/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" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/ort/base:latest" \
"$@"

# Haskell
image_build haskell haskell "$HASKELL_STACK_VERSION" \
image_build haskell ort/haskell "$HASKELL_STACK_VERSION" \
--build-arg HASKELL_STACK_VERSION="$HASKELL_STACK_VERSION" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/base:latest" \
--build-context "base=docker-image://${DOCKER_IMAGE_ROOT}/ort/base:latest" \
"$@"

# 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" \
--build-context "ort=docker-image://${DOCKER_IMAGE_ROOT}/ort:latest" \
--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" \
--build-context "android=docker-image://${DOCKER_IMAGE_ROOT}/ort/android:latest" \
--build-context "dart=docker-image://${DOCKER_IMAGE_ROOT}/ort/dart:latest" \
--build-context "haskell=docker-image://${DOCKER_IMAGE_ROOT}/ort/haskell:latest" \
--build-context "scala=docker-image://${DOCKER_IMAGE_ROOT}/ort/scala:latest" \
"$@" .

0 comments on commit c900e85

Please sign in to comment.