-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentrypoint.sh
52 lines (40 loc) · 1.2 KB
/
entrypoint.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
#!/bin/sh
PG_HOST="dews-db"
PG_PORT="5432"
PG_DB="dews"
PG_USER="dews"
PG_PW="dews"
# Wait for PostgreSQL to become available
echo "Waiting for PostgreSQL to become available..."
while ! PGPASSWORD="$PG_PW" psql -h "$PG_HOST" -U "$PG_USER" -p "$PG_PORT" -d "$PG_DB" -c 'SELECT 1' > /dev/null 2>&1
do
echo "PostgreSQL is unavailable - sleeping"
sleep 1
done
# Create directory paths
echo "Create directories..."
satellites="sentinel-1a sentinel-2b"
directories="extracted images archive"
# Create directories
for satellite in $satellites; do
for directory in $directories; do
mkdir -p "/dews/media/sat_data/$directory/$satellite"
done
done
mkdir -p "/dews/media/other"
# Create empty log
echo "Create empty Django log file..."
touch /app/dews/django.log
# Django database migration
echo "Make migrations..."
python manage.py makemigrations --noinput
echo "Migrate..."
python manage.py migrate --noinput
echo "Colect static..."
python manage.py collectstatic --noinput
# Create default super user
echo "Create default super user..."
python manage.py createsuperuser --noinput
# Start
echo "Start main app..."
gunicorn dews.wsgi:application --bind 0.0.0.0:8000 -k gevent --workers 3 --reload --timeout 120