-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
115 lines (98 loc) · 2.68 KB
/
docker-compose.yml
File metadata and controls
115 lines (98 loc) · 2.68 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
# ============================================
# Docker Compose Configuration
# ============================================
#
# This file defines services for running the application locally
# or in a containerized environment.
#
# Services:
# - api: The main Node.js REST API
#
# Usage:
# - Development: docker-compose up
# - Production: docker-compose -f docker-compose.yml -f docker-compose.prod.yml up
# ============================================
version: '3.8'
services:
# ============================================
# API Service
# ============================================
api:
build:
context: .
dockerfile: Dockerfile
target: builder # Use builder stage for development (includes dev deps)
container_name: reservation-api
ports:
- "${PORT:-3000}:3000"
environment:
# Server Configuration
- NODE_ENV=development
- PORT=3000
- HOST=0.0.0.0
# API Configuration
- API_VERSION=v1
- API_PREFIX=/api
# CORS
- CORS_ORIGIN=*
- CORS_CREDENTIALS=true
# Rate Limiting
- RATE_LIMIT_WINDOW_MS=10000
- RATE_LIMIT_MAX_REQUESTS=20
# Cache
- CACHE_TTL_ITEMS=30000
- CACHE_TTL_DEFAULT=5000
# Database
- DB_PATH=/app/data/app.db
# Logging
- LOG_LEVEL=debug
- LOG_PRETTY_PRINT=true
# Reservation
- RESERVATION_TIMEOUT_MINUTES=10
volumes:
# Mount source code for hot reload in development
- ./src:/app/src:ro
# Persist database data
- app-data:/app/data
# Mount node_modules (prevents conflicts with host)
- node_modules:/app/node_modules
# Restart policy
restart: unless-stopped
# Health check
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))"]
interval: 30s
timeout: 3s
retries: 3
start_period: 5s
# Resource limits (prevent container from consuming all resources)
deploy:
resources:
limits:
cpus: '1.0'
memory: 512M
reservations:
cpus: '0.25'
memory: 256M
# Logging configuration
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# ============================================
# Volumes
# ============================================
volumes:
# Database data persistence
app-data:
driver: local
# Node modules (isolated from host)
node_modules:
driver: local
# ============================================
# Networks
# ============================================
networks:
default:
name: reservation-api-network