-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
180 lines (173 loc) · 5 KB
/
docker-compose.dev.yml
File metadata and controls
180 lines (173 loc) · 5 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
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
-c log_statement=all
-c log_duration=on
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
- ./database/init-scripts:/docker-entrypoint-initdb.d
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:pg15
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 'Checking database tables...' &&
TABLE_COUNT=$$(psql -tAc \"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='public' AND table_type='BASE TABLE';\") &&
echo \"Found $$TABLE_COUNT tables\" &&
if [ \"$$TABLE_COUNT\" -lt \"4\" ]; then
echo 'Creating database schema...' &&
for script in /init-scripts/*.sql; do
echo \"Running $$script...\" &&
psql < \"$$script\"
done &&
echo 'Database initialization complete!'
else
echo 'Database tables already exist'
fi
"
# FastAPI Backend
backend:
build: ./backend
container_name: secondbrain-backend
working_dir: /app
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_MINI_DEPLOYMENT_NAME=${AZURE_MINI_DEPLOYMENT_NAME}
- AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME=${AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME:-text-embedding-3-small}
- SECRET_KEY=${SECRET_KEY}
- LLM_PROVIDER=${LLM_PROVIDER:-azure_openai}
- "OLLAMA_BASE_URL=${OLLAMA_BASE_URL:-http://host.docker.internal:11434}"
- OLLAMA_MODEL=${OLLAMA_MODEL:-smollm2:135m}
- OLLAMA_EMBEDDING_MODEL=${OLLAMA_EMBEDDING_MODEL:-nomic-embed-text}
# - CORS_ORIGINS=http://localhost:5173,http://frontend:5173
ports:
- "8000:8000"
volumes:
- ./backend:/app
- uploads:/app/uploads
networks:
- secondbrain-network
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
postgres:
condition: service_healthy
db-init:
condition: service_completed_successfully
restart: unless-stopped
# command: sleep infinity
command: ./startup.sh
# command: >
# bash -c "
# apt-get update && apt-get install -y gcc curl &&
# pip install -r requirements.txt &&
# python run.py
# "
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# SvelteKit Frontend
frontend:
image: node:24-slim
container_name: secondbrain-frontend
working_dir: /app
environment:
- NODE_ENV=development
ports:
- "5174:5173"
volumes:
- ./frontend:/app
- frontend_node_modules:/app/node_modules
networks:
- secondbrain-network
depends_on:
- backend
- db-init
restart: unless-stopped
# command: sleep infinity
command: >
bash -c "
npm install &&
npm run dev -- --host 0.0.0.0
"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5173"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
# Optional: pgAdmin for database management
pgadmin:
image: dpage/pgadmin4:latest
container_name: secondbrain-pgadmin
environment:
PGADMIN_DEFAULT_EMAIL: tobias.pitters@gmail.com
PGADMIN_DEFAULT_PASSWORD: admin
PGADMIN_CONFIG_SERVER_MODE: 'False'
ports:
- "5050:80"
depends_on:
- postgres
networks:
- secondbrain-network
restart: unless-stopped
volumes:
- pgadmin_data:/var/lib/pgadmin
volumes:
postgres_data:
driver: local
pgadmin_data:
driver: local
backend_venv:
driver: local
frontend_node_modules:
driver: local
uploads:
driver: local
networks:
secondbrain-network:
driver: bridge