Added database initialization mechanism, support for in-game mall

This commit is contained in:
Exynox 2024-09-22 09:54:42 +03:00
parent bcdd9ac51b
commit 0a497f5a69
3 changed files with 89 additions and 4 deletions

View File

@ -1,4 +1,6 @@
################################################################################
# MySQL settings
################################################################################
MYSQL_HOST=mysql
MYSQL_USER=root
MYSQL_PASSWORD=metin2
@ -9,6 +11,32 @@ MYSQL_DB_PLAYER=player
MYSQL_DB_COMMON=common
MYSQL_DB_LOG=log
################################################################################
# Web app settings
################################################################################
# General configuration
WEB_IMAGE=git.old-metin2.com/metin2/website:nightly
WEB_APP_NAME=Metin2
WEB_APP_ENV=production
WEB_APP_URL=http://metin2.local
WEB_APP_KEY=
WEB_EXTERNAL_PORT=80
# E-mail configuration
WEB_MAIL_MAILER=smtp
WEB_MAIL_HOST=smtp.example.com
WEB_MAIL_PORT=587
WEB_MAIL_USERNAME=smtp-username
WEB_MAIL_PASSWORD=smtp-password
WEB_MAIL_ENCRYPTION=tls
WEB_MAIL_FROM_ADDRESS=no-reply@example.com
WEB_MAIL_FROM_NAME=Metin2
################################################################################
# Game server settings
################################################################################
# Global settings
TEST_SERVER=0
@ -20,4 +48,3 @@ DB_PORT=15000
PUBLIC_IP=127.0.0.1
GAME_IMAGE=git.old-metin2.com/metin2/server:nightly
GAME_MAX_LEVEL=105
GAME_MALL_URL=metin2.test/mall

View File

@ -0,0 +1,5 @@
CREATE DATABASE account CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE DATABASE common CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE DATABASE log CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE DATABASE player CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE DATABASE website CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

View File

@ -16,7 +16,8 @@ x-environment:
PUBLIC_IP: ${PUBLIC_IP}
GAME_MAX_LEVEL: ${GAME_MAX_LEVEL}
GAME_MALL_URL: ${GAME_MALL_URL}
WEB_APP_URL: ${WEB_APP_URL}
WEB_APP_KEY: ${WEB_APP_KEY}
services:
# MySQL Database
@ -25,15 +26,55 @@ services:
restart: on-failure
environment:
# Password for root access
MYSQL_ROOT_PASSWORD: 'metin2'
MYSQL_ROOT_PASSWORD: ${MYSQL_PASSWORD}
ports:
- '${MYSQL_EXTERNAL_PORT}:${MYSQL_PORT}'
expose:
- ${MYSQL_PORT}
volumes:
- ./storage/database/:/var/lib/mysql/
- ./assets/db-init/:/docker-entrypoint-initdb.d/:ro
healthcheck:
test: ["CMD", 'mysqladmin', 'ping', '-h', 'localhost', '-u', 'root', '-p$$MYSQL_ROOT_PASSWORD' ]
test: mysqladmin ping -h localhost -u root -p$$MYSQL_ROOT_PASSWORD
interval: 10s
timeout: 5s
retries: 5
# Web management system
web:
image: ${WEB_IMAGE}
restart: on-failure
environment:
# Application config
APP_NAME: ${WEB_APP_NAME}
APP_ENV: ${WEB_APP_ENV}
APP_KEY: ${WEB_APP_KEY}
APP_URL: ${WEB_APP_URL}
# Database credentials
DB_HOST: ${MYSQL_HOST}
DB_PORT: ${MYSQL_PORT}
DB_USERNAME: ${MYSQL_USER}
DB_PASSWORD: ${MYSQL_PASSWORD}
# E-mail config
MAIL_MAILER: ${WEB_MAIL_MAILER}
MAIL_HOST: ${WEB_MAIL_HOST}
MAIL_PORT: ${WEB_MAIL_PORT}
MAIL_USERNAME: ${WEB_MAIL_USERNAME}
MAIL_PASSWORD: ${WEB_MAIL_PASSWORD}
MAIL_ENCRYPTION: ${WEB_MAIL_ENCRYPTION}
MAIL_FROM_ADDRESS: ${WEB_MAIL_FROM_ADDRESS}
MAIL_FROM_NAME: ${WEB_MAIL_FROM_NAME}
ports:
- '${WEB_EXTERNAL_PORT}:80'
volumes:
- ./storage/web/:/app/storage/
depends_on:
mysql:
condition: service_healthy
healthcheck:
test: curl --fail http://localhost:80/ || exit 1
interval: 10s
timeout: 5s
retries: 5
@ -51,6 +92,8 @@ services:
depends_on:
mysql:
condition: service_healthy
web:
condition: service_healthy
# Auth server
auth:
@ -75,6 +118,8 @@ services:
depends_on:
mysql:
condition: service_healthy
web:
condition: service_healthy
# Game server (CH1)
ch1_first:
@ -100,6 +145,8 @@ services:
depends_on:
mysql:
condition: service_healthy
web:
condition: service_healthy
ch1_game1:
image: ${GAME_IMAGE}
@ -123,6 +170,8 @@ services:
depends_on:
mysql:
condition: service_healthy
web:
condition: service_healthy
ch1_game2:
image: ${GAME_IMAGE}
@ -146,6 +195,8 @@ services:
depends_on:
mysql:
condition: service_healthy
web:
condition: service_healthy
# Game server (game99)
game99:
@ -170,3 +221,5 @@ services:
depends_on:
mysql:
condition: service_healthy
web:
condition: service_healthy