-
Notifications
You must be signed in to change notification settings - Fork 11
/
docker-entrypoint-build.sh
executable file
·46 lines (37 loc) · 1.33 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
#!/bin/bash
# Djacket build docker entrypoint shell script.
npm link gulp;
# GulpJS does the compiling of static files.
gulp --gulpfile ./frontend/gulpfile.js compile;
# If we are in development mode then we need to run 'makemigrations'
# otherwise 'migrate' would suffice.
if [[ "$DJKR_MODE" == "dev" ]]; then
python ./backend/manage.py makemigrations;
fi
# Keeping the database updated.
python ./backend/manage.py migrate;
# This will create an admin user if there is not any.
python ./backend/manage.py create_admin;
# If we are in production we have to collect all the required static files.
if [[ "$DJKR_MODE" == "prod" ]]; then
python ./backend/manage.py collectstatic --noinput;
fi
# We need to create some stock avatars first.
if [ ! -d "/srv/media/avatars" ]; then
mkdir -p "/srv/media/avatars";
fi
# Here we download some stock avatars.
stock_avatars=3
if [ ! -d "/srv/media/stock" ]; then
mkdir -p "/srv/media/stock";
for i in $(seq $stock_avatars $END); do
curl -m 5 "https://api.adorable.io/avatars/200/$i.png" > "/srv/media/stock/$i.png";
done
else
if [[ "$(ls /srv/media/stock | wc -l)" < "$stock_avatars" ]]; then
for i in $(seq $stock_avatars $END); do
curl -m 5 "https://api.adorable.io/avatars/200/$i.png" > "/srv/media/stock/$i.png";
done
fi
fi
cat /srv/SIGN;