-
Notifications
You must be signed in to change notification settings - Fork 6
/
docker-start.sh
executable file
·55 lines (40 loc) · 1.53 KB
/
docker-start.sh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
set -e
runtimeEnv=$(uname)
if [ "$runtimeEnv" != "Linux" ] || [ ! -f /.dockerenv ]; then
echo "Do not use this script in non-dockerized environments."
echo "Detected non-Linux runtime $runtimeEnv, or /.dockerenv is not present."
echo "Use 'node bin/api' or 'npm start'.'"
exit 1
fi
exit 1
if [ ! -z "$GIT_CREDENTIALS" ] && [ ! -z "$GIT_REPO" ]; then
tmpDir=$(mktemp -d)
echo "Cloning configuration repository from $GIT_REPO into $tmpDir..."
pushd $tmpDir
if [ -z "$GIT_BRANCH" ]; then
echo "Checking out branch 'master'..."
git clone https://${GIT_CREDENTIALS}@${GIT_REPO} --depth 1 .
else
echo "Checking out branch '$GIT_BRANCH'..."
git clone https://${GIT_CREDENTIALS}@${GIT_REPO} --depth 1 --branch ${GIT_BRANCH} .
fi
if [ ! -d "$tmpDir/static" ]; then
echo "===================================================================================="
echo "ERROR: Could not find directory 'static' in $tmpDir, wrong repository?"
echo "===================================================================================="
exit 1
fi
echo "Cleaning up old configuration (if applicable)"
rm -rf /var/portal-api/static
echo "Copying configuration to /var/portal-api/static"
cp -R static /var/portal-api
echo "Done."
popd
echo "Cleanining up temp dir."
rm -rf $tmpDir
else
echo "Assuming /var/portal-api/static is prepopulated, not cloning configuration repo."
fi
echo "Starting API..."
npm start