-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
156 lines (149 loc) · 4.91 KB
/
docker-compose.yml
File metadata and controls
156 lines (149 loc) · 4.91 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
services:
# # MySQL Database
# mysql:
# image: mysql:8.0
# container_name: taskopedia-mysql
# restart: unless-stopped
# environment:
# MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-rootpassword}
# MYSQL_DATABASE: ${MYSQL_DATABASE:-taskopedia}
# MYSQL_USER: ${MYSQL_USER:-taskopedia}
# MYSQL_PASSWORD: ${MYSQL_PASSWORD:-taskopedia123}
# # MySQL port not exposed - access via docker exec or internal network only
# # ports:
# # - "${MYSQL_PORT:-3306}:3306"
# volumes:
# - mysql_data:/var/lib/mysql
# networks:
# - taskopedia-network
# healthcheck:
# test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD:-rootpassword}"]
# interval: 10s
# timeout: 5s
# retries: 5
# command: --default-authentication-plugin=mysql_native_password
# PostgreSQL Database
postgres:
image: postgres:16.11-alpine3.23
container_name: taskopedia-postgres
restart: unless-stopped
environment:
- POSTGRES_USER=${POSTGRES_USER:-taskopedia}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-taskopedia123}
- POSTGRES_DB=${POSTGRES_DB:-taskopedia}
- POSTGRES_HOST_AUTH_METHOD=trust
# ports:
# - "${POSTGRES_PORT:-5432}:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- taskopedia-network
healthcheck:
test: ["CMD", "pg_isready", "-U", "${POSTGRES_USER:-taskopedia}"]
interval: 10s
timeout: 5s
retries: 5
# API Service
api:
build:
context: .
dockerfile: Dockerfile
target: production
container_name: taskopedia-api
restart: unless-stopped
entrypoint: ["/bin/sh", "/app/apps/api/docker-entrypoint.sh"]
environment:
- NODE_ENV=production
# - DATABASE_URL=mysql://${MYSQL_USER:-taskopedia}:${MYSQL_PASSWORD:-taskopedia123}@mysql:3306/${MYSQL_DATABASE:-taskopedia}
- DATABASE_URL=postgresql://${POSTGRES_USER:-taskopedia}:${POSTGRES_PASSWORD:-taskopedia123}@postgres:5432/${POSTGRES_DB:-taskopedia}
- API_PORT=${API_PORT:-4000}
- LOGGER_URL=http://logger:${LOGGER_PORT:-4001}
- JWT_SECRET=${JWT_SECRET:-your-secret-key-change-in-production}
- JWT_EXPIRES_IN=${JWT_EXPIRES_IN:-7d}
# API port not exposed - only accessible through Gateway
# ports:
# - "${API_PORT:-4000}:4000"
depends_on:
# mysql:
# condition: service_healthy
postgres:
condition: service_healthy
networks:
- taskopedia-network
volumes:
- ./apps/api/prisma:/app/apps/api/prisma
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://localhost:4000', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Gateway Service
gateway:
build:
context: .
dockerfile: Dockerfile
target: production
container_name: taskopedia-gateway
restart: unless-stopped
command: node apps/gateway/dist/main.js
environment:
- NODE_ENV=production
- GATEWAY_PORT=${GATEWAY_PORT:-3000}
- API_URL=http://api:${API_PORT:-4000}
- LOGGER_URL=http://logger:${LOGGER_PORT:-4001}
ports:
- "${GATEWAY_PORT:-3000}:3000"
depends_on:
- api
networks:
- taskopedia-network
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
# Logger Service
logger:
build:
context: .
dockerfile: Dockerfile
target: production
container_name: taskopedia-logger
restart: unless-stopped
command: node apps/logger/dist/main.js
environment:
- NODE_ENV=production
- LOGGER_PORT=${LOGGER_PORT:-4001}
- DATABASE_URL=postgresql://${POSTGRES_USER:-taskopedia}:${POSTGRES_PASSWORD:-taskopedia123}@postgres:5432/${POSTGRES_DB:-taskopedia}
# CloudWatch Configuration
- ENABLE_CLOUDWATCH=${ENABLE_CLOUDWATCH:-true}
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
- AWS_REGION=${AWS_REGION:-eu-west-2}
- LOG_STREAM_NAME=${LOG_STREAM_NAME:-logger-production}
- LOG_GROUP_NAME=${LOG_GROUP_NAME:-/microservices/logger}
# Logger port not exposed - only accessible from internal network
# ports:
# - "${LOGGER_PORT:-4001}:4001"
networks:
- taskopedia-network
volumes:
- logger_logs:/app/apps/logger/logs
healthcheck:
test: ["CMD", "node", "-e", "require('http').get('http://localhost:4001', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"]
interval: 30s
timeout: 10s
retries: 3
start_period: 20s
volumes:
# mysql_data:
# driver: local
postgres_data:
driver: local
logger_logs:
driver: local
networks:
taskopedia-network:
driver: bridge