Skip to content

Commit

Permalink
trying to test deployment docker compose file
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKassab committed Sep 18, 2024
1 parent c39c667 commit 0f82abf
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DB_NAME=dbname
DB_USER=rootuser
DB_PASS=changeme
DJANGO_SECRET_KEY=changeme
DJANGO_ALLOWED_HOSTS=127.0.0.1
10 changes: 8 additions & 2 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-=31wv7=*=_g#x%p5o4^v-9a_h*qxw56n$q*!_ou^g(b3=$z3@!'
SECRET_KEY = os.environ.get('SECRET_KEY', 'changeme')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = bool(int(os.environ.get('DEBUG', 0)))

ALLOWED_HOSTS = []
ALLOWED_HOSTS.extend(
filter(
None,
os.environ.get('ALLOWED_HOSTS', '').split(',')
)
)


# Application definition
Expand Down
43 changes: 43 additions & 0 deletions docker-compose-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: "3.9"

services:
app:
build:
context: .
restart: always
volumes:
- static-data:/vol/web
environment:
- DB_HOST=db
- DB_NAME=${DB_NAME}
- DB_USER=${DB_USER}
- DB_PASS=${DB_PASS}
- SECRET_KEY=${DJANGO_SECRET_KEY}
- ALLOWED_HOSTS=${DJANGO_ALLOWED_HOSTS}
depends_on:
- db

db:
image: postgres:13-alpine
restart: always
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
- POSTGRES_DB=${DB_NAME}
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASS}

proxy:
build:
context: ./proxy
restart: always
depends_on:
- app
ports:
- 8000:8000
volumes:
- static-data:/vol/static

volumes:
postgres-data:
static-data:
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
- DB_NAME=devdb
- DB_USER=devuser
- DB_PASS=changeme
- DEBUG=1
depends_on:
- db

Expand Down

0 comments on commit 0f82abf

Please sign in to comment.