aboutsummaryrefslogtreecommitdiffstats
path: root/docker/app/scripts/migrate_and_serve.sh
diff options
context:
space:
mode:
authorGravatar Leon Sandøy <[email protected]>2019-07-03 15:04:02 +0200
committerGravatar Leon Sandøy <[email protected]>2019-07-03 15:04:02 +0200
commit793249576d26ab448d6f55497a6bef05c8e27ede (patch)
treebf04424e9b3044ccf9697e1bbead2d6e3489ee12 /docker/app/scripts/migrate_and_serve.sh
parentAdding django.pythondiscord.com to ALLOWED_HOSTS (diff)
Setting up a method for automatically applying migrations in production. Making a separate Dockerfile for local docker-compose builds.
Diffstat (limited to 'docker/app/scripts/migrate_and_serve.sh')
-rwxr-xr-xdocker/app/scripts/migrate_and_serve.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/docker/app/scripts/migrate_and_serve.sh b/docker/app/scripts/migrate_and_serve.sh
new file mode 100755
index 00000000..42bf67a3
--- /dev/null
+++ b/docker/app/scripts/migrate_and_serve.sh
@@ -0,0 +1,20 @@
+#!/bin/sh -eu
+
+### NOTE
+# This file is intended to be used by local setups.
+# You do not want to run the Django development server
+# in production. The default Dockerfile command will
+# run using uWSGI, this script is provided purely as
+# a convenience to run migrations and start a development server.
+
+echo [i] Applying migrations.
+python manage.py migrate --verbosity 1
+
+echo [i] Collecting static files.
+python manage.py collectstatic --no-input --clear --verbosity 0
+
+echo [i] Creating a superuser.
+echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('admin', 'admin', 'admin') if not User.objects.filter(username='admin').exists() else print('Admin user already exists')" | python manage.py shell
+
+echo [i] Starting server.
+python manage.py runserver 0.0.0.0:8000