Skip to content

Commit dbff9c2

Browse files
committed
Herokuize
1 parent 507465c commit dbff9c2

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn boarddash.wsgi

boarddash/settings.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""
1212

1313
import os
14+
import django_heroku
1415

1516
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
1617
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -19,11 +20,10 @@
1920
# Quick-start development settings - unsuitable for production
2021
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
2122

22-
# SECURITY WARNING: keep the secret key used in production secret!
23-
SECRET_KEY = 'q7!62))q4n1+5pe($nhoq#p#xpm2kgm1b0%^sozedh#$a2+@=x'
23+
SECRET_KEY = "{{ secret_key }}"
2424

2525
# SECURITY WARNING: don't run with debug turned on in production!
26-
DEBUG = True
26+
DEBUG = os.environ.get("DEBUG") == "1"
2727

2828
ALLOWED_HOSTS = []
2929

@@ -77,11 +77,16 @@
7777

7878
DATABASES = {
7979
'default': {
80-
'ENGINE': 'django.db.backends.sqlite3',
81-
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
80+
'ENGINE': 'django.db.backends.postgresql',
81+
'NAME': 'postgres',
82+
'USER': 'postgres',
83+
'HOST': 'db',
84+
'PORT': 5432,
8285
}
8386
}
8487

88+
import dj_database_url
89+
DATABASES['default'].update(dj_database_url.config(conn_max_age=500))
8590

8691
# Password validation
8792
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
@@ -122,3 +127,7 @@
122127
STATIC_URL = '/static/'
123128

124129
REQUESTS_TIMEOUT_SECONDS = 20
130+
131+
# Activate Django-Heroku.
132+
django_heroku.settings(locals(), logging=not DEBUG, databases=not DEBUG)
133+

docker-compose.yml

+10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
version: '3'
22

3+
volumes:
4+
postgres-data:
5+
driver: local
6+
37
services:
48
db:
59
image: postgres
10+
volumes:
11+
- postgres-data:/var/lib/postgresql/data
612
web:
713
build: .
814
volumes:
915
- .:/code
1016
ports:
1117
- "8000:8000"
18+
environment:
19+
- DATABASE_URL=postgres://postgres:postgres@db/postgres
20+
- SECRET_KEY=developmentkittenssup
21+
- DEBUG=1
1222
depends_on:
1323
- db

requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
django==2.1.1
22
django-bootstrap4==0.0.7
33
requests==2.19.1
4+
gunicorn==19.9.0
5+
django-heroku
6+
dj_database_url

0 commit comments

Comments
 (0)