diff --git a/Dockerfile b/Dockerfile index 76d30087975d4..cdacea16f2f03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,7 @@ # Copyright (C) 2020 Bosch Software Innovations GmbH # Copyright (C) 2021 Bosch.IO GmbH # Copyright (C) 2021 Alliander N.V. +# Copyright (C) 2021 Helio Chissini de Castro # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,160 +20,302 @@ # SPDX-License-Identifier: Apache-2.0 # License-Filename: LICENSE -FROM adoptopenjdk/openjdk11:alpine-slim AS build +#------------------------------------------------------------------------ +# build base for main +FROM adoptopenjdk/openjdk11:ubuntu-slim AS base -ARG ORT_VERSION="DOCKER-SNAPSHOT" +# Set shell for bash and default pipefail +SHELL ["/bin/bash", "-o", "pipefail", "-c"] -# Apk install commands. -RUN apk add --no-cache \ - # Required for Node.js to build the reporter-web-app. - libstdc++ \ - # Required to allow to download via a proxy with a self-signed certificate. +# Basic intro +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y --no-install-recommends \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ ca-certificates \ - coreutils \ - openssl + curl \ + gnupg -COPY . /usr/local/src/ort +#------------------------------------------------------------------------ +# External repositories for SBT +RUN echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | tee /etc/apt/sources.list.d/sbt.list +RUN echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | tee /etc/apt/sources.list.d/sbt_old.list +ENV KEYURL=https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823 +RUN curl -ksS "$KEYURL" | gpg --dearmor | tee "/etc/apt/trusted.gpg.d/scala_ubuntu.gpg" > /dev/null +ARG SBT_VERSION=1.3.8 -WORKDIR /usr/local/src/ort +#------------------------------------------------------------------------ +# External repositories for Dart +ENV REPOURL="https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list" +RUN curl -ksS "$REPOURL" | tee "/etc/apt/sources.list.d/dart_stable.list" > /dev/null +ENV KEYURL="https://dl-ssl.google.com/linux/linux_signing_key.pub" +RUN curl -ksS "$KEYURL" | gpg --dearmor | tee "/etc/apt/trusted.gpg.d/dart_ubuntu.gpg" > /dev/null + +#------------------------------------------------------------------------ +# Add git ppa for latest git +RUN echo "deb http://ppa.launchpad.net/git-core/ppa/ubuntu focal main" > /etc/apt/sources.list.d/git-core-ubuntu-ppa-focal.list +ENV KEYURL=https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xa1715d88e1df1f24 +RUN curl -ksS "$KEYURL" | gpg --dearmor | tee "/etc/apt/trusted.gpg.d/git-core_ubuntu_ppa.gpg" > /dev/null -# Gradle build. -RUN --mount=type=cache,target=/tmp/.gradle/ \ - GRADLE_USER_HOME=/tmp/.gradle/ && \ - scripts/import_proxy_certs.sh && \ - scripts/set_gradle_proxy.sh && \ - sed -i -r 's,(^distributionUrl=)(.+)-all\.zip$,\1\2-bin.zip,' gradle/wrapper/gradle-wrapper.properties && \ - ./gradlew --no-daemon --stacktrace -Pversion=$ORT_VERSION :cli:distTar :helper-cli:startScripts - -FROM adoptopenjdk:11-jre-hotspot-bionic - -ENV \ - # Package manager versions. - BOWER_VERSION=1.8.8 \ - CARGO_VERSION=0.54.0-0ubuntu1~18.04.1 \ - COMPOSER_VERSION=1.6.3-1 \ - CONAN_VERSION=1.40.3 \ - GO_DEP_VERSION=0.5.4 \ - GO_VERSION=1.16.5 \ - HASKELL_STACK_VERSION=2.1.3 \ - NPM_VERSION=7.20.6 \ - PYTHON_PIPENV_VERSION=2018.11.26 \ - PYTHON_VIRTUALENV_VERSION=15.1.0 \ - SBT_VERSION=1.3.8 \ - YARN_VERSION=1.22.10 \ - # SDK versions. - ANDROID_SDK_VERSION=6858069 \ - # Scanner versions. - SCANCODE_VERSION=3.2.1rc2 \ - # Installation directories. - ANDROID_HOME=/opt/android-sdk \ - GOPATH=$HOME/go - -ENV DEBIAN_FRONTEND=noninteractive \ - PATH="$PATH:$HOME/.local/bin:$GOPATH/bin:/opt/go/bin:$GEM_PATH/bin" - -# Apt install commands. -RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ - apt-get update && \ - apt-get install -y --no-install-recommends ca-certificates gnupg software-properties-common && \ - echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | tee -a /etc/apt/sources.list.d/sbt.list && \ - curl -ksS "https://keyserver.ubuntu.com/pks/lookup?op=get&options=mr&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" | apt-key adv --import - && \ - curl -sL https://deb.nodesource.com/setup_16.x | bash - && \ - add-apt-repository -y ppa:git-core/ppa && \ - apt-get update && \ - apt-get install -y --no-install-recommends \ +#------------------------------------------------------------------------ +# Minimal set of packages for main docker +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y --no-install-recommends \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ # Install general tools required by this Dockerfile. + bash \ + cargo \ + composer \ + cvs \ + dart \ + git \ lib32stdc++6 \ - libffi-dev \ - libgmp-dev \ + libffi7 \ + libgmp10 \ + libgomp1 \ libxext6 \ libxi6 \ libxrender1 \ libxtst6 \ - make \ netbase \ openssh-client \ + sbt="$SBT_VERSION" \ + subversion \ unzip \ xz-utils \ - zlib1g-dev \ - # Install VCS tools (no specific versions required here). - cvs \ + zlib1g \ + && rm -rf /var/lib/apt/lists/* + +#------------------------------------------------------------------------ +# Build components +FROM base AS build + +#------------------------------------------------------------------------ +# Ubuntu build toolchain +RUN apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + build-essential \ + ca-certificates \ + dirmngr \ + dpkg-dev \ git \ - mercurial \ - subversion \ - # Install package managers (in versions known to work). - cargo=$CARGO_VERSION \ - composer=$COMPOSER_VERSION \ - nodejs \ - python-dev \ - python-pip \ - python-setuptools \ - python3-dev \ - python3-pip \ - python3-setuptools \ - ruby-dev \ - sbt=$SBT_VERSION \ - && \ - rm -rf /var/lib/apt/lists/* + libbluetooth-dev \ + libbz2-dev \ + libc6-dev \ + libexpat1-dev \ + libffi-dev \ + libgmp-dev \ + libgdbm-dev \ + liblzma-dev \ + libmpdec-dev \ + libncursesw5-dev \ + libreadline-dev \ + libsqlite3-dev \ + libssl-dev \ + make \ + netbase \ + openssl \ + tk-dev \ + tzdata \ + unzip \ + uuid-dev \ + xz-utils \ + zlib1g-dev \ + && rm -rf /var/lib/apt/lists/* -COPY --from=build /usr/local/src/ort/scripts/*.sh /opt/ort/bin/ +# Copy the necessary bash resource to have paths +# for different languages +COPY docker/bash_bootstrap /etc/ort/bash_bootstrap +RUN mkdir -p /etc/ort/bash_modules + +#------------------------------------------------------------------------ +# Python using pyenv +ARG CONAN_VERSION=1.38.0 +ARG PYTHON_VERSION=3.8.11 +ARG VIRTUALENV_VERSION=20.2.2 +ARG PIP_VERSION=21.2.4 + +# Python pyenv +ENV PYENV_ROOT=/opt/python +RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash +ENV PATH=/opt/python/bin:$PATH +RUN pyenv install "${PYTHON_VERSION}" +RUN pyenv global "${PYTHON_VERSION}" +ENV PATH=/opt/python/shims:$PATH +RUN pip install -U pip=="${PIP_VERSION}" \ + conan=="${CONAN_VERSION}" \ + Mercurial \ + virtualenv=="${VIRTUALENV_VERSION}" \ + pipenv +COPY docker/python.sh /etc/ort/bash_modules +#------------------------------------------------------------------------ +# Nodejs Using nvm +ARG NODEJS_VERSION="--lts" +ENV NVM_DIR=/opt/nodejs +RUN git clone --depth 1 https://github.com/nvm-sh/nvm.git /opt/nodejs +RUN . $NVM_DIR/nvm.sh && nvm install "${NODEJS_VERSION}" +COPY docker/nodejs.sh /etc/ort/bash_modules + +#------------------------------------------------------------------------ +# Golang +# Golang dep depends on some development packages to be installed, so need build +# in the build stage +ARG GO_DEP_VERSION=0.5.4 +ARG GO_VERSION=1.17 +ENV GOPATH=/opt/go +RUN curl -L https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz | tar -C /opt -xz +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 + +#------------------------------------------------------------------------ +# Haskell +ARG HASKELL_STACK_VERSION=2.1.3 +ENV DEST=/opt/haskell/bin/stack +RUN curl -ksS https://raw.githubusercontent.com/commercialhaskell/stack/v$HASKELL_STACK_VERSION/etc/scripts/get-stack.sh | bash -s -- -d /usr/bin + +#------------------------------------------------------------------------ +# Ruby using rbenv +ARG RUBY_VERSION=2.7.4 +ENV RBENV_ROOT=/opt/rbenv +ENV PATH=${RBENV_ROOT}/bin:${RBENV_ROOT}/shims/:${RBENV_ROOT}/plugins/ruby-build/bin:$PATH +RUN git clone --depth 1 https://github.com/rbenv/rbenv.git ${RBENV_ROOT} +RUN git clone --depth 1 https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build +WORKDIR ${RBENV_ROOT} +RUN src/configure \ + && make -C src +RUN rbenv install ${RUBY_VERSION} \ + && rbenv global ${RUBY_VERSION} \ + && gem install bundler cocoapods +COPY docker/ruby.sh /etc/ort/bash_modules + +#------------------------------------------------------------------------ +# Scancode from official releases +ARG SCANCODE_VERSION=30.1.0 +ENV SCANCODE_URL "https://github.com/nexB/scancode-toolkit/releases/download/v${SCANCODE_VERSION}" +RUN pyver=$(python3 --version | sed -e "s/Python //" | tr -d '.' | cut -c1-2) \ + && echo "${SCANCODE_URL}/scancode-toolkit-${SCANCODE_VERSION}_py${pyver}-linux.tar.xz" \ + && mkdir -p /opt/scancode \ + && curl -ksSL ${SCANCODE_URL}/scancode-toolkit-${SCANCODE_VERSION}_py${pyver}-linux.tar.xz | tar -C /opt/scancode -xJ --strip-components=1 \ + && cd /opt/scancode \ + && PYTHON_EXE=python3 ./configure \ + # cleanup unneeded installed binaries + && rm -rf /opt/scancode/thirdparty + +#------------------------------------------------------------------------ # This can be set to a directory containing CRT-files for custom certificates that ORT and all build tools should know about. ARG CRT_FILES="" COPY "$CRT_FILES" /tmp/certificates/ +ARG ORT_VERSION="DOCKER-SNAPSHOT" -# Custom install commands. -RUN /opt/ort/bin/import_proxy_certs.sh && \ - if [ -n "$CRT_FILES" ]; then \ - /opt/ort/bin/import_certificates.sh /tmp/certificates/; \ - fi && \ - # Install VCS tools (no specific versions required here). - curl -ksS https://storage.googleapis.com/git-repo-downloads/repo > /usr/local/bin/repo && \ - chmod a+x /usr/local/bin/repo && \ - # Install package managers (in versions known to work). - npm install --global npm@$NPM_VERSION bower@$BOWER_VERSION yarn@$YARN_VERSION && \ - pip install --no-cache-dir wheel && \ - pip install --no-cache-dir conan==$CONAN_VERSION pipenv==$PYTHON_PIPENV_VERSION virtualenv==$PYTHON_VIRTUALENV_VERSION && \ - # Install golang in order to have `go mod` as package manager. - curl -ksSO https://dl.google.com/go/go$GO_VERSION.linux-amd64.tar.gz && \ - tar -C /opt -xzf go$GO_VERSION.linux-amd64.tar.gz && \ - rm go$GO_VERSION.linux-amd64.tar.gz && \ - mkdir -p $GOPATH/bin && \ - curl -ksS https://raw.githubusercontent.com/golang/dep/v$GO_DEP_VERSION/install.sh | sh && \ - curl -ksS https://raw.githubusercontent.com/commercialhaskell/stack/v$HASKELL_STACK_VERSION/etc/scripts/get-stack.sh | sh && \ - # Install SDKs required for analysis. - curl -Os https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip && \ - unzip -q commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip -d $ANDROID_HOME && \ - rm commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip && \ - PROXY_HOST_AND_PORT=${https_proxy#*://} && \ - if [ -n "$PROXY_HOST_AND_PORT" ]; then \ - # While sdkmanager uses HTTPS by default, the proxy type is still called "http". - SDK_MANAGER_PROXY_OPTIONS="--proxy=http --proxy_host=${PROXY_HOST_AND_PORT%:*} --proxy_port=${PROXY_HOST_AND_PORT##*:}"; \ - fi && \ - yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager $SDK_MANAGER_PROXY_OPTIONS --sdk_root=$ANDROID_HOME "platform-tools" && \ - # Install 'CocoaPods'. As https://github.com/CocoaPods/CocoaPods/pull/10609 is needed but not yet released. - curl -ksSL https://github.com/CocoaPods/CocoaPods/archive/9461b346aeb8cba6df71fd4e71661688138ec21b.tar.gz | \ - tar -zxC . && \ - (cd CocoaPods-9461b346aeb8cba6df71fd4e71661688138ec21b && \ - gem build cocoapods.gemspec && \ - gem install cocoapods-1.10.1.gem \ - ) && \ - rm -rf CocoaPods-9461b346aeb8cba6df71fd4e71661688138ec21b && \ - # Add scanners (in versions known to work). - curl -ksSL https://github.com/nexB/scancode-toolkit/archive/v$SCANCODE_VERSION.tar.gz | \ - tar -zxC /usr/local && \ - # Trigger ScanCode configuration for Python 3 and reindex licenses initially. - PYTHON_EXE=/usr/bin/python3 /usr/local/scancode-toolkit-$SCANCODE_VERSION/scancode --reindex-licenses && \ - chmod -R o=u /usr/local/scancode-toolkit-$SCANCODE_VERSION && \ - ln -s /usr/local/scancode-toolkit-$SCANCODE_VERSION/scancode /usr/local/bin/scancode +#------------------------------------------------------------------------ +# ORT +COPY . /usr/local/src/ort +WORKDIR /usr/local/src/ort -COPY --from=build /usr/local/src/ort/cli/build/distributions/ort-*.tar /opt/ort.tar +#------------------------------------------------------------------------ +# Gradle ORT build. +RUN scripts/import_proxy_certs.sh \ + && scripts/set_gradle_proxy.sh \ + && GRADLE_USER_HOME=/tmp/.gradle/ \ + && sed -i -r 's,(^distributionUrl=)(.+)-all\.zip$,\1\2-bin.zip,' gradle/wrapper/gradle-wrapper.properties \ + && ./gradlew \ + --no-daemon \ + --stacktrace \ + -Pversion=$ORT_VERSION \ + -PscancodeVersion=${SCANCODE_VERSION} \ + :cli:distTar \ + :helper-cli:startScripts + +#------------------------------------------------------------------------ +# Main ORT docker +FROM base + +#------------------------------------------------------------------------ +# Python from build +ENV PYENV_ROOT=/opt/python +COPY --from=build /opt/python /opt/python + +#------------------------------------------------------------------------ +# Ruby from build +ENV RBENV_ROOT=/opt/rbenv +COPY --from=build /opt/rbenv /opt/rbenv + +#------------------------------------------------------------------------ +# nodejs from build +ENV NVM_DIR=/opt/nodejs +COPY --from=build /opt/nodejs /opt/nodejs -RUN tar xf /opt/ort.tar -C /opt/ort --strip-components 1 && \ - rm /opt/ort.tar && \ - /opt/ort/bin/ort requirements +#------------------------------------------------------------------------ +# Golang from build +COPY --from=build /opt/go /opt/go/ +#------------------------------------------------------------------------ +# Stack from build +COPY --from=build /usr/bin/stack /usr/bin/ + +#------------------------------------------------------------------------ +# Google Repo tool +RUN curl -ksS https://storage.googleapis.com/git-repo-downloads/repo > /usr/bin/repo \ + && chmod a+x /usr/bin/repo + +#------------------------------------------------------------------------ +# Android SDK +ARG ANDROID_SDK_VERSION=6858069 +ENV ANDROID_HOME=/opt/android-sdk +RUN set +o pipefail \ + && curl -Os https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip \ + && unzip -q commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip -d $ANDROID_HOME \ + && rm commandlinetools-linux-${ANDROID_SDK_VERSION}_latest.zip \ + && yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager $SDK_MANAGER_PROXY_OPTIONS \ + --sdk_root=$ANDROID_HOME "platform-tools" "cmdline-tools;latest" + +#------------------------------------------------------------------------ +# NPM based package managers +ARG BOWER_VERSION=1.8.8 +ARG NPM_VERSION=7.20.6 +ARG YARN_VERSION=1.22.4 +RUN . $NVM_DIR/nvm.sh \ + && npm install --global npm@$NPM_VERSION bower@$BOWER_VERSION yarn@$YARN_VERSION + +#------------------------------------------------------------------------ +# Scancode +COPY --from=build /opt/scancode /opt/scancode +RUN ln -s /opt/scancode/bin/scancode /usr/bin/scancode \ + && ln -s /opt/scancode/bin/pip /usr/bin/scancode-pip \ + && scancode --reindex-licenses + +#------------------------------------------------------------------------ +# ORT +COPY --from=build /usr/local/src/ort/scripts/*.sh /opt/ort/bin/ COPY --from=build /usr/local/src/ort/helper-cli/build/scripts/orth /opt/ort/bin/ COPY --from=build /usr/local/src/ort/helper-cli/build/libs/helper-cli-*.jar /opt/ort/lib/ +COPY --from=build /usr/local/src/ort/cli/build/distributions/ort-*.tar /opt/ort.tar +RUN tar xf /opt/ort.tar -C /opt/ort --strip-components 1 \ + && rm /opt/ort.tar + +#------------------------------------------------------------------------ +# Bash modules and wrapper +COPY --from=build /etc/ort /etc/ort +RUN chmod a+x /etc/ort +RUN chmod -R a+r /etc/ort + +COPY docker/ort-wrapper.sh /usr/bin/ort +RUN chmod 755 /usr/bin/ort + +#------------------------------------------------------------------------ +# Add arg user and run as a regular user +ARG USER_ID=0 +ARG GROUP_ID=0 + +RUN if [ ${USER_ID:-0} -ne 0 ] && [ ${GROUP_ID:-0} -ne 0 ]; then \ + groupadd -g ${GROUP_ID} ort \ + && useradd -l -u ${USER_ID} -g ort ort \ + && install -d -m 0755 -o ort -g ort /home/ort; \ + fi + +USER ort +WORKDIR /home/ort -ENTRYPOINT ["/opt/ort/bin/ort"] +ENTRYPOINT ["/usr/bin/ort"] diff --git a/README.md b/README.md index dc82e7b57a504..e50f37118ad95 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,36 @@ Install the following basic prerequisites: * Docker 18.09 or later (and ensure its daemon is running). * Enable [BuildKit](https://docs.docker.com/develop/develop-images/build_enhancements/) for Docker. -Change into the directory with ORT's source code and run `docker build -t ort .`. +Change into the directory with ORT's source code and run: +``` +docker build -t ort . +``` + +Tool versions can be changed passing as args like **--build-arg TOOL_ENV=VERSION** +This is the list of tools variables you can change: + +| Tool Env Var | To obtain versions list | +| ------------ | ------------------------ | +ANDROID_SDK_VERSION | +BOWER_VERSION | +CONAN_VERSION | +GO_DEP_VERSION | +GO_VERSION | +HASKELL_STACK_VERSION | +NODEJS_VERSION | Any of **nvm ls-remote** +NPM_VERSION | +PIP_VERSION | +PYTHON_VERSION | Any of **pyenv install --list** +RUBY_VERSION | Any of **rbenv install --list-all** +SBT_VERSION | +SCANCODE_VERSION | +VIRTUALENV_VERSION | +YARN_VERSION | + +Example: +``` +--build-arg PYTHON_VERSION="3.9.1" +``` ### Build natively diff --git a/docker/bash_bootstrap b/docker/bash_bootstrap new file mode 100644 index 0000000000000..78347ceb34a75 --- /dev/null +++ b/docker/bash_bootstrap @@ -0,0 +1,37 @@ +#!/bin/bash + +# Copyright (C) 2021 Helio Chissini de Castro +# +# 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 +# +# http://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 + +# We will parse the necessary shells inits for each language +# independently + +set -e + +# Global functions +add_local_path () { + case ":${PATH:=$1}:" in + *:"$1":*) ;; + *) PATH="$1:$PATH" ;; + esac; +} + +# Source all resources +for resource in /etc/ort/bash_modules/*.sh; do + # shellcheck disable=SC1090 + source "${resource}" +done diff --git a/docker/nodejs.sh b/docker/nodejs.sh new file mode 100644 index 0000000000000..ae85543cff0d8 --- /dev/null +++ b/docker/nodejs.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Copyright (C) 2021 Helio Chissini de Castro +# +# 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 +# +# http://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 + +export NVM_DIR="/opt/nodejs" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion diff --git a/docker/ort-wrapper.sh b/docker/ort-wrapper.sh new file mode 100644 index 0000000000000..2b78b50d0ac1f --- /dev/null +++ b/docker/ort-wrapper.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Copyright (C) 2021 Helio Chissini de Castro +# +# 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 +# +# http://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 + +set -e + +#shellcheck disable=SC1091 +source /etc/ort/bash_bootstrap + +exec /opt/ort/bin/ort "$@" diff --git a/docker/python.sh b/docker/python.sh new file mode 100644 index 0000000000000..eb81418e530a9 --- /dev/null +++ b/docker/python.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Copyright (C) 2021 Helio Chissini de Castro +# +# 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 +# +# http://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 + +PYENV_ROOT="/opt/python" +export PYENVROOT + +add_local_path "${PYENV_ROOT}/bin" + +eval "$(pyenv init --path)"; +#shellcheck disable=1091 +. "$(pyenv root)"/completions/pyenv.bash; + + +# Needed if you want new pyhon version then default +install_python_builddeps () { + apt update + apt install -y make build-essential libssl-dev zlib1g-dev \ + libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \ + libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev +} diff --git a/docker/ruby.sh b/docker/ruby.sh new file mode 100644 index 0000000000000..24fcb89196202 --- /dev/null +++ b/docker/ruby.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Copyright (C) 2021 Helio Chissini de Castro +# +# 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 +# +# http://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 + +RBENV_ROOT="/opt/rbenv" +export RBENV_ROOT + +add_local_path "${RBENV_ROOT}/bin" +add_local_path "${RBENV_ROOT}/shims" +add_local_path "${RBENV_ROOT}/plugins/ruby-install/bin" diff --git a/scripts/docker_build.sh b/scripts/docker_build.sh index 97ab254d0d6f5..4a7957e4b7d8b 100755 --- a/scripts/docker_build.sh +++ b/scripts/docker_build.sh @@ -21,4 +21,8 @@ GIT_ROOT=$(git rev-parse --show-toplevel) GIT_VERSION=$(git describe --abbrev=7 --always --tags --dirty) echo "Setting ORT_VERSION to $GIT_VERSION." -docker build -f $GIT_ROOT/Dockerfile -t ort --build-arg ORT_VERSION=$GIT_VERSION $GIT_ROOT +docker build -f $GIT_ROOT/Dockerfile -t ort \ + --build-arg USER_ID=$(id -u ${USER}) \ + --build-arg GROUP_ID=$(id -g ${USER}) \ + --build-arg ORT_VERSION=$GIT_VERSION \ + $GIT_ROOT