-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
91 lines (85 loc) · 2.46 KB
/
docker-compose.prod.yml
File metadata and controls
91 lines (85 loc) · 2.46 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
# Production-style stack on a single EC2 host: Postgres + Redis + web (nginx) + Nest API.
# RedisInsight intentionally omitted — use RDS/ElastiCache or SSM bastion tooling in real prod.
#
# Required on the EC2 instance:
# - .env beside this file (JWT, POSTGRES_URL, REDIS_URL, AWS_*, APP_*, PORTS, secrets)
# - WEB_IMAGE / BACKEND_IMAGE exported (ECR URIs produced by CI)
#
# Typical POSTGRES_URL host: nodejs-monorepo-postgres
# Typical REDIS_URL: redis://nodejs-monorepo-redis:6379/<db?>
services:
nodejs-monorepo-postgres:
container_name: nodejs-monorepo-postgres
image: postgres:17.5-alpine3.22
restart: always
volumes:
- nodejs-monorepo-postgres-data:/var/lib/postgresql/data
env_file:
- .env
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
PGUSER: ${POSTGRES_USER}
networks:
- nodejs-monorepo-network
healthcheck:
test: pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
nodejs-monorepo-redis:
container_name: nodejs-monorepo-redis
image: redis:8.0.2-alpine
restart: unless-stopped
volumes:
- nodejs-monorepo-redis-data:/data
env_file:
- .env
ports:
- "${REDIS_PORT:-6379}:6379"
networks:
- nodejs-monorepo-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 10s
retries: 5
start_period: 30s
backend:
image: ${BACKEND_IMAGE:?set BACKEND_IMAGE to your ECR image URI including tag}
container_name: nodejs-monorepo-backend
restart: unless-stopped
ports:
- "${BACKEND_PUBLISH_PORT:-3000}:3000"
env_file:
- .env
networks:
- nodejs-monorepo-network
depends_on:
nodejs-monorepo-postgres:
condition: service_healthy
nodejs-monorepo-redis:
condition: service_healthy
web:
image: ${WEB_IMAGE:?set WEB_IMAGE to your ECR image URI including tag}
container_name: nodejs-monorepo-web
restart: unless-stopped
ports:
- "${WEB_PUBLISH_PORT:-80}:80"
networks:
- nodejs-monorepo-network
depends_on:
backend:
condition: service_started
volumes:
nodejs-monorepo-postgres-data:
driver: local
nodejs-monorepo-redis-data:
driver: local
networks:
nodejs-monorepo-network:
name: nodejs-monorepo-network
driver: bridge
attachable: true