Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New multi docker #3902

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
399 changes: 271 additions & 128 deletions Dockerfile

Large diffs are not rendered by default.

31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
37 changes: 37 additions & 0 deletions docker/bash_bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# Copyright (C) 2021 Helio Chissini de Castro <helio@kde.org>
#
# 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
22 changes: 22 additions & 0 deletions docker/nodejs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
heliocastro marked this conversation as resolved.
Show resolved Hide resolved

# Copyright (C) 2021 Helio Chissini de Castro <helio@kde.org>
#
# 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
25 changes: 25 additions & 0 deletions docker/ort-wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Copyright (C) 2021 Helio Chissini de Castro <helio@kde.org>
#
# 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 "$@"
36 changes: 36 additions & 0 deletions docker/python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# Copyright (C) 2021 Helio Chissini de Castro <helio@kde.org>
#
# 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)";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
eval "$(pyenv init --path)";
eval "$(pyenv init --path)"

#shellcheck disable=1091
. "$(pyenv root)"/completions/pyenv.bash;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
. "$(pyenv root)"/completions/pyenv.bash;
. "$(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
}
25 changes: 25 additions & 0 deletions docker/ruby.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Copyright (C) 2021 Helio Chissini de Castro <helio@kde.org>
#
# 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"
6 changes: 5 additions & 1 deletion scripts/docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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