forked from Loqicx/join
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
166 lines (161 loc) · 6.76 KB
/
docker-compose.yml
File metadata and controls
166 lines (161 loc) · 6.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
services:
# Traefik Reverse Proxy
traefik:
image: traefik:v2.11
container_name: join-traefik
restart: unless-stopped
command:
# Enable Docker provider
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
# Entry points
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
# Optional: Enable dashboard (remove in production or secure it)
- "--api.dashboard=true"
- "--api.insecure=${TRAEFIK_DASHBOARD_INSECURE:-false}"
# Logging
- "--log.level=${TRAEFIK_LOG_LEVEL:-INFO}"
- "--accesslog=true"
# Optional: Let's Encrypt SSL (uncomment for production with real domain)
# - "--certificatesresolvers.letsencrypt.acme.tlschallenge=true"
# - "--certificatesresolvers.letsencrypt.acme.email=${ACME_EMAIL}"
# - "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
ports:
- "${TRAEFIK_HTTP_PORT:-80}:80"
- "${TRAEFIK_HTTPS_PORT:-443}:443"
- "${TRAEFIK_DASHBOARD_PORT:-8080}:8080" # Dashboard
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- traefik-certificates:/letsencrypt
networks:
- web
labels:
- "traefik.enable=true"
# Dashboard (uses subdomain pattern for separation from main app)
- "traefik.http.routers.traefik.rule=Host(`traefik.${DOMAIN:-localhost}`)"
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.routers.traefik.entrypoints=web"
# Backend - Django REST API
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: join-backend
restart: unless-stopped
environment:
# Django settings
- DJANGO_SECRET_KEY=${DJANGO_SECRET_KEY:-django-insecure-change-this-in-production}
- DJANGO_DEBUG=${DJANGO_DEBUG:-False}
- DJANGO_ALLOWED_HOSTS=${DJANGO_ALLOWED_HOSTS:-backend,localhost,127.0.0.1}
- DJANGO_CSRF_TRUSTED_ORIGINS=${DJANGO_CSRF_TRUSTED_ORIGINS:-https://localhost,https://127.0.0.1}
- DJANGO_CORS_ALLOWED_ORIGINS=${DJANGO_CORS_ALLOWED_ORIGINS:-https://localhost,https://127.0.0.1}
# Database settings (for future PostgreSQL migration)
- DB_ENGINE=${DB_ENGINE:-django.db.backends.sqlite3}
- DB_NAME=${DB_NAME:-db.sqlite3}
- DB_USER=${DB_USER:-}
- DB_PASSWORD=${DB_PASSWORD:-}
- DB_HOST=${DB_HOST:-}
- DB_PORT=${DB_PORT:-}
# Django superuser creation (optional)
- DJANGO_SUPERUSER_USERNAME=${DJANGO_SUPERUSER_USERNAME:-}
- DJANGO_SUPERUSER_EMAIL=${DJANGO_SUPERUSER_EMAIL:-}
- DJANGO_SUPERUSER_PASSWORD=${DJANGO_SUPERUSER_PASSWORD:-}
volumes:
- backend-data:/app/data
- backend-static:/app/staticfiles
networks:
- web
labels:
- "traefik.enable=true"
# HTTP router - backend accessible at /api/ and /admin/ paths on main domain
- "traefik.http.routers.backend.rule=Host(`${DOMAIN:-localhost}`) && (PathPrefix(`/api`) || PathPrefix(`/admin`))"
- "traefik.http.routers.backend.entrypoints=web"
- "traefik.http.routers.backend.priority=100"
- "traefik.http.services.backend.loadbalancer.server.port=8000"
# HTTPS router - uses Traefik default certificate (or Let's Encrypt if configured)
- "traefik.http.routers.backend-secure.rule=Host(`${DOMAIN:-localhost}`) && (PathPrefix(`/api`) || PathPrefix(`/admin`))"
- "traefik.http.routers.backend-secure.entrypoints=websecure"
- "traefik.http.routers.backend-secure.priority=100"
- "traefik.http.routers.backend-secure.tls=true"
# Uncomment the next line to use Let's Encrypt instead of Traefik default certificate
# - "traefik.http.routers.backend-secure.tls.certresolver=letsencrypt"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/admin/"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Static Server - Serves Django admin and DRF static files
static-server:
build:
context: ./static-server
dockerfile: Dockerfile
container_name: join-static-server
restart: unless-stopped
volumes:
- backend-static:/usr/share/nginx/html/static:ro
networks:
- web
labels:
- "traefik.enable=true"
# HTTP router - serves /static/ path
- "traefik.http.routers.static-server.rule=Host(`${DOMAIN:-localhost}`) && PathPrefix(`/static`)"
- "traefik.http.routers.static-server.entrypoints=web"
- "traefik.http.routers.static-server.priority=110"
- "traefik.http.services.static-server.loadbalancer.server.port=80"
# HTTPS router - uses Traefik default certificate (or Let's Encrypt if configured)
- "traefik.http.routers.static-server-secure.rule=Host(`${DOMAIN:-localhost}`) && PathPrefix(`/static`)"
- "traefik.http.routers.static-server-secure.entrypoints=websecure"
- "traefik.http.routers.static-server-secure.priority=110"
- "traefik.http.routers.static-server-secure.tls=true"
# Uncomment the next line to use Let's Encrypt instead of Traefik default certificate
# - "traefik.http.routers.static-server-secure.tls.certresolver=letsencrypt"
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
depends_on:
- backend
# Frontend - Angular Application
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: join-frontend
restart: unless-stopped
environment:
- API_URL=${API_URL:-https://localhost/}
networks:
- web
labels:
- "traefik.enable=true"
# HTTP router - frontend handles all paths on main domain except backend paths
- "traefik.http.routers.frontend.rule=Host(`${DOMAIN:-localhost}`)"
- "traefik.http.routers.frontend.entrypoints=web"
- "traefik.http.routers.frontend.priority=1"
- "traefik.http.services.frontend.loadbalancer.server.port=80"
# HTTPS router - uses Traefik default certificate (or Let's Encrypt if configured)
- "traefik.http.routers.frontend-secure.rule=Host(`${DOMAIN:-localhost}`)"
- "traefik.http.routers.frontend-secure.entrypoints=websecure"
- "traefik.http.routers.frontend-secure.priority=1"
- "traefik.http.routers.frontend-secure.tls=true"
# Uncomment the next line to use Let's Encrypt instead of Traefik default certificate
# - "traefik.http.routers.frontend-secure.tls.certresolver=letsencrypt"
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
depends_on:
- backend
networks:
web:
driver: bridge
volumes:
traefik-certificates:
backend-data:
backend-static: