Skip to content

Commit d88e18a

Browse files
committed
Added: docker commands
1 parent f63b9f9 commit d88e18a

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/commands/docker-entrypoint.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if [ -z ${POSTGRES_DB+x} ]; then
6+
echo "PostgreSQL is not used. Skipping wait-for-it...";
7+
echo "Using SQLite. Creating database...";
8+
else
9+
echo "Using PostgreSQL. Waiting for it to be ready...";
10+
/opt/venv/bin/wait-for-it -s "$POSTGRES_HOST:$POSTGRES_PORT" -t 60
11+
echo "PostgreSQL is ready.";
12+
fi
13+
14+
echo "Running makemigrations..."
15+
/opt/venv/bin/python /app/src/manage.py makemigrations --noinput
16+
echo "Completed makemigrations."
17+
18+
echo "Running migrate..."
19+
/opt/venv/bin/python /app/src/manage.py migrate --noinput
20+
echo "Completed migrate."
21+
22+
echo "Running CreateSuperUser..."
23+
USER_EXISTS="from django.contrib.auth import get_user_model; User = get_user_model(); exit(User.objects.exists())"
24+
/opt/venv/bin/python /app/src/manage.py shell -c "$USER_EXISTS" && /opt/venv/bin/python /app/src/manage.py createsuperuser --noinput
25+
echo "Completed CreateSuperUser."
26+
27+
echo "Running collectstatic..."
28+
/opt/venv/bin/python /app/src/manage.py collectstatic --noinput
29+
echo "Completed collectstatic."
30+
31+
exec "$@"

src/commands/run-prod.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
cd /app/src
4+
5+
APP_PORT=${GUNICORN_PORT:-8000}
6+
7+
if [ "$1" = "--debug" ]; then
8+
/opt/venv/bin/python /backend/manage.py runserver "0.0.0.0:$APP_PORT"
9+
else
10+
/opt/venv/bin/gunicorn "backend.wsgi:application" --bind "0.0.0.0:$GUNICORN_PORT" --workers "$GUNICORN_WORKERS" --timeout "$GUNICORN_TIMEOUT" --log-level "$GUNICORN_LOG_LEVEL"
11+
fi

0 commit comments

Comments
 (0)