-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
69 lines (66 loc) · 2.52 KB
/
Copy pathdocker-compose.yml
File metadata and controls
69 lines (66 loc) · 2.52 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
services:
# ── NestJS 애플리케이션 ───────────────────────────────
app:
build:
context: .
dockerfile: Dockerfile
image: batchar-api:local
container_name: batchar-nest-api
env_file: .env # JWT / S3 / MAIL / MYSQL_USER 등 모든 값 주입
environment:
TZ: Asia/Seoul
# 로컬 도커 구동 시 컨테이너 로그(docker logs)를 사람이 읽기 좋은 pretty 포맷으로.
# (실제 배포 이미지는 이 값이 없으므로 JSON 그대로 — 수집/검색 용이)
LOG_PRETTY: "true"
# 컨테이너 간 통신은 서비스 이름 + 내부 포트 사용 (.env의 localhost/13306 값을 덮어씀)
MYSQL_HOST: mysql
MYSQL_PORT: 3306
REDIS_HOST: redis
REDIS_PORT: 6379
ports:
# 호스트 노출 포트. 공용 서버에서 겹치면 .env에 APP_PORT 지정 (미지정 시 18080)
- "${APP_PORT:-18080}:18080"
depends_on:
mysql:
condition: service_healthy # mysql이 healthy 된 뒤에 app 기동
redis:
condition: service_healthy
restart: unless-stopped
# ── MySQL ────────────────────────────────────────────
mysql:
image: mysql:8.0
container_name: batchar-nest-mysql
env_file: .env
environment:
TZ: Asia/Seoul
ports:
# 앱은 내부 네트워크(mysql:3306)로 붙으므로 이 노출은 "DB 클라이언트로 직접 볼 때"만 필요.
# 공용 서버에서 13306이 겹치면 .env에 MYSQL_PUBLISH_PORT 지정 (미지정 시 13306)
- "${MYSQL_PUBLISH_PORT:-13306}:3306"
volumes:
- mysql_data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 5s
timeout: 3s
retries: 10
# ── Redis ────────────────────────────────────────────
redis:
image: redis:7
container_name: batchar-nest-redis
environment:
TZ: Asia/Seoul
ports:
# 공용 서버에서 16379가 겹치면 .env에 REDIS_PUBLISH_PORT 지정 (미지정 시 16379)
- "${REDIS_PUBLISH_PORT:-16379}:6379"
volumes:
- redis_data:/data
command: redis-server --appendonly yes --notify-keyspace-events Ex
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
volumes:
mysql_data:
redis_data: