Skip to content

Commit

Permalink
Use /etc/profile.d instead of bash_bootstrap.sh
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Huber <[email protected]>
  • Loading branch information
maxhbr authored and Helio Chissini de Castro committed Dec 2, 2021
1 parent c800dc5 commit 3ce67da
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 38 deletions.
36 changes: 17 additions & 19 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ RUN --mount=type=cache,target=/var/cache/apt apt-get update \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*

# Prepare build components to install their modules
RUN mkdir -p /etc/ort/bash_modules

#------------------------------------------------------------------------
# Build ort as a separate component

Expand Down Expand Up @@ -125,7 +122,7 @@ RUN pip install -U \
virtualenv=="${PYTHON_VIRTUALENV_VERSION}" \
wheel

COPY docker/python.sh /etc/ort/bash_modules
COPY docker/python.sh /etc/profile.d

#------------------------------------------------------------------------
# RUBY - Build Ruby as a separate component with rbenv
Expand Down Expand Up @@ -153,7 +150,7 @@ RUN curl -ksSL https://github.com/CocoaPods/CocoaPods/archive/9461b346aeb8cba6df
) \
&& rm -rf CocoaPods-9461b346aeb8cba6df71fd4e71661688138ec21b

COPY docker/ruby.sh /etc/ort/bash_modules
COPY docker/ruby.sh /etc/profile.d

#------------------------------------------------------------------------
# NODEJS - Build NodeJS as a separate component with nvm
Expand All @@ -170,7 +167,7 @@ RUN git clone --depth 1 https://github.com/nvm-sh/nvm.git /opt/nodejs
RUN . $NVM_DIR/nvm.sh && nvm install "${NODEJS_VERSION}"
RUN . $NVM_DIR/nvm.sh \
&& npm install --global npm@$NPM_VERSION bower@$BOWER_VERSION yarn@$YARN_VERSION
COPY docker/nodejs.sh /etc/ort/bash_modules
COPY docker/nodejs.sh /etc/profile.d

#------------------------------------------------------------------------
# GOLANG - Build as a separate component
Expand All @@ -183,7 +180,7 @@ RUN curl -L https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | tar -C
ENV PATH=/opt/go/bin:$PATH
RUN go version
RUN curl -ksS https://raw.githubusercontent.com/golang/dep/v$GO_DEP_VERSION/install.sh | bash
RUN echo "add_local_path /opt/go/bin:$PATH" > /etc/ort/bash_modules/go.sh
RUN echo "add_local_path /opt/go/bin:\$PATH" > /etc/profile.d/go.sh

#------------------------------------------------------------------------
# HASKELL STACK
Expand Down Expand Up @@ -212,7 +209,7 @@ RUN curl -Os https://dl.google.com/android/repository/commandlinetools-linux-${A
fi \
&& yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager $SDK_MANAGER_PROXY_OPTIONS \
--sdk_root=$ANDROID_HOME "platform-tools" "cmdline-tools;latest"
COPY docker/android.sh /etc/ort/bash_modules
COPY docker/android.sh /etc/profile.d

#------------------------------------------------------------------------
# SCANCODE - Build ScanCode as a separate component
Expand All @@ -233,36 +230,31 @@ RUN mkdir -p /opt/scancode \
# Main container
FROM eclipse-temurin:11-jre

# ORT
COPY --from=ortbuild /opt/ort /opt/ort
COPY docker/bash_bootstrap.sh /etc/ort/bash_bootstrap.sh
COPY docker/ort-wrapper.sh /usr/bin/ort
COPY docker/ort-wrapper.sh /usr/bin/orth
RUN chmod 755 /usr/bin/ort
COPY docker/00-add_local_path.sh /etc/profile.d/

# Python
COPY --from=pythonbuild /opt/python /opt/python
COPY --from=pythonbuild /etc/ort/bash_modules/python.sh /etc/ort/bash_modules/
COPY --from=pythonbuild /etc/profile.d/python.sh /etc/profile.d/

# Ruby
COPY --from=rubybuild /opt/rbenv /opt/rbenv
COPY --from=rubybuild /etc/ort/bash_modules/ruby.sh /etc/ort/bash_modules/
COPY --from=rubybuild /etc/profile.d/ruby.sh /etc/profile.d/

# NodeJS
COPY --from=nodebuild /opt/nodejs /opt/nodejs
COPY --from=nodebuild /etc/ort/bash_modules/nodejs.sh /etc/ort/bash_modules/
COPY --from=nodebuild /etc/profile.d/nodejs.sh /etc/profile.d/

# Golang
COPY --from=gobuild /opt/go /opt/go/
COPY --from=gobuild /etc/ort/bash_modules/go.sh /etc/ort/bash_modules/
COPY --from=gobuild /etc/profile.d/go.sh /etc/profile.d/

# Haskell
COPY --from=haskellbuild /usr/bin/stack /usr/bin

# Repo and Android
COPY --from=androidbuild /usr/bin/repo /usr/bin/
COPY --from=androidbuild /opt/android-sdk /opt/android-sdk
COPY --from=androidbuild /etc/ort/bash_modules/android.sh /etc/ort/bash_modules/
COPY --from=androidbuild /etc/profile.d/android.sh /etc/profile.d/

# ScanCode
COPY --from=scancodebuild /opt/scancode /opt/scancode
Expand Down Expand Up @@ -306,5 +298,11 @@ RUN --mount=type=cache,target=/var/cache/apt apt-get update \
subversion \
&& rm -rf /var/lib/apt/lists/*

# ORT
COPY --from=ortbuild /opt/ort /opt/ort
COPY docker/ort-wrapper.sh /usr/bin/ort
COPY docker/ort-wrapper.sh /usr/bin/orth
RUN chmod 755 /usr/bin/ort

ENTRYPOINT ["/usr/bin/ort"]

11 changes: 1 addition & 10 deletions docker/bash_bootstrap.sh → docker/00-add_local_path.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
# SPDX-License-Identifier: Apache-2.0
# License-Filename: LICENSE

# We will parse the necessary shells modules for each language
# independently

set -e

# Global functions
Expand All @@ -30,11 +27,5 @@ add_local_path () {
esac;
}

[ -z "$(ls -A /etc/ort/bash_modules)" ] && return

# Source all resources
for resource in /etc/ort/bash_modules/*.sh; do
# shellcheck disable=SC1090
source "${resource}"
done
export -f add_local_path

11 changes: 2 additions & 9 deletions docker/ort-wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash -l

# Copyright (C) 2021 BMW CarIT GmbH
#
Expand All @@ -17,11 +17,4 @@
# SPDX-License-Identifier: Apache-2.0
# License-Filename: LICENSE

set -e

script=$(basename "$0")

# shellcheck disable=SC1091
source /etc/ort/bash_bootstrap.sh

exec /opt/ort/bin/"$script" "$@"
exec /opt/ort/bin/"$(basename "$0")" "$@"

0 comments on commit 3ce67da

Please sign in to comment.