-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
127 lines (121 loc) · 3.36 KB
/
docker-compose.prod.yml
File metadata and controls
127 lines (121 loc) · 3.36 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
version: '3.8'
services:
# PostgreSQL Database with pgvector
postgres:
image: pgvector/pgvector:pg16
container_name: secondbrain-postgres
environment:
POSTGRES_DB: secondbrain
POSTGRES_USER: secondbrain
POSTGRES_PASSWORD: secondbrain_password
POSTGRES_INITDB_ARGS: "--auth-host=scram-sha-256"
command: >
postgres
-c shared_preload_libraries=pg_stat_statements
-c pg_stat_statements.max=10000
-c pg_stat_statements.track=all
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- secondbrain-network
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U secondbrain -d secondbrain"]
interval: 5s
timeout: 5s
retries: 5
# Database initializer - ensures tables exist
db-init:
image: pgvector/pgvector:pg16
container_name: secondbrain-db-init
environment:
PGHOST: postgres
PGUSER: secondbrain
PGPASSWORD: secondbrain_password
PGDATABASE: secondbrain
volumes:
- ./database/init-scripts:/init-scripts
networks:
- secondbrain-network
depends_on:
postgres:
condition: service_healthy
restart: "no"
command: >
bash -c "
echo 'Running database initialization scripts...'
for f in /init-scripts/*.sql; do
[ -e \"$$f\" ] || continue
echo \"Executing $$f\"
psql -f \"$$f\"
done
echo 'Database initialization completed'
"
# FastAPI Backend
backend:
build:
context: ./backend
dockerfile: Dockerfile.prod
image: secondbrain-backend:prod
container_name: secondbrain-backend
env_file:
- .env
environment:
- DATABASE_URL=postgresql+asyncpg://secondbrain:secondbrain_password@postgres:5432/secondbrain
- AZURE_OPENAI_API_KEY=${AZURE_OPENAI_API_KEY}
- AZURE_OPENAI_ENDPOINT=${AZURE_OPENAI_ENDPOINT}
- AZURE_OPENAI_API_VERSION=${AZURE_OPENAI_API_VERSION}
- AZURE_OPENAI_DEPLOYMENT_NAME=${AZURE_OPENAI_DEPLOYMENT_NAME}
- AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME=${AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME}
- AZURE_MINI_DEPLOYMENT_NAME=${AZURE_MINI_DEPLOYMENT_NAME}
ports:
- "${BACKEND_PORT:-8000}:8000"
volumes:
- uploads:/app/uploads
networks:
- secondbrain-network
depends_on:
postgres:
condition: service_healthy
db-init:
condition: service_completed_successfully
# todo: remove, once it works
# command: sleep infinity
restart: unless-stopped
# healthcheck:
# test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
# interval: 30s
# timeout: 10s
# retries: 3
# start_period: 40s
# SvelteKit Frontend
frontend:
build:
context: ./frontend
dockerfile: Dockerfile.prod
image: secondbrain-frontend:prod
container_name: secondbrain-frontend
environment:
- NODE_ENV=production
- BODY_SIZE_LIMIT=52428800
ports:
- "3000:3000"
networks:
- secondbrain-network
depends_on:
- backend
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
volumes:
postgres_data:
driver: local
uploads:
driver: local
networks:
secondbrain-network:
driver: bridge