Skip to content

Commit

Permalink
docker: Build and run as a non-privileged user
Browse files Browse the repository at this point in the history
- Shell in login profile is not more needed
- Container runs always on the defined build user ( default: ort )
- Added an auxiliary script for apt proxy
- Detect platform for build. scancode is disabled on linux/arm64

Signed-off-by: Helio Chissini de Castro <heliocastro@gmail.com>
  • Loading branch information
heliocastro committed Nov 10, 2022
1 parent edcc15f commit f9804d8
Show file tree
Hide file tree
Showing 8 changed files with 259 additions and 291 deletions.
405 changes: 247 additions & 158 deletions Dockerfile

Large diffs are not rendered by default.

22 changes: 0 additions & 22 deletions docker/android.sh

This file was deleted.

20 changes: 0 additions & 20 deletions docker/ort-wrapper.sh

This file was deleted.

27 changes: 0 additions & 27 deletions docker/python.sh

This file was deleted.

25 changes: 0 additions & 25 deletions docker/ruby.sh

This file was deleted.

26 changes: 0 additions & 26 deletions docker/rust.sh

This file was deleted.

20 changes: 9 additions & 11 deletions docker/00-add_local_path.sh → docker/set_apt_proxy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# Copyright (C) 2021 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>)
#
# Copyright (C) 2020 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -17,13 +17,11 @@
# SPDX-License-Identifier: Apache-2.0
# License-Filename: LICENSE

# Global functions
add_local_path () {
case ":${PATH:=$1}:" in
*:"$1":*) ;;
*) PATH="$1:$PATH" ;;
esac;
if [ -n "$http_proxy" ]; then
cat << EOF > /etc/apt/apt.conf.d/proxy.conf
Acquire {
HTTP::proxy "$http_proxy";
HTTPS::proxy "$http_proxy";
}

export -f add_local_path

EOF
fi
5 changes: 3 additions & 2 deletions scripts/docker_build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash -x
#
# Copyright (C) 2020 The ORT Project Authors (see <https://github.com/oss-review-toolkit/ort/blob/main/NOTICE>)
#
Expand All @@ -21,12 +21,13 @@ DOCKER_ARGS=$@

GIT_ROOT=$(git rev-parse --show-toplevel)
GIT_REVISION=$(git describe --abbrev=10 --always --tags --dirty --match=[0-9]*)
PLATFORM="${PLATFORM:-linux/$(arch)}"

echo "Setting ORT_VERSION to $GIT_REVISION."
docker buildx build \
-f "$GIT_ROOT/Dockerfile" \
-t "${ORT_DOCKER_TAG:-ort}" \
--build-arg ORT_VERSION="$GIT_REVISION" \
--platform linux/amd64 \
--platform "$PLATFORM" \
$DOCKER_ARGS \
"$GIT_ROOT"

0 comments on commit f9804d8

Please sign in to comment.