From ba15011669c950d18628591622cbfd20c13d9594 Mon Sep 17 00:00:00 2001 From: Exynox Date: Sun, 2 Jun 2024 21:49:40 +0300 Subject: [PATCH 1/8] Compose file now uses .env variables, added mysql healtcheck --- .env.example | 22 ++++++++ .gitignore | 3 ++ config/auth.txt | 18 ------- config/ch1/first.txt | 27 ---------- config/ch1/game1.txt | 26 ---------- config/ch1/game2.txt | 26 ---------- config/db.txt | 19 ------- config/game99.txt | 26 ---------- docker-compose.yml | 120 +++++++++++++++++++++++++++++++++++-------- 9 files changed, 124 insertions(+), 163 deletions(-) create mode 100644 .env.example delete mode 100644 config/auth.txt delete mode 100644 config/ch1/first.txt delete mode 100644 config/ch1/game1.txt delete mode 100644 config/ch1/game2.txt delete mode 100644 config/db.txt delete mode 100644 config/game99.txt diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..ccb4a0d --- /dev/null +++ b/.env.example @@ -0,0 +1,22 @@ +# MySQL settings +MYSQL_HOST=mysql +MYSQL_USER=root +MYSQL_PASSWORD=metin2 +MYSQL_PORT=3306 +MYSQL_DB_ACCOUNT=account +MYSQL_DB_PLAYER=player +MYSQL_DB_COMMON=common +MYSQL_DB_LOG=log + +# Global settings +TEST_SERVER=0 + +# DBCache settings +DB_ADDR=db +DB_PORT=15000 + +# Game settings +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 diff --git a/.gitignore b/.gitignore index c204181..221cd02 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ +# Working copy of .env file +.env + # Storage directory storage/ diff --git a/config/auth.txt b/config/auth.txt deleted file mode 100644 index fd81b7b..0000000 --- a/config/auth.txt +++ /dev/null @@ -1,18 +0,0 @@ -CHANNEL: 1 -HOSTNAME: auth -PUBLIC_IP: 127.0.0.1 -PORT: 11000 -P2P_PORT: 12000 -DB_ADDR: db -DB_PORT: 15000 -PLAYER_SQL: mysql root metin2 account -COMMON_SQL: mysql root metin2 common -LOG_SQL: mysql root metin2 log -TABLE_POSTFIX: -PASSES_PER_SEC: 25 -PING_EVENT_SECOND_CYCLE: 180 -ADMINPAGE_PASSWORD: metin2adminpass -ADMINPAGE_IP: 127.0.0.1 -AUTH_SERVER: master -TRAFFIC_PROFILE: -TEST_SERVER: 0 diff --git a/config/ch1/first.txt b/config/ch1/first.txt deleted file mode 100644 index b9f24f2..0000000 --- a/config/ch1/first.txt +++ /dev/null @@ -1,27 +0,0 @@ -CHANNEL: 1 -HOSTNAME: ch1_first -PUBLIC_IP: 127.0.0.1 -PORT: 13000 -P2P_PORT: 14000 -DB_ADDR: db -DB_PORT: 15000 -MAP_ALLOW: 1 4 5 6 3 23 43 112 107 67 68 72 208 302 304 -PLAYER_SQL: mysql root metin2 player -COMMON_SQL: mysql root metin2 common -LOG_SQL: mysql root metin2 log -TABLE_POSTFIX: -PASSES_PER_SEC: 25 -SAVE_EVENT_SECOND_CYCLE: 180 -PING_EVENT_SECOND_CYCLE: 180 -VIEW_RANGE: 8000 -CHECK_MULTIHACK: 0 -ADMINPAGE_PASSWORD: metin2adminpass -ADMINPAGE_IP: 127.0.0.1 -SPEEDHACK_LIMIT_COUNT: 300 -SPEEDHACK_LIMIT_BONUS: 80 -PK_PROTECT_LEVEL: 15 -MALL_URL: google.com -TRAFFIC_PROFILE: -TEST_SERVER: 0 -MAX_LEVEL: 105 -MARK_SERVER: 1 \ No newline at end of file diff --git a/config/ch1/game1.txt b/config/ch1/game1.txt deleted file mode 100644 index 68a7411..0000000 --- a/config/ch1/game1.txt +++ /dev/null @@ -1,26 +0,0 @@ -CHANNEL: 1 -HOSTNAME: ch1_game1 -PUBLIC_IP: 127.0.0.1 -PORT: 13001 -P2P_PORT: 14001 -DB_ADDR: db -DB_PORT: 15000 -MAP_ALLOW: 21 24 25 26 108 61 63 69 70 73 216 217 303 -PLAYER_SQL: mysql root metin2 player -COMMON_SQL: mysql root metin2 common -LOG_SQL: mysql root metin2 log -TABLE_POSTFIX: -PASSES_PER_SEC: 25 -SAVE_EVENT_SECOND_CYCLE: 180 -PING_EVENT_SECOND_CYCLE: 180 -VIEW_RANGE: 8000 -CHECK_MULTIHACK: 0 -ADMINPAGE_PASSWORD: metin2adminpass -ADMINPAGE_IP: 127.0.0.1 -SPEEDHACK_LIMIT_COUNT: 300 -SPEEDHACK_LIMIT_BONUS: 80 -PK_PROTECT_LEVEL: 15 -MALL_URL: google.com -TRAFFIC_PROFILE: -TEST_SERVER: 0 -MAX_LEVEL: 105 \ No newline at end of file diff --git a/config/ch1/game2.txt b/config/ch1/game2.txt deleted file mode 100644 index 8af78d0..0000000 --- a/config/ch1/game2.txt +++ /dev/null @@ -1,26 +0,0 @@ -CHANNEL: 1 -HOSTNAME: ch1_game2 -PUBLIC_IP: 127.0.0.1 -PORT: 13002 -P2P_PORT: 14002 -DB_ADDR: db -DB_PORT: 15000 -MAP_ALLOW: 41 44 45 46 109 62 64 65 66 71 104 301 351 -PLAYER_SQL: mysql root metin2 player -COMMON_SQL: mysql root metin2 common -LOG_SQL: mysql root metin2 log -TABLE_POSTFIX: -PASSES_PER_SEC: 25 -SAVE_EVENT_SECOND_CYCLE: 180 -PING_EVENT_SECOND_CYCLE: 180 -VIEW_RANGE: 8000 -CHECK_MULTIHACK: 0 -ADMINPAGE_PASSWORD: metin2adminpass -ADMINPAGE_IP: 127.0.0.1 -SPEEDHACK_LIMIT_COUNT: 300 -SPEEDHACK_LIMIT_BONUS: 80 -PK_PROTECT_LEVEL: 15 -MALL_URL: google.com -TRAFFIC_PROFILE: -TEST_SERVER: 0 -MAX_LEVEL: 105 \ No newline at end of file diff --git a/config/db.txt b/config/db.txt deleted file mode 100644 index 3f1f00c..0000000 --- a/config/db.txt +++ /dev/null @@ -1,19 +0,0 @@ -WELCOME_MSG = "DB Server has been started" - -SQL_ACCOUNT = "mysql account root metin2 0" -SQL_PLAYER = "mysql player root metin2 0" -SQL_COMMON = "mysql common root metin2 0" -SQL_HOTBACKUP = "mysql hotbackup root metin2 0" - -TABLE_POSTFIX = "" - -BIND_PORT = 15000 -DB_SLEEP_MSEC = 10 -CLIENT_HEART_FPS = 10 -HASH_PLAYER_LIFE_SEC = 600 -BACKUP_LIMIT_SEC = 3600 -PLAYER_ID_START = 100 -PLAYER_DELETE_LEVEL_LIMIT = 70 - -ITEM_ID_RANGE = 10000001 20000000 -TEST_SERVER = 0 diff --git a/config/game99.txt b/config/game99.txt deleted file mode 100644 index 52bb5d5..0000000 --- a/config/game99.txt +++ /dev/null @@ -1,26 +0,0 @@ -CHANNEL: 99 -HOSTNAME: game99 -PUBLIC_IP: 127.0.0.1 -PORT: 13099 -P2P_PORT: 14099 -DB_ADDR: db -DB_PORT: 15000 -MAP_ALLOW: 113 81 100 101 103 105 110 111 114 118 119 120 121 122 123 124 125 126 127 128 181 182 183 200 -PLAYER_SQL: mysql root metin2 player -COMMON_SQL: mysql root metin2 common -LOG_SQL: mysql root metin2 log -TABLE_POSTFIX: -PASSES_PER_SEC: 25 -SAVE_EVENT_SECOND_CYCLE: 180 -PING_EVENT_SECOND_CYCLE: 180 -VIEW_RANGE: 8000 -CHECK_MULTIHACK: 0 -ADMINPAGE_PASSWORD: metin2adminpass -ADMINPAGE_IP: 127.0.0.1 -SPEEDHACK_LIMIT_COUNT: 300 -SPEEDHACK_LIMIT_BONUS: 80 -PK_PROTECT_LEVEL: 15 -MALL_URL: google.com -TRAFFIC_PROFILE: -TEST_SERVER: 0 -MAX_LEVEL: 105 \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 5b38161..8c43eae 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,28 @@ -version: '3.3' +x-environment: + &common-environment + MYSQL_HOST: ${MYSQL_HOST} + MYSQL_USER: ${MYSQL_USER} + MYSQL_PASSWORD: ${MYSQL_PASSWORD} + MYSQL_PORT: ${MYSQL_PORT} + MYSQL_DB_ACCOUNT: ${MYSQL_DB_ACCOUNT} + MYSQL_DB_PLAYER: ${MYSQL_DB_PLAYER} + MYSQL_DB_COMMON: ${MYSQL_DB_COMMON} + MYSQL_DB_LOG: ${MYSQL_DB_LOG} + + TEST_SERVER: ${TEST_SERVER} + + DB_ADDR: ${DB_ADDR} + DB_PORT: ${DB_PORT} + + PUBLIC_IP: ${PUBLIC_IP} + GAME_MAX_LEVEL: ${GAME_MAX_LEVEL} + GAME_MALL_URL: ${GAME_MALL_URL} + services: # MySQL Database mysql: image: mysql:5.5 - restart: always + restart: on-failure environment: # Password for root access MYSQL_ROOT_PASSWORD: 'metin2' @@ -13,22 +32,39 @@ services: - 3306 volumes: - ./storage/database/:/var/lib/mysql/ + healthcheck: + #test: ["CMD", "mysql", "-u", "${MYSQL_USER}", "--password", "${MYSQL_PASSWORD}", "-e", "USE ${MYSQL_DB_ACCOUNT};"] + test: ["CMD", 'mysqladmin', 'ping', '-h', 'localhost', '-u', 'root', '-p$$MYSQL_ROOT_PASSWORD' ] + interval: 10s + timeout: 5s + retries: 5 # DBCache Server db: - image: metin2/server:test - restart: always + image: ${GAME_IMAGE} + restart: on-failure + environment: *common-environment expose: - - 15000 + - ${DB_PORT} command: db volumes: - - ./config/db.txt:/app/conf.txt - ./storage/log/db/:/app/log/ + depends_on: + mysql: + condition: service_healthy # Auth server auth: - image: metin2/server:test - restart: always + image: ${GAME_IMAGE} + restart: on-failure + environment: + <<: *common-environment + MYSQL_DB_PLAYER: ${MYSQL_DB_ACCOUNT} + GAME_HOSTNAME: auth + GAME_CHANNEL: 1 + GAME_AUTH_SERVER: master + GAME_PORT: 11000 + GAME_P2P_PORT: 12000 expose: - 11000 - 12000 @@ -36,13 +72,23 @@ services: - '11000:11000' command: game volumes: - - ./config/auth.txt:/app/CONFIG - ./storage/log/auth/:/app/log/ + depends_on: + mysql: + condition: service_healthy # Game server (CH1) ch1_first: - image: metin2/server:test - restart: always + image: ${GAME_IMAGE} + restart: on-failure + environment: + <<: *common-environment + GAME_HOSTNAME: ch1_first + GAME_CHANNEL: 1 + GAME_MARK_SERVER: 1 + GAME_PORT: 13000 + GAME_P2P_PORT: 14000 + GAME_MAP_ALLOW: 1 4 5 6 3 23 43 112 107 67 68 72 208 302 304 expose: - 13000 - 14000 @@ -50,13 +96,23 @@ services: - '13000:13000' command: game volumes: - - ./config/ch1/first.txt:/app/CONFIG - ./storage/log/ch1/first/:/app/log/ - ./storage/mark/:/app/mark/ + depends_on: + mysql: + condition: service_healthy ch1_game1: - image: metin2/server:test - restart: always + image: ${GAME_IMAGE} + restart: on-failure + environment: + <<: *common-environment + GAME_HOSTNAME: ch1_game1 + GAME_CHANNEL: 1 + GAME_MARK_SERVER: 0 + GAME_PORT: 13001 + GAME_P2P_PORT: 14001 + GAME_MAP_ALLOW: 21 24 25 26 108 61 63 69 70 73 216 217 303 expose: - 13001 - 14001 @@ -64,12 +120,22 @@ services: - '13001:13001' command: game volumes: - - ./config/ch1/game1.txt:/app/CONFIG - ./storage/log/ch1/game1/:/app/log/ + depends_on: + mysql: + condition: service_healthy ch1_game2: - image: metin2/server:test - restart: always + image: ${GAME_IMAGE} + restart: on-failure + environment: + <<: *common-environment + GAME_HOSTNAME: ch1_game2 + GAME_CHANNEL: 1 + GAME_MARK_SERVER: 0 + GAME_PORT: 13002 + GAME_P2P_PORT: 14002 + GAME_MAP_ALLOW: 41 44 45 46 109 62 64 65 66 71 104 301 351 expose: - 13002 - 14002 @@ -77,13 +143,23 @@ services: - '13002:13002' command: game volumes: - - ./config/ch1/game2.txt:/app/CONFIG - ./storage/log/ch1/game2/:/app/log/ + depends_on: + mysql: + condition: service_healthy # Game server (game99) game99: - image: metin2/server:test - restart: always + image: ${GAME_IMAGE} + restart: on-failure + environment: + <<: *common-environment + GAME_HOSTNAME: game99 + GAME_CHANNEL: 99 + GAME_MARK_SERVER: 0 + GAME_PORT: 13099 + GAME_P2P_PORT: 14099 + GAME_MAP_ALLOW: 113 81 100 101 103 105 110 111 114 118 119 120 121 122 123 124 125 126 127 128 181 182 183 200 expose: - 13099 - 14099 @@ -91,5 +167,7 @@ services: - '13099:13099' command: game volumes: - - ./config/game99.txt:/app/CONFIG - ./storage/log/game99/:/app/log/ + depends_on: + mysql: + condition: service_healthy From 37ada3e96e6fc47c9795ea9b5f5c37b57f7debed Mon Sep 17 00:00:00 2001 From: Exynox Date: Sun, 2 Jun 2024 21:55:42 +0300 Subject: [PATCH 2/8] MySQL port is configurable through the .env file --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8c43eae..3c0bd1f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,9 +27,9 @@ services: # Password for root access MYSQL_ROOT_PASSWORD: 'metin2' ports: - - '3306:3306' + - '${MYSQL_PORT}:${MYSQL_PORT}' expose: - - 3306 + - ${MYSQL_PORT} volumes: - ./storage/database/:/var/lib/mysql/ healthcheck: From 3a99e1f83023db556634316a0a2f3609b486e164 Mon Sep 17 00:00:00 2001 From: Exynox Date: Sun, 2 Jun 2024 22:03:26 +0300 Subject: [PATCH 3/8] Remove non-working healthcheck --- docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3c0bd1f..0f914c6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,7 +33,6 @@ services: volumes: - ./storage/database/:/var/lib/mysql/ healthcheck: - #test: ["CMD", "mysql", "-u", "${MYSQL_USER}", "--password", "${MYSQL_PASSWORD}", "-e", "USE ${MYSQL_DB_ACCOUNT};"] test: ["CMD", 'mysqladmin', 'ping', '-h', 'localhost', '-u', 'root', '-p$$MYSQL_ROOT_PASSWORD' ] interval: 10s timeout: 5s From bcdd9ac51bf91663e8c32378a468e48c790f9bd1 Mon Sep 17 00:00:00 2001 From: Exynox Date: Sun, 2 Jun 2024 22:23:41 +0300 Subject: [PATCH 4/8] Made external MySQL port configurable --- .env.example | 1 + docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index ccb4a0d..39056b9 100644 --- a/.env.example +++ b/.env.example @@ -3,6 +3,7 @@ MYSQL_HOST=mysql MYSQL_USER=root MYSQL_PASSWORD=metin2 MYSQL_PORT=3306 +MYSQL_EXTERNAL_PORT=3306 MYSQL_DB_ACCOUNT=account MYSQL_DB_PLAYER=player MYSQL_DB_COMMON=common diff --git a/docker-compose.yml b/docker-compose.yml index 0f914c6..275079a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -27,7 +27,7 @@ services: # Password for root access MYSQL_ROOT_PASSWORD: 'metin2' ports: - - '${MYSQL_PORT}:${MYSQL_PORT}' + - '${MYSQL_EXTERNAL_PORT}:${MYSQL_PORT}' expose: - ${MYSQL_PORT} volumes: From 0a497f5a69fa2e1be6746b86940a4843b2cb794d Mon Sep 17 00:00:00 2001 From: Exynox Date: Sun, 22 Sep 2024 09:54:42 +0300 Subject: [PATCH 5/8] Added database initialization mechanism, support for in-game mall --- .env.example | 29 +++++++++++++- assets/db-init/create-databases.sql | 5 +++ docker-compose.yml | 59 +++++++++++++++++++++++++++-- 3 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 assets/db-init/create-databases.sql diff --git a/.env.example b/.env.example index 39056b9..a722325 100644 --- a/.env.example +++ b/.env.example @@ -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 diff --git a/assets/db-init/create-databases.sql b/assets/db-init/create-databases.sql new file mode 100644 index 0000000..56156c5 --- /dev/null +++ b/assets/db-init/create-databases.sql @@ -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; diff --git a/docker-compose.yml b/docker-compose.yml index 275079a..4393a76 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 From 708b65be30bcf29f7545dee8d35b0d4452c1d894 Mon Sep 17 00:00:00 2001 From: Exynox Date: Sun, 17 Nov 2024 09:58:56 +0200 Subject: [PATCH 6/8] Restructured sample .env file, switched database to biarms/mysql --- .env.example | 8 ++++++-- docker-compose.yml | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index a722325..4b54192 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,9 @@ +################################################################################ +# Docker images +################################################################################ +GAME_IMAGE=git.old-metin2.com/metin2/server:latest +WEB_IMAGE=git.old-metin2.com/metin2/web:latest + ################################################################################ # MySQL settings ################################################################################ @@ -16,7 +22,6 @@ MYSQL_DB_LOG=log ################################################################################ # 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 @@ -46,5 +51,4 @@ DB_PORT=15000 # Game settings PUBLIC_IP=127.0.0.1 -GAME_IMAGE=git.old-metin2.com/metin2/server:nightly GAME_MAX_LEVEL=105 diff --git a/docker-compose.yml b/docker-compose.yml index 4393a76..c244911 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,7 +22,8 @@ x-environment: services: # MySQL Database mysql: - image: mysql:5.5 + # The biarms/mysql Docker image supports ARM machines; you may also use mysql:5.5 + image: biarms/mysql:5.5 restart: on-failure environment: # Password for root access From 35b2b1c57ee5fd01085c8242614f3fab157897e2 Mon Sep 17 00:00:00 2001 From: Exynox Date: Sun, 17 Nov 2024 10:48:33 +0200 Subject: [PATCH 7/8] Updated README.md with a quick start guide --- README.md | 59 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index fea0fb9..79b8ad1 100644 --- a/README.md +++ b/README.md @@ -3,27 +3,62 @@ The Old Metin2 Project aims at improving and maintaining the 2014 Metin2 game fi For-profit usage of this material is certainly illegal without the proper licensing agreements and is hereby discouraged (not legal advice). Even so, the nature of this project is HIGHLY EXPERIMENTAL - bugs are to be expected for now. -## Usage -The deployment strategy for this project is based around Docker Compose. For now, no images are published, so building your own server image is required. Also, for now, you need to provide your own database schema. +## Quick start guide +The deployment strategy for this project is based around Docker Compose. -### Building the server image -This process requires that you do the following steps on a Linux environment with Docker installed and running. +### Architecture description +The MySQL database is currently pinned on version 5.5. We're using the [biarms/mysql](https://github.com/biarms/mysql) project in order to provide ARM compatibility for such an old version of MySQL. -Clone the Server project repository: +The game cores (`db`, `auth`, `game-*`) are ran by using pre-built images containing the server binaries and game files, provided in the [Server repository](https://git.old-metin2.com/metin2/server/packages). + +The web application provides the actual website, item mall and autopatcher functionality. Moreover, it is responsible with maintaining the database schema, creating and updating tables when needed. Pre-built images containing the web application are provided in the [Website repository](https://git.old-metin2.com/metin2/web/packages). + +### Preparing the server +Clone this repository and access its root directory. For instance, on Linux you would do this: ```shell -git clone https://git.old-metin2.com/metin2/server.git +git clone --depth 1 https://git.old-metin2.com/metin2/deploy.git metin2-deploy +cd metin2-deploy/ ``` -Build the image: +Now, we need to copy the example environment file and name it `.env`. This file contains all settings used by Docker Compose to start up our project. ```shell -cd server -docker build -t metin2/server:test . +cp .env.example .env ``` +Some settings aren't yet filled out. The actual settings will differ based on your setup. We'll assume that you're using WSL and Docker on your own computer, and you want to run the server locally, just for yourself. Start with opening the newly copied `.env` file. + +Firstly, we need to configure the web application. Find `WEB_APP_URL` and change it to the URL you would use to access the machine you're installing this on (without a trailing slash!). In our case, simply set it to `http://localhost`. + +You might already use port 80 on your machine for something else, in which case we need to configure the app to use another port. Simply change `WEB_EXTERNAL_PORT` to another value, for example `8080`. Don't forget to change `WEB_APP_URL` accordingly, in our case to `http://localhost:8080`. + +Next, we need to generate a cryptographic key. We'll make use of Laravel's generator feature, as follows: +```shell +docker run git.old-metin2.com/metin2/web:latest "php artisan key:generate --show" +``` + +Run the above command and configure `WEB_APP_KEY` with the output. You should end up with something like: `WEB_APP_KEY=base64:`. + +Lastly, let's switch our focus to the game server. Make sure that `PUBLIC_IP` is set to a value at which you can access your machine. As a rule of thumb, this should be the same value you set in your client's `serverinfo.py`. In our case, leaving a value of `127.0.0.1` should work just fine. + +Don't forget to save your `.env` file! + ### Starting the server -Clone this repository and open a terminal window in its root directory. Then, simply bring up the Compose project: +You're ready to start the server. Simply run the following command to start up the server: ```shell -docker compose up -d +docker compose up -d --pull always ``` -On the first run, you might need to connect to port 3306 with your favourite MySQL client (Navicat, DBeaver, phpMyAdmin etc.) and install a Metin2 database schema. +On the first run, your database tables will be created and populated with default data. + +### Stopping the server +Should you want to stop the server, simply bring down the Docker Compose stack: +```shell +docker compose down +``` + +### Start only some services +This deployment environment can also be used for development purposes. If you need a database and website, but want to run the server in some other way (for example, in an IDE), you can just bring up only the services you need: + +```shell +docker compose up -d mysql web +``` From b371a5317f9c00caab7245fa570070374efdc377 Mon Sep 17 00:00:00 2001 From: Exynox Date: Sun, 17 Nov 2024 11:19:21 +0200 Subject: [PATCH 8/8] Added remove flag to docker run command --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 79b8ad1..008dd59 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ You might already use port 80 on your machine for something else, in which case Next, we need to generate a cryptographic key. We'll make use of Laravel's generator feature, as follows: ```shell -docker run git.old-metin2.com/metin2/web:latest "php artisan key:generate --show" +docker run --rm git.old-metin2.com/metin2/web:latest "php artisan key:generate --show" ``` Run the above command and configure `WEB_APP_KEY` with the output. You should end up with something like: `WEB_APP_KEY=base64:`.