Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DJANGO_SECRET_KEY=
# space-separated hosts
DJANGO_ALLOWED_HOSTS=
DJANGO_DB_HOST=
DJANGO_DB_NAME=
Expand All @@ -7,6 +8,8 @@ DJANGO_DB_PASSWORD=
DJANGO_SECURE_SSL_HOST=False
DJANGO_SESSION_COOKIE_SECURE=False
DJANGO_CSRF_COOKIE_SECURE=False
DJANGO_SUPERUSER=
# This is default variable read by createsuperuser --noinput
DJANGO_SUPERUSER_USERNAME=
DJANGO_SUPERUSER_PASSWORD=
HTTP_X_FORWARDED_PROTO=
DJANGO_SUPERUSER_EMAIL=
HTTP_X_FORWARDED_PROTO=
25 changes: 20 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.4'

# For use in development only. Starts two containers - one for MMT, one for postgres
# with volumes for the /app directory and the postgres data. /app dir mapped means that
# changes to the code reloads MMT.
Expand All @@ -20,6 +18,11 @@ services:
env_file:
- .env
platform: linux/amd64
healthcheck:
test: ["CMD-SHELL", "pg_isready --username=${DJANGO_DB_USER} --dbname=${DJANGO_DB_NAME}"]
start_period: 10s
restart: always

memorymaptoolkit:
image: memorymaptoolkit
build:
Expand All @@ -31,8 +34,15 @@ services:
- backups:/app/backups
- .:/app
depends_on:
- db
command: python manage.py runserver 0.0.0.0:8000 --settings=memorymap_toolkit.settings.local
db:
condition: service_healthy
command: >
bash -c "
python manage.py migrate && \
(python manage.py createsuperuser --noinput || echo 'Assuming preexisting user and continuing...') && \
python manage.py collectstatic --noinput && \
python manage.py runserver 0.0.0.0:8000
"
ports:
- 8000:8000
env_file:
Expand All @@ -47,8 +57,13 @@ services:
- DJANGO_SESSION_COOKIE_SECURE=${DJANGO_SESSION_COOKIE_SECURE}
- DJANGO_CSRF_COOKIE_SECURE=${DJANGO_CSRF_COOKIE_SECURE}
- DJANGO_DB_HOST=${DJANGO_DB_HOST}
- DJANGO_SETTINGS_MODULE=memorymap_toolkit.settings.local
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000')"]
restart: always

volumes:
postgres_data:
static:
media:
backups:
backups:
5 changes: 3 additions & 2 deletions memorymap_toolkit/settings/secret_settings_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY', '')

ALLOWED_HOSTS = [os.environ.get('DJANGO_ALLOWED_HOSTS', 'localhost')]
# Hosts are split in case more than one (space-separated) host is provided in the .env file
ALLOWED_HOSTS = os.environ.get('DJANGO_ALLOWED_HOSTS', 'localhost').split()

# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
Expand All @@ -29,4 +30,4 @@

# SESSION_COOKIE_SECURE = True

# CSRF_COOKIE_SECURE = True
# CSRF_COOKIE_SECURE = True
4 changes: 2 additions & 2 deletions mmt_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
except:
pw = os.environ.get('DJANGO_SUPERUSER_PASSWORD')
if pw:
u = User.objects.create(username=os.environ.get('DJANGO_SUPERUSER', 'admin'), is_superuser=True, is_staff=True)
u = User.objects.create(username=os.environ.get('DJANGO_SUPERUSER_USERNAME', 'admin'), is_superuser=True, is_staff=True)
u.set_password(pw)
u.save()
u.save()
1 change: 1 addition & 0 deletions project_static/js/mapHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ map.on('load', function() {
]
}
});

});


Expand Down