Tối ưu hóa cấu hình MySQL trong docker-compose.dev.yml

- Nâng cấp MySQL image lên phiên bản 8.0
- Thêm các tùy chọn cấu hình chi tiết cho hiệu suất và bảo mật
- Cập nhật healthcheck và các tham số kết nối
- Thêm volume khởi tạo và cấu hình character set
- Điều chỉnh các tham số hiệu suất MySQL
This commit is contained in:
koh 2025-03-03 16:39:36 +07:00
parent 86a60a7861
commit 954e4331fd
No known key found for this signature in database
2 changed files with 25 additions and 4 deletions

View File

@ -32,7 +32,7 @@ services:
networks:
- blueprint
mysql_bp:
image: mysql:latest
image: mysql:8.0
platform: linux/arm64
restart: unless-stopped
environment:
@ -40,16 +40,35 @@ services:
MYSQL_USER: ${BLUEPRINT_DB_USERNAME}
MYSQL_PASSWORD: ${BLUEPRINT_DB_PASSWORD}
MYSQL_ROOT_PASSWORD: ${BLUEPRINT_DB_ROOT_PASSWORD}
MYSQL_ALLOW_EMPTY_PASSWORD: "no"
ports:
- "${BLUEPRINT_DB_PORT}:3306"
- "3306:3306"
volumes:
- mysql_volume_bp:/var/lib/mysql
- ./mysql/init:/docker-entrypoint-initdb.d
command: >
--default-authentication-plugin=mysql_native_password
--character-set-server=utf8mb4
--collation-server=utf8mb4_unicode_ci
--skip-name-resolve
--explicit_defaults_for_timestamp=1
--max_connections=1000
--innodb_buffer_pool_size=256M
--innodb_log_buffer_size=16M
--innodb_log_file_size=256M
--innodb_write_io_threads=8
--innodb_read_io_threads=8
--innodb_thread_concurrency=0
--innodb_flush_log_at_trx_commit=2
--innodb_flush_method=O_DIRECT
--innodb_file_per_table=1
--bind-address=0.0.0.0
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "${BLUEPRINT_DB_USERNAME}", "--password=${BLUEPRINT_DB_PASSWORD}", "--silent"]
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${BLUEPRINT_DB_ROOT_PASSWORD}", "--connect-timeout=5"]
interval: 10s
timeout: 5s
retries: 5
start_period: 40s
start_period: 180s
networks:
- blueprint

View File

@ -121,3 +121,5 @@
{"level":"INFO","time":"2025-03-03T07:00:37.818Z","caller":"initialize/run.go:63","msg":"Server đang chạy trên cổng 8080"}
{"level":"INFO","time":"2025-03-03T07:01:19.523Z","caller":"initialize/mysql.go:31","msg":"Initializing MySQL Successfully"}
{"level":"INFO","time":"2025-03-03T07:01:19.524Z","caller":"initialize/run.go:63","msg":"Server đang chạy trên cổng 8080"}
{"level":"INFO","time":"2025-03-03T09:36:38.123Z","caller":"initialize/mysql.go:31","msg":"Initializing MySQL Successfully"}
{"level":"INFO","time":"2025-03-03T09:36:38.127Z","caller":"initialize/run.go:63","msg":"Server đang chạy trên cổng 8080"}