Skip to content

Instantly share code, notes, and snippets.

@tarkatronic
Created April 2, 2019 18:07
Show Gist options
  • Save tarkatronic/1be8ce121f1c2374195a873e448b4e2b to your computer and use it in GitHub Desktop.
Save tarkatronic/1be8ce121f1c2374195a873e448b4e2b to your computer and use it in GitHub Desktop.
Basic Django app running in Docker
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
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 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