-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
121 lines (111 loc) · 4.39 KB
/
docker-compose.yml
File metadata and controls
121 lines (111 loc) · 4.39 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
# Docker Compose configuration for Matrix Admin Panel System (MAPS)
# This file orchestrates the frontend and backend containers
services:
# Backend Service - FastAPI application
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: maps-backend
restart: unless-stopped
ports:
# Map container port 8000 to host port 8000
# Access backend API at http://localhost:8000
- "8000:8000"
extra_hosts:
# Allow container to access host services via host.docker.internal
# This enables the backend to reach Matrix server at 127.0.0.1:8008 on the host
- "host.docker.internal:host-gateway"
environment:
# DATABASE_URL in .env is for local uvicorn; Compose uses DOCKER_DATABASE_URL so a host
# sqlite:///./maps.db does not override the container path or the sqlite_data volume.
# For PostgreSQL in Docker: set DOCKER_DATABASE_URL=postgresql://...
- DATABASE_URL=${DOCKER_DATABASE_URL:-sqlite:///./sqlite_data/maps.db}
# Secret key for JWT token encryption
# Generate a secure key: openssl rand -hex 32
- SECRET_KEY=${SECRET_KEY:-your-secret-key-change-this}
# CORS origins - allow frontend to make requests
# Comma-separated list of allowed origins
- CORS_ORIGINS=${CORS_ORIGINS:-http://localhost:3000,http://127.0.0.1:3000}
# Matrix Synapse server URL
# For accessing host Matrix server from container, use host.docker.internal
# Example: http://host.docker.internal:8008 (for host Matrix server)
# Example: https://matrix.example.com (for external Matrix server)
- MATRIX_SERVER_URL=${MATRIX_SERVER_URL:-http://host.docker.internal:8008}
volumes:
# Mount a directory so maps.db is a real file (never bind-mount a non-existent file path).
# For PostgreSQL, remove this volume and use the db service below
- ./backend/sqlite_data:/app/sqlite_data
# Mount config and log file directories if needed
# Uncomment and adjust paths as needed:
- /etc/matrix-synapse:/etc/matrix-synapse:ro
- /var/log/matrix-synapse:/var/log/matrix-synapse:ro
networks:
- maps-network
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health')"]
interval: 45s
timeout: 5s
retries: 3
start_period: 30s
# Frontend Service - Next.js application
frontend:
build:
context: .
dockerfile: Dockerfile
args:
# Same-origin /api proxy; leave empty. Rewrites target the backend container.
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-}
BACKEND_INTERNAL_URL: ${BACKEND_INTERNAL_URL:-http://backend:8000}
container_name: maps-frontend
restart: unless-stopped
ports:
# Map container port 3000 to host port 3000
# Access frontend at http://localhost:3000
- "3000:3000"
environment:
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-}
# Must match backend SECRET_KEY (Next.js middleware verifies JWTs)
- JWT_SECRET=${SECRET_KEY}
depends_on:
backend:
condition: service_healthy
networks:
- maps-network
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://127.0.0.1:3000/', (r) => process.exit(r.statusCode === 200 ? 0 : 1)).on('error', () => process.exit(1))"]
interval: 45s
timeout: 5s
retries: 3
start_period: 60s
# PostgreSQL Database (Optional)
# Uncomment this service if you want to use PostgreSQL instead of SQLite
# Make sure to update DATABASE_URL in backend environment to:
# postgresql://maps_user:maps_password@db:5432/maps_db
#
# db:
# image: postgres:16-alpine
# container_name: maps-db
# restart: unless-stopped
# environment:
# POSTGRES_USER: ${POSTGRES_USER:-maps_user}
# POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-maps_password}
# POSTGRES_DB: ${POSTGRES_DB:-maps_db}
# volumes:
# # Persist database data
# - postgres_data:/var/lib/postgresql/data
# networks:
# - maps-network
# healthcheck:
# test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-maps_user}"]
# interval: 10s
# timeout: 5s
# retries: 5
# Docker network for service communication
networks:
maps-network:
driver: bridge
# Volumes for persistent data
# Uncomment if using PostgreSQL
# volumes:
# postgres_data: