-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
153 lines (145 loc) · 3.79 KB
/
docker-compose.yml
File metadata and controls
153 lines (145 loc) · 3.79 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
# Compose v2+ syntax (no explicit version key needed)
# Reusable env-file anchor
x-env: &default-env
env_file:
- .env
networks:
plugbot-network:
driver: bridge
volumes:
postgres_data:
redis_data:
services:
db:
image: postgres:16-alpine
restart: unless-stopped
<<: *default-env
environment:
POSTGRES_INITDB_ARGS: "--encoding=UTF8"
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
# Optional but nice to have
TZ: ${TZ:-UTC}
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
interval: 10s
timeout: 5s
retries: 5
networks:
- plugbot-network
redis:
image: redis:7-alpine
restart: unless-stopped
command: >
redis-server
--appendonly yes
--maxmemory 256mb
--maxmemory-policy allkeys-lru
volumes:
- redis_data:/data
healthcheck:
# 'ping' returns PONG when healthy
test: [ "CMD", "redis-cli", "ping" ]
interval: 10s
timeout: 5s
retries: 5
networks:
- plugbot-network
# NEW: run DB migrations once, then exit successfully.
migrator:
build:
context: ./backend
dockerfile: Dockerfile
restart: "no"
init: true
<<: *default-env
environment:
# only what the migrator actually needs
DATABASE_URL: ${DATABASE_URL}
TZ: ${TZ:-UTC}
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
command: >
sh -c "alembic upgrade head"
networks:
- plugbot-network
backend:
build:
context: ./backend
dockerfile: Dockerfile
restart: unless-stopped
init: true
<<: *default-env
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
migrator:
condition: service_completed_successfully
environment:
DATABASE_URL: ${DATABASE_URL}
REDIS_URL: ${REDIS_URL}
SECRET_KEY: ${SECRET_KEY}
ENCRYPTION_KEY: ${ENCRYPTION_KEY}
BACKEND_CORS_ORIGINS: ${BACKEND_CORS_ORIGINS}
SMTP_HOST: ${SMTP_HOST}
SMTP_PORT: ${SMTP_PORT}
SMTP_USERNAME: ${SMTP_USERNAME}
SMTP_PASSWORD: ${SMTP_PASSWORD}
SMTP_FROM: ${SMTP_FROM}
SMTP_STARTTLS: ${SMTP_STARTTLS}
DEFAULT_LANGUAGE: ${DEFAULT_LANGUAGE}
ALLOW_REGISTRATION: ${ALLOW_REGISTRATION}
FRONTEND_URL: ${FRONTEND_URL}
TZ: ${TZ:-UTC}
ports:
- "${BACKEND_PORT}:8000"
# If you later add HTTPS termination inside the container, expose it here:
# - "${BACKEND_HTTPS_PORT:-8532}:8443"
command: >
uvicorn app.main:app
--host 0.0.0.0
--port 8000
--proxy-headers
--forwarded-allow-ips='*'
healthcheck:
test: [ "CMD", "curl", "-fsS", "http://localhost:8000/health" ]
interval: 30s
timeout: 10s
retries: 3
networks:
- plugbot-network
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
args:
# CRITICAL: build-time public URL for Next.js (must be HTTPS in prod)
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL}
restart: unless-stopped
init: true
depends_on:
backend:
condition: service_healthy
environment:
NODE_ENV: production
# Runtime exposure (handy for client-side fetches)
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL}
TZ: ${TZ:-UTC}
ports:
- "${FRONTEND_PORT}:3000"
healthcheck:
# Use a lightweight HEAD to the root (adjust to your /health route if you have one)
test: [ "CMD", "curl", "-fsS", "http://localhost:3000" ]
interval: 30s
timeout: 10s
retries: 3
networks:
- plugbot-network