Skip to content

Commit abf4e7d

Browse files
authored
Merge pull request #2 from vikinganalytics/improved-script-compatability
Improved script compatability
2 parents 016b106 + 306b100 commit abf4e7d

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

python38-slim/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ FROM python:3.8-slim
33

44
LABEL maintainer="Viking Analytics AB"
55

6-
ENV BUILDER_VERSION 1.0
6+
ENV BUILDER_VERSION=1.0 \
7+
APP_ROOT="/app_root" \
8+
STI_SCRIPTS_PATH="/.s2i/bin"
79

810
# Set labels used in OpenShift to describe the builder image
911
LABEL io.k8s.description="Platform for building Daeploy images with reduced size" \

python38-slim/s2i/bin/assemble

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ if [[ "$1" == "-h" ]]; then
1313
fi
1414

1515
echo "---> Installing application source ..."
16-
mv /tmp/src/* "$HOME"
16+
mkdir -p "$APP_ROOT/src"
17+
mv /tmp/src/* "$APP_ROOT/src"
1718

1819
# Install dependencies
1920
echo "---> Upgrading pip and setuptools"
2021
pip install -U pip setuptools
2122

22-
cd $HOME
23+
cd "$APP_ROOT/src"
2324
if [[ -f requirements.txt ]]; then
2425
echo "---> Installing dependencies..."
2526
python -m pip install -r requirements.txt

python38-slim/s2i/bin/run

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md
88
#
99

10-
cd $HOME
10+
cd "$APP_ROOT/src"
1111

1212
if [ -z "$APP_SCRIPT" ] && [ -z "$APP_FILE" ] && [ -z "$APP_MODULE" ]; then
1313
# Set default values for APP_SCRIPT and APP_FILE only when all three APP_
@@ -24,8 +24,9 @@ if [ ! -z "$APP_SCRIPT" ]; then
2424
if [[ -f "$APP_SCRIPT" ]]; then
2525
echo "---> Running application from script ($APP_SCRIPT) ..."
2626
if [[ "$APP_SCRIPT" != /* ]]; then
27-
APP_SCRIPT="$HOME/$APP_SCRIPT"
27+
APP_SCRIPT="$APP_ROOT/src/$APP_SCRIPT"
2828
fi
29+
chmod +x "$APP_SCRIPT"
2930
"$APP_SCRIPT"
3031
elif [[ -z "$APP_SCRIPT_DEFAULT" ]]; then
3132
echo "ERROR: file '$APP_SCRIPT' not found." && exit 1
@@ -35,7 +36,7 @@ fi
3536
if [ ! -z "$APP_FILE" ]; then
3637
if [[ -f "$APP_FILE" ]]; then
3738
echo "---> Running application from Python script ($APP_FILE) ..."
38-
python "$HOME/$APP_FILE"
39+
python "$APP_FILE"
3940
elif [[ -z "$APP_FILE_DEFAULT" ]]; then
4041
echo "ERROR: file '$APP_FILE' not found." && exit 1
4142
fi

0 commit comments

Comments
 (0)