django_template/docker-compose.traefik.yml

79 lines
2.1 KiB
YAML

version: "3.8"
services:
# To use an built-in Postgres server, uncomment this service
#db:
# # Use regular Postgres by default
# image: postgres:15.3-bullseye
# # Use PostGIS for spatial apps
# #image: postgis/postgis:15-3.3
# env_file: .env
# volumes:
# - db_data:/var/lib/postgresql/data
# healthcheck:
# test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
# interval: 10s
# timeout: 5s
# retries: 5
# restart: "unless-stopped"
# networks:
# - backend
app:
image: localhost/your_app_image_here
build:
context: ./django
# To build image with extra dev tools
#dockerfile: Dockerfile.dev
command: python -m gunicorn myproject.wsgi -b 0.0.0.0:8000
env_file: .env
volumes:
- static_files:/static
- media_files:/media
- docs:/docs
# Comment this out if you're not using SQLite
- ./db:/db
restart: "unless-stopped"
# To use an built-in Postgres server, uncomment this dependency
#depends_on:
# db:
# condition: service_healthy
networks:
- backend
web:
image: mattcen/nginx_django
build: ./nginx
environment:
# Replace 'app' below with the name of the django service above
WEB_APP_HOST: app:8000
depends_on:
- app
volumes:
- static_files:/static
- media_files:/media
- docs:/docs
networks:
- backend
- proxy
restart: "unless-stopped"
labels:
traefik.enable: "true"
traefik.http.routers.replace_this_name_with_something_else.rule: Host(`your_domain_name_here.example.net`, `www.your_domain_name_here.example.net`)
traefik.http.routers.replace_this_name_with_something_else.entryPoints: websecure
traefik.http.services.replace_this_name_with_something_else.loadbalancer.server.port: 80
traefik.http.services.replace_this_name_with_something_else.loadbalancer.sticky: "true"
volumes:
db_data:
static_files:
media_files:
docs:
networks:
backend:
# The Traefik container should be on this network
proxy:
external: true