forked from redhat-developer/odo-init-image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
s2i-setup
executable file
·39 lines (32 loc) · 1.49 KB
/
s2i-setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
set -x
set -eo pipefail
# We need to setup these directories before the actual assembly process
# because odo copies into some of these directories before running assemble
# If not present, copy supervisor.conf from EmptyDir on to persistent volume mounted on "/opt/app-root"
# This is to persist supervisor.conf across pod restarts
PV_MNT_PT="/opt/app-root"
ODO_UTILS_DIR="/opt/odo"
if [ ! -f ${PV_MNT_PT}/conf/supervisor.conf ]; then
cp -rp ${ODO_UTILS_DIR}/conf ${PV_MNT_PT}
fi
# source directory from other s2i images
mkdir -p ${ODO_S2I_SRC_BIN_PATH}
# s2i fails when /tmp/src/ is empty. Also this is needed for Java s2i
touch ${ODO_S2I_SRC_BIN_PATH}/.dummy
# NodeJs s2i expects /tmp to exist even when its neither destination nor deployments-dir
mkdir -p /tmp/src/
touch /tmp/src/.dummy
# some s2i images additionally expect ${ODO_S2I_SRC_BIN_PATH}/src to exist ex: /tmp/src for java
if [[ ${ODO_S2I_SRC_BIN_PATH} != *"/src"* ]];then
mkdir -p ${ODO_S2I_SRC_BIN_PATH}/src
touch ${ODO_S2I_SRC_BIN_PATH}/src/.dummy
fi
mkdir -p ${PV_MNT_PT}/src
# for converted components there is volume permission issue if we directly sync the source code to /tmp/src
# devfile creates empty dir to sync source code, which has root ownership. if we directly sync code to /tmp/src
# it would have root ownership and s2i-assemble script would fail for non root container.
# To resolve this issue we are first syncing to another dir.
if [ ! -z "${ODO_S2I_CONVERTED_DEVFILE}" ];then
rsync -ar /tmp/projects/ /tmp/src
fi