-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-entrypoint-build.sh
executable file
·63 lines (50 loc) · 1.95 KB
/
docker-entrypoint-build.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
56
57
58
59
60
61
62
63
#!/bin/bash
info () {
printf "\r [\033[00;34mINFO\033[0m] %s\n" "("
})
trap exit SIGHUP SIGINT SIGTERM
env | grep -iv PASS | sort
# prepare a tarball of build
if [ "$1" = 'releasetarball' ]; then
echo "[Run] Preparing a release tarball"
info "BUILD_VERSION ${BUILD_VERSION}"
info "PROJECT_SOURCE ${PROJECT_SOURCE}"
set -e
cd /app
rm -rf /app/*
set -x
git clone --depth=1 --branch="${GIT_BRANCH}" "${PROJECT_SOURCE}" .
git rev-parse HEAD > .version
cat .version
# Note: Environment vars are used to control the behaviour of pip (use local devpi for instance)
pip3 install --upgrade -r requirements/runtime-requirements.txt
pip3 install --upgrade -r requirements/migration.txt
# as we're doing an in-place install, we need the .egg-info directory in the tarball so
# entrypoint scripts work in the prod container
pip3 install -e .
set +x
# npm deps in /npm
mkdir -p /npm
cp /app/package.json /npm/package.json
cd /npm && npm install --ignore-scripts
# bower deps in /bower
mkdir -p /bower
cp /app/bower.json /bower/bower.json
cd /bower && /npm/node_modules/.bin/bower install --allow-root --config.interactive=false
# install the previously cached bower components into the app
ln -s /bower/bower_components /app/bower_components
ln -s /npm/node_modules /app/node_modules
# Build the frontend into /app/gulpdist
cd /app
/app/node_modules/.bin/gulp build --venv /env
# prepare for base_href hack in uwsgi entrypoint
cp /app/gulpdist/index.html /app/gulpdist/index.base.html
chown ccg-user /app/gulpdist/index.html
# create release tarball
DEPS="/env /npm /bower /app/uwsgi /app/docker-entrypoint.sh /app/kindred /app/migrate /app/django_kindred.egg-info /app/gulpdist"
cd /data
exec tar -cpzf ${PROJECT_NAME}-${BUILD_VERSION}.tar.gz ${DEPS}
fi
echo "[RUN]: Builtin command not provided [releasetarball]"
echo "[RUN]: $@"
exec "$@"