Skip to content

Commit

Permalink
feat(docker): Promote rust, ruby and golang to first party
Browse files Browse the repository at this point in the history
Signed-off-by: Helio Chissini de Castro <heliocastro@gmail.com>
  • Loading branch information
heliocastro committed Sep 7, 2023
1 parent 5ea3b16 commit e01e88b
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 99 deletions.
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions scripts/custom_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -33,17 +33,17 @@ dockerfile_template="FROM ghcr.io/oss-review-toolkit/ort\n"
output_file="Dockerfile.custom"

function usage() {
echo "Usage: $0 -components <component1> [<component2> ...] -output <output_file>"
echo "Usage: $0 -c <component1> [<component2> ...] -output <output_file>"
echo "Options:"
echo " -components <component1> [<component2> ...]: List of language components to include in the Dockerfile: ${valid_components[*]}"
echo " -output <output_file>: Output file for the generated Dockerfile"
echo " -c <component1> [<component2> ...]: List of language components to include in the Dockerfile: ${valid_components[*]}"
echo " -output <output_file>: 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
Expand Down
49 changes: 26 additions & 23 deletions scripts/docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
22 changes: 0 additions & 22 deletions scripts/docker_snippets/golang.snippet

This file was deleted.

23 changes: 0 additions & 23 deletions scripts/docker_snippets/ruby.snippet

This file was deleted.

26 changes: 0 additions & 26 deletions scripts/docker_snippets/rust.snippet

This file was deleted.

0 comments on commit e01e88b

Please sign in to comment.