Created
April 2, 2019 18:07
-
-
Save tarkatronic/1be8ce121f1c2374195a873e448b4e2b to your computer and use it in GitHub Desktop.
Basic Django app running in Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
web: | |
build: . | |
restart: "always" | |
command: python manage.py runserver 0.0.0.0:8000 | |
depends_on: | |
- database | |
ports: | |
- "8000:8000" | |
database: | |
image: postgres | |
environment: | |
POSTGRES_USER: django_test | |
POSTGRES_PASSWORD: django_test | |
POSTGRES_DB: django_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:alpine | |
RUN apk add --update \ | |
build-base \ | |
postgresql-dev | |
WORKDIR /source | |
ADD requirements.txt . | |
RUN pip install -r requirements.txt | |
ADD . /source | |
CMD python manage.py runserver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is the only thing which needs to be changed in the settings, for the purposes of this demo | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.postgresql', | |
'NAME': 'django_test', | |
'USER': 'django_test', | |
'HOST': 'database', | |
'PORT': 5432, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment