-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.unified.yml
More file actions
162 lines (153 loc) · 5.81 KB
/
Copy pathdocker-compose.unified.yml
File metadata and controls
162 lines (153 loc) · 5.81 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
services:
# PostgreSQL Database for APItokenmanager and JWT services
postgres:
image: postgres:15
container_name: brainkb-postgres
environment:
POSTGRES_USER: ${JWT_POSTGRES_DATABASE_USER:-postgres}
POSTGRES_PASSWORD: ${JWT_POSTGRES_DATABASE_PASSWORD:-postgres}
POSTGRES_DB: ${JWT_POSTGRES_DATABASE_NAME:-brainkb}
ports:
- "${JWT_POSTGRES_DATABASE_PORT:-5432}:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- brainkb-network
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${JWT_POSTGRES_DATABASE_USER:-postgres}"]
interval: 10s
timeout: 5s
retries: 5
# Unified BrainKB Services Container
brainkb-unified:
build:
context: .
dockerfile: Dockerfile.unified
container_name: brainkb-unified
env_file:
- .env
ports:
- "${API_TOKEN_PORT:-8000}:8000"
- "${QUERY_SERVICE_PORT:-8010}:8010"
- "${ML_SERVICE_PORT:-8007}:8007"
volumes:
- ./logs:/var/log/supervisor
networks:
- brainkb-network
depends_on:
postgres:
condition: service_healthy
restart: unless-stopped
# Resource limits to utilize available CPUs
deploy:
resources:
limits:
cpus: '8.0' # Use up to 8 CPUs (out of 12 available)
memory: 16G # Increase memory limit
reservations:
cpus: '2.0' # Reserve 2 CPUs minimum
memory: 4G
healthcheck:
test: ["CMD-SHELL", "/app/healthcheck.sh"]
interval: 30s
timeout: 10s
retries: 5
start_period: 90s
# Oxigraph SPARQL Database (separate service)
# Note: Oxigraph is not directly exposed - access through oxigraph-nginx service
oxigraph:
image: ghcr.io/oxigraph/oxigraph:latest
container_name: brainkb-oxigraph
# No port mapping - only accessible through oxigraph-nginx
volumes:
# Use named volume for local development, or custom path via OXIGRAPH_DATA_PATH
# For production with shared storage, set OXIGRAPH_DATA_PATH=/fsx/brainkb-kg-repo in .env
- ${OXIGRAPH_DATA_PATH:-oxigraph_data}:/data
- ${OXIGRAPH_TMP_PATH:-oxigraph_tmp}:/tmp
environment:
- TMPDIR=/tmp
command: ["serve", "--location", "/data", "--bind", "0.0.0.0:7878"]
ulimits:
fsize: -1
nofile: 65536 # Increase file descriptor limit for concurrent connections
networks:
- brainkb-network
restart: unless-stopped
# Note: For resource limits, use Docker run flags or configure in your orchestration platform
# Recommended: 8GB memory, 4 CPUs for large concurrent uploads
# Example: docker update --memory=8g --cpus=4.0 brainkb-oxigraph
# Note: Healthcheck removed - oxigraph uses distroless image without shell/tools
# The service is working (check logs: docker logs brainkb-oxigraph)
# oxigraph-nginx will handle connection failures gracefully
# Note: Old Oxigraph storage format data in /fsx/brainkb-kg-repo should load automatically
# If data doesn't load, check:
# 1. Permissions: Ensure /fsx/brainkb-kg-repo is readable by container (chmod -R 755 /fsx/brainkb-kg-repo)
# 2. Path exists: Verify /fsx/brainkb-kg-repo exists on host
# 3. Data location: Old data should be directly in /data (not in subdirectories)
# 4. Version compatibility: Old Oxigraph data should be compatible with latest version
# Nginx reverse proxy with HTTP Basic Authentication for Oxigraph
oxigraph-nginx:
image: nginx:1.21.4
container_name: brainkb-oxigraph-nginx
env_file:
- .env
environment:
OXIGRAPH_USER: ${OXIGRAPH_USER:-admin}
OXIGRAPH_PASSWORD: ${OXIGRAPH_PASSWORD:-pwdoxigraph}
volumes:
- ./oxigraph/nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- "${OXIGRAPH_PORT:-7878}:7878"
networks:
- brainkb-network
depends_on:
- oxigraph
# Note: oxigraph uses distroless image, so no healthcheck available
# Nginx will start when oxigraph container starts and handle connection failures gracefully
restart: unless-stopped
# Note: For resource limits, use Docker run flags or configure in your orchestration platform
# Recommended: 2GB memory, 2 CPUs for handling concurrent uploads
# Example: docker update --memory=2g --cpus=2.0 brainkb-oxigraph-nginx
ulimits:
nofile: 65536 # Increase file descriptor limit for concurrent connections
entrypoint: >
sh -c 'echo -n "$$OXIGRAPH_USER:" > /etc/nginx/.htpasswd &&
echo "$$OXIGRAPH_PASSWORD" | openssl passwd -stdin -apr1 >> /etc/nginx/.htpasswd &&
chmod 644 /etc/nginx/.htpasswd &&
/docker-entrypoint.sh nginx -g "daemon off;"'
# pgAdmin for PostgreSQL management
pgadmin:
image: dpage/pgadmin4:latest
container_name: brainkb-pgadmin
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-admin@brainkb.org}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin}
PGADMIN_SERVER_NAME: ${PGADMIN_SERVER_NAME:-BrainKB PostgreSQL}
ports:
- "${PGADMIN_PORT:-5051}:80"
volumes:
- pgadmin_data:/var/lib/pgadmin
- ./pgadmin-init/servers.json:/pgadmin4/servers.json:ro
networks:
- brainkb-network
depends_on:
postgres:
condition: service_healthy
restart: unless-stopped
# Note: PostgreSQL server is automatically configured on startup
# Note: You may see periodic "database postgres_admin does not exist" errors in PostgreSQL logs.
# These are harmless - they come from pgAdmin's internal health checks that don't use MaintenanceDB.
# pgAdmin correctly uses MaintenanceDB: "brainkb" from servers.json for actual operations.
volumes:
postgres_data:
driver: local
oxigraph_data:
driver: local
oxigraph_tmp:
driver: local
pgadmin_data:
driver: local
networks:
brainkb-network:
external: true