forked from sylvester-francis/Resource-Reserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
188 lines (180 loc) · 5.56 KB
/
Copy pathdocker-compose.yml
File metadata and controls
188 lines (180 loc) · 5.56 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
181
182
183
184
185
186
187
188
# =============================================================================
# Resource Reserver - Docker Compose Configuration
# =============================================================================
# Copy .env.docker to .env and customize for your deployment.
# See .env.docker for detailed documentation of all configuration options.
# =============================================================================
services:
# FastAPI Backend Service
backend:
build:
context: .
dockerfile: Dockerfile.backend
args:
- HTTP_PROXY=${HTTP_PROXY:-}
- HTTPS_PROXY=${HTTPS_PROXY:-}
container_name: resource-reserver-backend
ports:
- "${BACKEND_PORT:-8000}:8000"
environment:
- DATABASE_URL=${DATABASE_URL:-sqlite:///./data/db/resource_reserver.db}
- ENVIRONMENT=${ENVIRONMENT:-production}
- SECRET_KEY=${SECRET_KEY:-your-secret-key-change-in-production}
- REDIS_URL=${REDIS_URL:-redis://redis:6379/0}
- CACHE_ENABLED=${CACHE_ENABLED:-true}
- RATE_LIMIT_ENABLED=${RATE_LIMIT_ENABLED:-true}
- EMAIL_ENABLED=${EMAIL_ENABLED:-false}
- SMTP_HOST=${SMTP_HOST:-}
- SMTP_PORT=${SMTP_PORT:-587}
- SMTP_USER=${SMTP_USER:-}
- SMTP_PASSWORD=${SMTP_PASSWORD:-}
- SMTP_FROM=${SMTP_FROM:-noreply@resource-reserver.local}
- SMTP_FROM_NAME=${SMTP_FROM_NAME:-Resource Reserver}
volumes:
- backend_data:/app/data
- backend_logs:/app/logs
networks:
- resource-reserver-network
depends_on:
redis:
condition: service_healthy
restart: unless-stopped
healthcheck:
test: ["CMD", "python", "-c", "import requests; requests.get('http://localhost:8000/health')"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Next.js Frontend Service
# API Proxy Mode: When NEXT_PUBLIC_API_URL is empty, all /api/* requests are
# proxied through Next.js rewrites to the backend. This is recommended for
# enterprise deployments behind corporate proxies.
frontend:
build:
context: .
dockerfile: Dockerfile.frontend
args:
- HTTP_PROXY=${HTTP_PROXY:-}
- HTTPS_PROXY=${HTTPS_PROXY:-}
- NO_PROXY=${NO_PROXY:-}
# Empty = API proxy mode (recommended), or set full URL for direct mode
- NEXT_PUBLIC_API_URL=${NEXT_PUBLIC_API_URL:-}
container_name: resource-reserver-frontend
ports:
- "${FRONTEND_PORT:-8081}:3000"
environment:
- NODE_ENV=${NODE_ENV:-production}
# Internal URL for server-side API calls (container-to-container)
- INTERNAL_API_URL=${INTERNAL_API_URL:-http://backend:8000}
networks:
- resource-reserver-network
depends_on:
backend:
condition: service_healthy
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Redis Cache Service
redis:
image: public.ecr.aws/docker/library/redis:7-alpine
container_name: resource-reserver-redis
ports:
- "${REDIS_PORT:-6379}:6379"
volumes:
- redis_data:/data
networks:
- resource-reserver-network
restart: unless-stopped
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
command: redis-server --appendonly yes
# PostgreSQL Database (Optional - for production)
postgres:
image: public.ecr.aws/docker/library/postgres:15-alpine
container_name: resource-reserver-postgres
environment:
- POSTGRES_DB=resource_reserver
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-postgres}
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- resource-reserver-network
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 30s
timeout: 10s
retries: 3
ports:
- "5432:5432"
profiles:
- postgres
# Development Backend (with hot reload)
backend-dev:
build:
context: .
dockerfile: Dockerfile.dev
container_name: resource-reserver-backend-dev
ports:
- "8001:8000"
environment:
- DATABASE_URL=sqlite:///./data/db/resource_reserver_dev.db
- ENVIRONMENT=development
- SECRET_KEY=dev-secret-key
- REDIS_URL=redis://redis:6379/0
- CACHE_ENABLED=true
- RATE_LIMIT_ENABLED=false
volumes:
- ./apps/backend/app:/app/app
- ./apps/backend/cli:/app/cli
- ./data:/app/data
networks:
- resource-reserver-network
depends_on:
- redis
command: ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
profiles:
- dev
# Development Frontend (Next.js with hot reload using Bun)
frontend-dev:
image: oven/bun:1-alpine
container_name: resource-reserver-frontend-dev
working_dir: /app
ports:
- "3001:3000"
environment:
- NODE_ENV=development
- NEXT_PUBLIC_API_URL=http://backend-dev:8000
volumes:
- ./apps/frontend:/app
- /app/node_modules
- /app/.next
networks:
- resource-reserver-network
depends_on:
- backend-dev
command: ["sh", "-c", "bun install && bun run dev"]
profiles:
- dev
# Named volumes for data persistence
volumes:
backend_data:
driver: local
backend_logs:
driver: local
postgres_data:
driver: local
redis_data:
driver: local
# Network for service communication
networks:
resource-reserver-network:
driver: bridge