diff --git a/Dockerfile b/Dockerfile index ef13a533a8049..3be3e4ab36da7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -457,6 +457,27 @@ ENV PATH=$PATH:$NVM_DIR/versions/node/v$NODEJS_VERSION/bin COPY --from=nodejs --chown=$USER:$USER $NVM_DIR $NVM_DIR RUN syft $NVM_DIR -o spdx-json --file /usr/share/doc/ort/ort-nodejs.spdx.json +# Rust +ENV RUST_HOME=/opt/rust +ENV CARGO_HOME=$RUST_HOME/cargo +ENV RUSTUP_HOME=$RUST_HOME/rustup +ENV PATH=$PATH:$CARGO_HOME/bin:$RUSTUP_HOME/bin +COPY --from=ghcr.io/oss-review-toolkit/rust --chown=$USER:$USER $RUST_HOME $RUST_HOME +RUN chmod o+rwx $CARGO_HOME +RUN syft $RUST_HOME -o spdx-json --file /usr/share/doc/ort/ort-rust.spdx.json + +# Golang +ENV PATH=$PATH:/opt/go/bin +COPY --from=ghcr.io/oss-review-toolkit/golang --chown=$USER:$USER /opt/go /opt/go +RUN syft /opt/go -o spdx-json --file /usr/share/doc/ort/ort-golang.spdx.json + +# Ruby +ENV RBENV_ROOT=/opt/rbenv/ +ENV GEM_HOME=/var/tmp/gem +ENV PATH=$PATH:$RBENV_ROOT/bin:$RBENV_ROOT/shims:$RBENV_ROOT/plugins/ruby-install/bin +COPY --from=ghcr.io/oss-review-toolkit/ruby --chown=$USER:$USER $RBENV_ROOT $RBENV_ROOT +RUN syft $RBENV_ROOT -o spdx-json --file /usr/share/doc/ort/ort-ruby.spdx.json + # ORT COPY --from=ortbin --chown=$USER:$USER /opt/ort /opt/ort ENV PATH=$PATH:/opt/ort/bin diff --git a/scripts/custom_docker.sh b/scripts/custom_docker.sh index 8cec94456c8da..f0d1ca575218f 100755 --- a/scripts/custom_docker.sh +++ b/scripts/custom_docker.sh @@ -24,7 +24,7 @@ SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) DOCKER_IMAGE_ROOT="${DOCKER_IMAGE_ROOT:-ghcr.io/oss-review-toolkit}" # Define the list of valid components -valid_components=("rust" "ruby" "android" "golang" "swift" "sbt" "dart" "dotnet" "php") +valid_components=("android" "swift" "sbt" "dart" "dotnet" "php" "haskell") # Define the Dockerfile template dockerfile_template="FROM ghcr.io/oss-review-toolkit/ort\n" @@ -33,17 +33,17 @@ dockerfile_template="FROM ghcr.io/oss-review-toolkit/ort\n" output_file="Dockerfile.custom" function usage() { - echo "Usage: $0 -components [ ...] -output " + echo "Usage: $0 -c [ ...] -output " echo "Options:" - echo " -components [ ...]: List of language components to include in the Dockerfile: ${valid_components[*]}" - echo " -output : Output file for the generated Dockerfile" + echo " -c [ ...]: List of language components to include in the Dockerfile: ${valid_components[*]}" + echo " -output : Output file for the generated Dockerfile, Defaults to Dockerfile.custom." echo " -h: Display this help message" } # Parse the command-line options while [[ $# -gt 0 ]]; do case "$1" in - -components) + -c) shift components=("$@") break diff --git a/scripts/docker_build.sh b/scripts/docker_build.sh index 931e2b32e6632..66154ad15bf4d 100755 --- a/scripts/docker_build.sh +++ b/scripts/docker_build.sh @@ -82,22 +82,6 @@ image_build nodejs nodejs "$NODEJS_VERSION" \ --build-arg YARN_VERSION="$YARN_VERSION" \ "$@" -# Ort -image_build ortbin ortbin "$GIT_REVISION" \ - --build-arg ORT_VERSION="$GIT_REVISION" \ - "$@" - -# 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 "ortbin=docker-image://${DOCKER_IMAGE_ROOT}/ortbin:latest" \ - "$@" - -# Build adjacent language containers if ALL_LANGUAGES is set. -[ -z "$ALL_LANGUAGES" ] && exit 0 - # Rust # shellcheck disable=SC1091 . .ortversions/rust.versions @@ -113,13 +97,6 @@ image_build ruby ruby "$RUBY_VERSION" \ --build-arg COCOAPODS_VERSION="$COCOAPODS_VERSION" \ "$@" -# Android -# shellcheck disable=SC1091 -. .ortversions/android.versions -image_build android android "$ANDROID_CMD_VERSION" \ - --build-arg ANDROID_CMD_VERSION="$ANDROID_CMD_VERSION" \ - "$@" - # Golang # shellcheck disable=SC1091 . .ortversions/golang.versions @@ -128,6 +105,32 @@ image_build golang golang "$GO_VERSION" \ --build-arg GO_DEP_VERSION="$GO_DEP_VERSION" \ "$@" +# Ort +image_build ortbin ortbin "$GIT_REVISION" \ + --build-arg ORT_VERSION="$GIT_REVISION" \ + "$@" + +# 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 "ortbin=docker-image://${DOCKER_IMAGE_ROOT}/ortbin:latest" \ + "$@" + +# Build adjacent language containers if ALL_LANGUAGES is set. +[ -z "$ALL_LANGUAGES" ] && exit 0 + +# Android +# shellcheck disable=SC1091 +. .ortversions/android.versions +image_build android android "$ANDROID_CMD_VERSION" \ + --build-arg ANDROID_CMD_VERSION="$ANDROID_CMD_VERSION" \ + "$@" + # Swift # shellcheck disable=SC1091 . .ortversions/swift.versions diff --git a/scripts/docker_snippets/golang.snippet b/scripts/docker_snippets/golang.snippet deleted file mode 100644 index 09cf6443e4079..0000000000000 --- a/scripts/docker_snippets/golang.snippet +++ /dev/null @@ -1,22 +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 - - -ENV PATH=$PATH:/opt/go/bin -COPY --from=ghcr.io/oss-review-toolkit/golang --chown=$USER:$USER /opt/go /opt/go - -RUN syft /opt/go -o spdx-json --file /usr/share/doc/ort/ort-golang.spdx.json diff --git a/scripts/docker_snippets/ruby.snippet b/scripts/docker_snippets/ruby.snippet deleted file mode 100644 index 9386cb9f39cfe..0000000000000 --- a/scripts/docker_snippets/ruby.snippet +++ /dev/null @@ -1,23 +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 - -ENV RBENV_ROOT=/opt/rbenv/ -ENV GEM_HOME=/var/tmp/gem -ENV PATH=$PATH:$RBENV_ROOT/bin:$RBENV_ROOT/shims:$RBENV_ROOT/plugins/ruby-install/bin -COPY --from=ghcr.io/oss-review-toolkit/ruby --chown=$USER:$USER $RBENV_ROOT $RBENV_ROOT - -RUN syft $RBENV_ROOT -o spdx-json --file /usr/share/doc/ort/ort-ruby.spdx.json diff --git a/scripts/docker_snippets/rust.snippet b/scripts/docker_snippets/rust.snippet deleted file mode 100644 index c43706fd27207..0000000000000 --- a/scripts/docker_snippets/rust.snippet +++ /dev/null @@ -1,26 +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 - -# Rust -ENV RUST_HOME=/opt/rust -ENV CARGO_HOME=$RUST_HOME/cargo -ENV RUSTUP_HOME=$RUST_HOME/rustup -ENV PATH=$PATH:$CARGO_HOME/bin:$RUSTUP_HOME/bin -COPY --from=ghcr.io/oss-review-toolkit/rust --chown=$USER:$USER $RUST_HOME $RUST_HOME -RUN chmod o+rwx $CARGO_HOME - -RUN syft $RUST_HOME -o spdx-json --file /usr/share/doc/ort/ort-rust.spdx.json