aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Johannes Christ <[email protected]>2018-10-06 22:42:38 +0200
committerGravatar Johannes Christ <[email protected]>2018-10-06 22:42:38 +0200
commit8b1523b8c484abed432dfd80d4592048e9861405 (patch)
tree29010b57ac42109f4f06546516217fe74942ca6e
parentUse proper keyword argument. (diff)
Update the compose file and dockerapp file.
The development app from the compose file will now apply migrations on boot and additionally, it will use Django's development server along with the current directory mounted read-only into the container in order to support code reloading, helpful while development.
-rw-r--r--.dockerignore1
-rw-r--r--docker-compose.yml31
-rwxr-xr-xdocker/app/migrate_and_serve.sh13
-rw-r--r--docker/pysite.dockerapp23
4 files changed, 52 insertions, 16 deletions
diff --git a/.dockerignore b/.dockerignore
index 33fc984e..d853d0d2 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -17,6 +17,7 @@ api/tests.py
CHANGELOG.md
CONTRIBUTING.md
docker
+!docker/app/migrate_and_boot.sh
!docker/app/uwsgi.ini
docker-compose.yml
Dockerfile
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 00000000..95513d84
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,31 @@
+### Docker compose setup file
+# This file can be used to quickly set up a development server
+# with code auto-reloading and automatic execution of migrations.
+#
+## Note
+# This file is not intended to be used for production.
+
+version: "3.6"
+services:
+ django:
+ build:
+ context: .
+ dockerfile: docker/app/alpine/3.7/Dockerfile
+ command: docker/app/migrate_and_serve.sh
+ ports:
+ - "8000:8000"
+ depends_on:
+ - postgres
+ volumes:
+ - .:/app:ro
+ environment:
+ DATABASE_URL: postgres://pysite:supersecretpassword@postgres/pysite
+ DEBUG: "true"
+ SECRET_KEY: suitable-for-development-only
+
+ postgres:
+ image: postgres:11-alpine
+ environment:
+ POSTGRES_DB: pysite
+ POSTGRES_PASSWORD: supersecretpassword
+ POSTGRES_USER: pysite
diff --git a/docker/app/migrate_and_serve.sh b/docker/app/migrate_and_serve.sh
new file mode 100755
index 00000000..7c20130b
--- /dev/null
+++ b/docker/app/migrate_and_serve.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+### 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 0
+echo [i] Starting server.
+python manage.py runserver
diff --git a/docker/pysite.dockerapp b/docker/pysite.dockerapp
index 4a811861..dc472b2e 100644
--- a/docker/pysite.dockerapp
+++ b/docker/pysite.dockerapp
@@ -1,8 +1,8 @@
-version: 0.1.0
+version: 0.3.0
name: pysite
description: |
Our community website, built on Django and PostgreSQL.
-#namespace: python-discord
+namespace: python-discord
maintainers:
- name: Johannes Christ
@@ -11,15 +11,16 @@ maintainers:
version: "3.6"
services:
django:
- image: registry.gitlab.com/python-discord/projects/site/django:latest
+ build:
+ context: .
+ command: docker/app/migrate_and_serve.sh
ports:
- "127.0.0.1:4000:4000"
environment:
DATABASE_URL: "postgres://${pg_user}:${pg_passwd}@${pg_host}/${pg_db}"
- DEBUG: 0
+ DEBUG: 'false'
SECRET_KEY: "${secret_key}"
depends_on:
- - migrator
- postgres
postgres:
@@ -29,20 +30,10 @@ services:
POSTGRES_USER: "${pg_user}"
POSTGRES_PASSWORD: "${pg_passwd}"
- migrator:
- image: registry.gitlab.com/python-discord/projects/site/django:latest
- environment:
- DATABASE_URL: "postgres://${pg_user}:${pg_passwd}@${pg_host}/${pg_db}"
- DEBUG: 0
- SECRET_KEY: "${secret_key}"
- command: "python manage.py migrate"
- depends_on:
- - postgres
-
---
pg_user: pysite
pg_db: pysite
-pg_passwd: ''
+pg_passwd: supersecretpassword
pg_host: postgres
secret_key: 'suitable-for-development-only'