-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
75 lines (71 loc) · 5.72 KB
/
Copy pathdocker-compose.yml
File metadata and controls
75 lines (71 loc) · 5.72 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
# ┌────────────────────────────────────────────────────────────────────────┐
# │ 네트워크 정의: 모든 컨테이너가 동일 브리지 네트워크에 연결됩니다. │
# └────────────────────────────────────────────────────────────────────────┘
version: '3'
networks:
monitoring:
driver: bridge
services:
# ┌────────────────────────────────────────────────────────────────────────┐
# │ 4) Kafka 서비스 정의 │
# │ - 메시지 브로커로 사용되며, 포트 9094로 외부와 통신합니다. │
# │ - 볼륨을 통해 로그 및 데이터를 영속화하며, 다양한 리스너를 설정합니다. │
# └────────────────────────────────────────────────────────────────────────┘
kafka:
image: public.ecr.aws/bitnami/kafka:3.5.1 # Bitnami Kafka 3.5.1 이미지를 사용
ports:
- "9094:9094" # 호스트 9094 → 컨테이너 9094
environment: # 환경 변수는 매핑(mapping) 형태로 작성 :contentReference[oaicite:33]{index=33}
KAFKA_CFG_NODE_ID: 0 # Kafka 노드 ID 설정
KAFKA_CFG_PROCESS_ROLES: controller,broker # 프로세스 역할 설정
KAFKA_CFG_LISTENERS: PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094
# 리스너(프로토콜) 설정 :contentReference[oaicite:36]{index=36}
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092,EXTERNAL://localhost:9094
# 외부에 노출할 어드버타이즈드 리스너 :contentReference[oaicite:37]{index=37}
KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP: CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT
# 리스너별 프로토콜 맵핑 :contentReference[oaicite:38]{index=38}
KAFKA_CFG_CONTROLLER_QUORUM_VOTERS: 0@kafka:9093 # 컨트롤러 쿼럼 투표자 설정 :contentReference[oaicite:39]{index=39}
KAFKA_CFG_CONTROLLER_LISTENER_NAMES: CONTROLLER
restart: always
deploy:
resources:
limits:
memory: 512MB # 컨테이너 전체 메모리 제한
networks:
monitoring:
aliases:
- kafka
# ┌────────────────────────────────────────────────────────────────────────┐
# │ 5) Redis 서비스 정의 │
# │ - 캐시 또는 세션 저장소로 사용되며, 포트 6379로 외부와 통신합니다. │
# │ - AOF(Append Only File) 모드를 활성화하여 데이터 영속성을 확보합니다. │
# └────────────────────────────────────────────────────────────────────────┘
redis:
image: redis:7.0-alpine # Redis 7.0 Alpine 이미지를 사용 :contentReference[oaicite:41]{index=41}
container_name: hhplus-redis # 컨테이너 이름을 hhplus-redis로 지정 :contentReference[oaicite:42]{index=42}
ports:
- "6379:6379" # 호스트 6379 → 컨테이너 6379 :contentReference[oaicite:43]{index=43}
# volumes:
# - ./data/redis/:/data # 호스트 ./data/redis/ → 컨테이너 /data (영속화) :contentReference[oaicite:44]{index=44}
command: [ "redis-server", "--appendonly", "yes" ] # AOF 모드 활성화하여 영속성 확보 :contentReference[oaicite:45]{index=45}
restart: unless-stopped # 비정상 종료 시 자동 재시작 :contentReference[oaicite:46]{index=46}
networks:
- monitoring
# ┌────────────────────────────────────────────────────────────────────────┐
# │ 6) Spring Boot 애플리케이션 (app) 정의 │
# │ - `Dockerfile`를 이용해 이미지를 빌드하며, 포트 8082로 외부와 통신합니다. │
# │ - MySQL, Kafka, Redis, InfluxDB에 의존(depend on)하여 실행 순서를 보장합니다. │
# │ - Spring Boot 환경 변수로 각 서비스 호스트를 지정합니다. │
# └────────────────────────────────────────────────────────────────────────┘
app:
image: 116981801268.dkr.ecr.us-east-1.amazonaws.com/hhplus-server:latest
depends_on:
- kafka
- redis
environment: # Spring Boot 환경 변수는 매핑(mapping) 형태로 작성
SPRING_PROFILES_ACTIVE: docker # 활성화 할 프로파일을 docker로 지정함.
restart: always
ports:
- "8080:8080"
networks:
- monitoring