-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
174 lines (169 loc) · 5.89 KB
/
Copy pathdocker-compose.yml
File metadata and controls
174 lines (169 loc) · 5.89 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
services:
# MySQL Database
mysql:
image: mysql:8.0
container_name: bookstore-mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:?Set MYSQL_ROOT_PASSWORD to a private value}
MYSQL_DATABASE: ${DB_NAME:-bookstore}
MYSQL_USER: ${DB_USERNAME:-bookstore}
MYSQL_PASSWORD: ${DB_PASSWORD:?Set DB_PASSWORD to a private value}
ports:
- "3307:3306"
volumes:
- mysql_data:/var/lib/mysql
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
healthcheck:
test:
[
"CMD-SHELL",
"mysqladmin ping -h localhost -u root -p$${MYSQL_ROOT_PASSWORD}",
]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
networks:
- bookstore-network
# PostgreSQL for specific services (optional)
postgres:
image: postgres:16-alpine
container_name: bookstore-postgres
restart: unless-stopped
environment:
POSTGRES_DB: bookstore
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD to a private value}
PGDATA: /var/lib/postgresql/data/pgdata
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d bookstore"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
networks:
- bookstore-network
backend:
build:
context: .
dockerfile: Dockerfile.backend
container_name: bookstore-backend
restart: unless-stopped
environment:
SPRING_PROFILES_ACTIVE: prod
# MySQL (primary)
DB_HOST: mysql
DB_PORT: 3306
DB_NAME: ${DB_NAME:-bookstore}
DB_USERNAME: ${DB_USERNAME:-bookstore}
DB_PASSWORD: ${DB_PASSWORD:?Set DB_PASSWORD to a private value}
# PostgreSQL (optional, for specific features)
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
POSTGRES_DB: bookstore
POSTGRES_USERNAME: postgres
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD to a private value}
JWT_SECRET: ${JWT_SECRET:?Set JWT_SECRET to a non-public value with at least 32 bytes}
CORS_ORIGINS: http://localhost:3000,http://localhost:3001,http://frontend:3000
JPA_DDL_AUTO: update
APP_BASE_URL: http://localhost:8080
UPLOAD_DIR: /app/uploads
# Grok AI chatbot configuration from .env
GROK_ENABLED: ${GROK_ENABLED:-false}
GROK_API_KEY: ${GROK_API_KEY:-}
GROK_MODEL: ${GROK_MODEL:-grok-3}
GROK_API_URL: ${GROK_API_URL:-https://api.x.ai/v1/chat/completions}
VNPAY_URL: ${VNPAY_URL:-https://sandbox.vnpayment.vn/paymentv2/vpcpay.html}
VNPAY_MERCHANT_ID: ${VNPAY_MERCHANT_ID:-}
VNPAY_MERCHANT_KEY: ${VNPAY_MERCHANT_KEY:-}
VNPAY_RETURN_URL: ${VNPAY_RETURN_URL:-http://localhost:3001/payment/return}
VNPAY_IPN_URL: ${VNPAY_IPN_URL:-http://localhost:8080/api/payments/vnpay/ipn}
# Weekly flash sale automation
FLASHSALE_AUTO_ENABLED: ${FLASHSALE_AUTO_ENABLED:-true}
FLASHSALE_AUTO_CRON: "${FLASHSALE_AUTO_CRON:-0 5 0 ? * MON}"
FLASHSALE_AUTO_TIMEZONE: ${FLASHSALE_AUTO_TIMEZONE:-Asia/Bangkok}
FLASHSALE_AUTO_BATCH_SIZE: "${FLASHSALE_AUTO_BATCH_SIZE:-4}"
FLASHSALE_AUTO_DISCOUNT_MIN: "${FLASHSALE_AUTO_DISCOUNT_MIN:-15}"
FLASHSALE_AUTO_DISCOUNT_MAX: "${FLASHSALE_AUTO_DISCOUNT_MAX:-30}"
FLASHSALE_AUTO_STOCK_MIN: "${FLASHSALE_AUTO_STOCK_MIN:-20}"
FLASHSALE_AUTO_STOCK_MAX: "${FLASHSALE_AUTO_STOCK_MAX:-60}"
FLASHSALE_AUTO_MAX_PER_USER: "${FLASHSALE_AUTO_MAX_PER_USER:-2}"
# Rate Limiting
RATE_LIMIT_ENABLED: "true"
RATE_LIMIT_AUTH_LIMIT: "5"
RATE_LIMIT_API_LIMIT: "100"
RATE_LIMIT_PUBLIC_LIMIT: "200"
# Input Validation
INPUT_VALIDATION_ENABLED: "true"
INPUT_VALIDATION_BLOCK_XSS: "true"
INPUT_VALIDATION_BLOCK_SQL_INJECTION: "true"
# Email (cấu hình trong .env)
MAIL_HOST: ${MAIL_HOST:-smtp.gmail.com}
MAIL_PORT: ${MAIL_PORT:-587}
MAIL_USERNAME: ${MAIL_USERNAME:-}
MAIL_PASSWORD: ${MAIL_PASSWORD:-}
MAIL_FROM: ${MAIL_FROM:-noreply@bookstore.com}
APP_EMAIL_TEST_ENABLED: ${APP_EMAIL_TEST_ENABLED:-false}
APP_EMAIL_ALLOWED_RECIPIENTS: ${APP_EMAIL_ALLOWED_RECIPIENTS:-}
APP_DEMO_SEED_ENABLED: ${APP_DEMO_SEED_ENABLED:-false}
APP_DEMO_ADMIN_PASSWORD: ${APP_DEMO_ADMIN_PASSWORD:-}
APP_DEMO_MANAGER_PASSWORD: ${APP_DEMO_MANAGER_PASSWORD:-}
APP_DEMO_CUSTOMER_PASSWORD: ${APP_DEMO_CUSTOMER_PASSWORD:-}
ports:
- "8080:8080"
volumes:
- uploads_data:/app/uploads
depends_on:
mysql:
condition: service_healthy
healthcheck:
test:
[
"CMD",
"curl",
"-f",
"http://localhost:8080/api/actuator/health/liveness",
]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
networks:
- bookstore-network
frontend:
build:
context: .
dockerfile: Dockerfile.frontend
args:
NEXT_PUBLIC_API_URL: /api
NEXT_PUBLIC_APP_NAME: BookStore
NEXT_PUBLIC_APP_DESCRIPTION: Professional Vietnamese E-Commerce BookStore Platform
NEXT_PUBLIC_VNPAY_ENABLED: ${NEXT_PUBLIC_VNPAY_ENABLED:-false}
API_PROXY_TARGET: http://backend:8080/api
container_name: bookstore-frontend
restart: unless-stopped
environment:
NEXT_PUBLIC_API_URL: /api
NEXT_PUBLIC_APP_NAME: BookStore
NEXT_PUBLIC_APP_DESCRIPTION: Professional Vietnamese E-Commerce BookStore Platform
NEXT_PUBLIC_VNPAY_ENABLED: ${NEXT_PUBLIC_VNPAY_ENABLED:-false}
API_PROXY_TARGET: http://backend:8080/api
ports:
- "3001:3000"
depends_on:
backend:
condition: service_healthy
networks:
- bookstore-network
volumes:
mysql_data:
postgres_data:
uploads_data:
networks:
bookstore-network:
driver: bridge