Skip to content
Open
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: 7 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SQL_ENGINE=django.db.backends.postgresql
SQL_DATABASE=hello_django_dev
SQL_USER=hello_django
SQL_PASSWORD=hello_django
SQL_HOST=db
SQL_PORT=5432
DATABASE=postgres
7 changes: 7 additions & 0 deletions .env.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SQL_ENGINE=django.db.backends.postgresql
SQL_DATABASE=hello_django_prod
SQL_USER=hello_django
SQL_PASSWORD=hello_django
SQL_HOST=db
SQL_PORT=5432
DATABASE=postgres
3 changes: 2 additions & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ djoser==2.0.5
djangorestframework==3.11.2 # https://github.com/sunscrapers/djoser/issues/541
markdown==3.3
django-filter==2.4.0
django_cors_headers==3.5.0
django_cors_headers==3.5.0
psycopg2-binary>=2.8
11 changes: 8 additions & 3 deletions backend/server/server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
https://docs.djangoproject.com/en/3.1/ref/settings/
"""

import os
from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
Expand Down Expand Up @@ -120,9 +121,13 @@
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
"default": {
"ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.sqlite3"),
"NAME": os.environ.get("SQL_DATABASE", BASE_DIR / "db.sqlite3"),
"USER": os.environ.get("SQL_USER", "user"),
"PASSWORD": os.environ.get("SQL_PASSWORD", "password"),
"HOST": os.environ.get("SQL_HOST", "localhost"),
"PORT": os.environ.get("SQL_PORT", "5432"),
}
}

Expand Down
19 changes: 15 additions & 4 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
version: '2'

services:
db:
image: postgres:13.0-alpine
volumes:
- postgres_data:/var/lib/postgresql/data/
environment:
- POSTGRES_USER=hello_django
- POSTGRES_PASSWORD=hello_django
- POSTGRES_DB=hello_django_dev
nginx:
restart: unless-stopped
build:
Expand All @@ -18,14 +26,17 @@ services:
build:
context: .
dockerfile: ./docker/backend/Dockerfile
volumes:

entrypoint: /app/docker/backend/wsgi-entrypoint.sh
volumes:
- .:/app
- static_volume:/app/backend/server/django_static
expose:
- 8000
- 8000
env_file:
- ./.env.dev
depends_on:
- db

volumes:
static_volume: {}
postgres_data:
static_volume:
15 changes: 14 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
version: '2'

services:
db:
image: postgres:13.0-alpine
volumes:
- postgres_data:/var/lib/postgresql/data/
environment:
- POSTGRES_USER=hello_django
- POSTGRES_PASSWORD=hello_django
- POSTGRES_DB=hello_django_prod
nginx:
restart: unless-stopped
build:
Expand Down Expand Up @@ -33,6 +41,11 @@ services:
- static_volume:/app/backend/server/django_static
expose:
- 8000
env_file:
- ./.env.prod
depends_on:
- db

volumes:
static_volume: {}
static_volume:
postgres_data: