-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: ✨ Add new branch to work with Docker #256
base: master
Are you sure you want to change the base?
Changes from all commits
658fb2a
d9d3a75
2a86353
f7dd52c
cfa2971
1f2e059
751c0fb
681cdd0
840cfb7
06a6f25
2bb0a58
cc5879c
68eec32
c55cd66
b724216
dc8de12
5cedc96
a7b736b
2d3b785
fbfd852
47660fe
35323dc
c9de2e7
7ffd8b3
b475db6
e45283e
bf27246
54b0d11
90b9773
6b5d9f5
bddca91
13f3487
875c132
e93bcfe
b2b25da
2a8ff97
a382399
81d7965
8a5a120
6e298ca
ce4fc82
b5c0c37
50edd51
a683071
eef7545
29a7cd1
a196a76
43b9145
4c66caa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# ENVIRONMENT determines the folder where we'll look for binaries. | ||
# If you're using Release, change the build command to: docker compose run --rm melia-server dotnet publish | ||
# Release performance tends to have better performance, Debug will have more info for development. | ||
|
||
ENVIRONMENT="Debug" # Options: Release | Debug | ||
|
||
# Database password | ||
MYSQL_ROOT_PASSWORD="123456" # Use a strong password, change in ./user/conf/database.conf too | ||
|
||
# Automatically restart server. If using on-failure, sets amount of retries | ||
SERVER_RESTART="unless-stopped" # Options: no | unless-stopped | always | on-failure:5 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,6 @@ with any services provided by game developers or publishers, and we don't | |
endorse such actions. We're here to learn and create, not to steal or | ||
destroy. | ||
|
||
Client | ||
----------------------------------------------------------------------------- | ||
|
||
Melia does not have a client of its own at this time. Instead, it's designed | ||
to be network compatible with the latest client of the international | ||
version of ToS, which is freely available on Steam. | ||
|
||
State of Development | ||
----------------------------------------------------------------------------- | ||
|
||
|
@@ -29,6 +22,7 @@ of the typical features you would expect from an online RPG, but | |
there's still a way to go before we'd call it truly playable. | ||
|
||
Specifically, some of the major features that are working are as follows: | ||
|
||
- Characters (creation, deletion, etc.) | ||
- Inventory (managing items, equipping, etc.) | ||
- Chat | ||
|
@@ -41,7 +35,116 @@ Specifically, some of the major features that are working are as follows: | |
- Monster spawns | ||
- Quests | ||
|
||
Requirements | ||
Installation with Docker | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer you revert the changes to the readme, which is supposed to be both concise and general purpose. Long explanations about the setup are better suited for the docs folder. |
||
----------------------------------------------------------------------------- | ||
|
||
This branch aims to make Melia easier to setup and run in any environment. | ||
To achieve this, we're making a few changes do add the capability of building | ||
and running Melia on Linux, as well as building and running the server in a | ||
few Docker containers. | ||
|
||
For this to work, you will need [Docker](https://docs.docker.com/) installed | ||
on your system. Recent versions of Docker comes with [Docker Compose](https://docs.docker.com/compose/) | ||
pre-installed, so you don't have to worry about it. | ||
|
||
After cloning or downloading this repository, rename file `.env.example` to | ||
`.env` and change configuration as needed. Then, navigate to the project folder | ||
(where you'll find `docker-compose.yml` ) and run: | ||
|
||
```bash | ||
docker compose build | ||
``` | ||
|
||
This will download the necessary Docker Images for our project to run and | ||
build a new image with `./Servers/Dockerfile`, where our server dependencies | ||
are listed. | ||
|
||
Now, you can run: | ||
|
||
```bash | ||
docker compose run --rm melia-server dotnet build | ||
``` | ||
|
||
This will create our server binaries, making it ready to start with our next | ||
command: | ||
|
||
```bash | ||
docker compose up -d | ||
``` | ||
|
||
Wait for a few seconds for everything to initialize. Then, you can go to your | ||
browser and access [http://127.0.0.1/toslive/patch/serverlist.xml] to check | ||
if server is up and running. | ||
|
||
You can restart server if anything goes wrong using: | ||
|
||
```bash | ||
docker compose restart | ||
``` | ||
|
||
If you change anything on source code, you need to run | ||
`docker compose run --rm melia-server dotnet build` again and restart your | ||
server with `docker compose restart` | ||
|
||
Database with Docker | ||
----------------------------------------------------------------------------- | ||
|
||
With the Docker containers, we've added a PHPMyAdmin container, which can be | ||
accessed via [http://127.0.0.1:8080]. Default user is `root` and password | ||
is `123456` (You can change password on `.env`, but remember to change on | ||
`user/conf/database.conf` as well). | ||
|
||
Client | ||
----------------------------------------------------------------------------- | ||
|
||
Melia does not have a client of its own at this time. Instead, it's designed | ||
to be network compatible with the latest client of the international | ||
version of ToS, which is freely available on Steam. | ||
|
||
After downloading, open your client folder (Steam > Right-Click on Game > | ||
Manage > Browse Local Files). Then, open `release/client.xml` with a text | ||
editor. | ||
|
||
Change the line which starts with `<GameOption ServerList [...]` to this: | ||
|
||
```xml | ||
<GameOption ServerListURL="http://127.0.0.1/toslive/patch/serverlist.xml" StaticConfigURL="http://127.0.0.1/toslive/patch/" NewAccountURL="http://127.0.0.1/" PaymentURL="http://127.0.0.1/" LoadingImgURL="http://127.0.0.1/toslive/patch/loadingimg/" LoadingImgCount="10"/> | ||
``` | ||
|
||
Note: If your server is not on the same machine you're playing, change | ||
`127.0.0.1` to your Server's LAN / WAN IP. | ||
|
||
Now you can open your game and play. | ||
|
||
If you're using Docker, you can't use server's console to create your | ||
account, so, when logging in for the first time, use `new__` as a prefix | ||
to your username. | ||
|
||
Example: | ||
|
||
```bash | ||
Username: new__myaccount | ||
Password: mypassword | ||
``` | ||
|
||
This will create an account with username `myaccount` and password | ||
`mypassword`. You can check the database to make sure everything is okay, | ||
but you'll already be connected and playing. Next time, just login with | ||
your username without the `new__` prefix. | ||
|
||
Installation from scratch | ||
----------------------------------------------------------------------------- | ||
|
||
- Compile Melia | ||
- Run `sql/main.sql` to setup the database | ||
- Copy `system/conf/database.conf` to `user/conf/`, | ||
adjust the necessary values and remove the rest. | ||
|
||
Afterwards, you should be able to start Melia via the provided scripts or | ||
directly from the bin directories. If not, or if you need a more detailed | ||
guide, head over to our forum, the chat, or the wiki. | ||
|
||
Requirements to build from scratch | ||
----------------------------------------------------------------------------- | ||
|
||
Melia is being developed in C# (.NET 8+) and uses a MySQL database for | ||
|
@@ -57,18 +160,6 @@ macOS, you will need to install the SDK as well. | |
For more detailed instructions, please wait patiently while we give | ||
our documentation a much-needed overhaul. It's only a matter of time. | ||
|
||
Installation | ||
----------------------------------------------------------------------------- | ||
|
||
* Compile Melia | ||
* Run `sql/main.sql` to setup the database | ||
* Copy `system/conf/database.conf` to `user/conf/`, | ||
adjust the necessary values and remove the rest. | ||
|
||
Afterwards, you should be able to start Melia via the provided scripts or | ||
directly from the bin directories. If not, or if you need a more detailed | ||
guide, head over to our forum, the chat, or the wiki. | ||
|
||
Contribution | ||
----------------------------------------------------------------------------- | ||
|
||
|
@@ -77,8 +168,7 @@ Check the file CONTRIBUTING.md for instructions on how you may contribute. | |
Links | ||
----------------------------------------------------------------------------- | ||
|
||
* GitHub: https://github.com/NoCode-NoLife/melia | ||
* Wiki: https://github.com/NoCode-NoLife/melia/wiki | ||
* Forum: https://nocodenolife.org/forum/65-melia/ | ||
* Chat: https://discord.gg/5sszEgw | ||
|
||
- GitHub: https://github.com/NoCode-NoLife/melia | ||
- Wiki: https://github.com/NoCode-NoLife/melia/wiki | ||
- Forum: https://nocodenolife.org/forum/65-melia/ | ||
- Chat: https://discord.gg/5sszEgw |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM ubuntu:22.04 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the name of this folder could be chosen better, as "Servers" has a rather general purpose ring to it, that seems misleading, seeing how it's only used for Docker. |
||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
WORKDIR / | ||
|
||
RUN apt update -y && apt upgrade -y && apt install -y dotnet-sdk-8.0 aspnetcore-runtime-8.0 git php libapache2-mod-php php-cgi php-mysql vim | ||
|
||
WORKDIR /melia | ||
|
||
CMD ["./start", "Debug", "BarracksServer"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: "melia" | ||
services: | ||
melia-database: | ||
container_name: melia-database | ||
image: mysql:8.3 | ||
networks: | ||
- melia-network | ||
ports: | ||
- 3306:3306 | ||
environment: | ||
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} | ||
volumes: | ||
- ./sql:/docker-entrypoint-initdb.d | ||
- ./.mysql/:/var/lib/mysql | ||
restart: ${SERVER_RESTART} | ||
env_file: | ||
- ./.env | ||
healthcheck: | ||
test: "/usr/bin/mysql --user=root --password=${MYSQL_ROOT_PASSWORD} --execute \"SHOW DATABASES;\"" | ||
interval: 5s | ||
timeout: 10s | ||
retries: 40 | ||
|
||
melia-server: | ||
container_name: melia-server | ||
command: "./start ${ENVIRONMENT}" | ||
# command: "tail -f /dev/null" | ||
build: "./Servers" | ||
networks: | ||
- melia-network | ||
volumes: | ||
- ./:/melia | ||
depends_on: | ||
melia-database: | ||
condition: service_healthy | ||
ports: | ||
- "2000:2000" | ||
- "6001:6001" | ||
- "7001:7001" | ||
- "7002:7002" | ||
- "80:80" | ||
restart: ${SERVER_RESTART} | ||
env_file: | ||
- ./.env | ||
phpmyadmin: | ||
container_name: melia-dbadmin | ||
networks: | ||
- melia-network | ||
image: phpmyadmin | ||
ports: | ||
- 8080:80 | ||
restart: ${SERVER_RESTART} | ||
environment: | ||
- PMA_HOST=melia-database | ||
- PMA_USER=root | ||
- PMA_PASSWORD=${MYSQL_ROOT_PASSWORD} | ||
- UPLOAD_LIMIT=300M | ||
profiles: [] | ||
env_file: | ||
- ./.env | ||
depends_on: | ||
melia-database: | ||
condition: service_healthy | ||
networks: | ||
melia-network: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
CREATE TABLE `character_etc_properties` ( | ||
`propertyId` bigint(20) NOT NULL, | ||
CREATE TABLE IF NOT EXISTS `character_etc_properties` ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you tell me what this change is about? I feel like we'd want this to fail if the table already exists, because that's an indicator for something not being right. |
||
`propertyId` bigint(20) NOT NULL AUTO_INCREMENT, | ||
`characterId` bigint(20) NOT NULL, | ||
`name` varchar(64) NOT NULL, | ||
`type` varchar(1) NOT NULL, | ||
`value` varchar(255) NOT NULL | ||
`value` varchar(255) NOT NULL, | ||
PRIMARY KEY (`propertyId`), | ||
KEY `characterId` (`characterId`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; | ||
|
||
ALTER TABLE `character_etc_properties` | ||
ADD PRIMARY KEY (`propertyId`), | ||
ADD KEY `characterId` (`characterId`); | ||
|
||
ALTER TABLE `character_etc_properties` | ||
MODIFY `propertyId` bigint(20) NOT NULL AUTO_INCREMENT; | ||
-- Drop the foreign key if it exists | ||
-- ALTER TABLE `character_etc_properties` | ||
-- DROP FOREIGN KEY `character_etc_properties_ibfk_1`; | ||
|
||
-- Add the foreign key constraint again | ||
ALTER TABLE `character_etc_properties` | ||
ADD CONSTRAINT `character_etc_properties_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE, | ||
ADD CONSTRAINT `character_etc_properties_ibfk_2` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
ADD CONSTRAINT `character_etc_properties_ibfk_1` FOREIGN KEY (`characterId`) REFERENCES `characters` (`characterId`) ON DELETE CASCADE ON UPDATE CASCADE; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
CREATE TABLE `storage_team` ( | ||
CREATE TABLE IF NOT EXISTS `storage_team` ( | ||
`accountId` bigint(20) NOT NULL, | ||
`itemId` bigint(20) NOT NULL, | ||
`position` int(11) NOT NULL | ||
`position` int(11) NOT NULL, | ||
PRIMARY KEY (`accountId`, `itemId`), | ||
KEY `itemId` (`itemId`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci; | ||
|
||
-- Drop the first foreign key if it exists | ||
-- ALTER TABLE `storage_team` | ||
-- DROP FOREIGN KEY `storage_team_ibfk_1`; | ||
|
||
-- Drop the second foreign key if it exists | ||
-- ALTER TABLE `storage_team` | ||
-- DROP FOREIGN KEY `storage_team_ibfk_2`; | ||
|
||
-- Add the first foreign key constraint | ||
ALTER TABLE `storage_team` | ||
ADD PRIMARY KEY (`accountId`,`itemId`), | ||
ADD KEY `itemId` (`itemId`); | ||
ADD CONSTRAINT `storage_team_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- Add the second foreign key constraint | ||
ALTER TABLE `storage_team` | ||
ADD CONSTRAINT `storage_team_ibfk_1` FOREIGN KEY (`accountId`) REFERENCES `accounts` (`accountId`) ON DELETE CASCADE ON UPDATE CASCADE, | ||
ADD CONSTRAINT `storage_team_ibfk_2` FOREIGN KEY (`itemId`) REFERENCES `items` (`itemUniqueId`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
ADD CONSTRAINT `storage_team_ibfk_2` FOREIGN KEY (`itemId`) REFERENCES `items` (`itemUniqueId`) ON DELETE CASCADE ON UPDATE CASCADE; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using System.IO; | ||
using System; | ||
using System.IO; | ||
using Yggdrasil.Configuration; | ||
|
||
namespace Melia.Shared.Configuration.Files | ||
|
@@ -17,8 +18,12 @@ public class WebConfFile : ConfFile | |
public void Load(string filePath) | ||
{ | ||
this.Include(filePath); | ||
|
||
this.PhpCgiFilePath = this.GetString("php_cgi_bin", Path.Combine("user", "tools", "php", "php-cgi.exe")); | ||
if (Environment.OSVersion.Platform == PlatformID.Win32NT) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't really change anything, because the configuration value is read from the conf file regardless of the operating system. The only way you will get the usr bin path from this is if the conf option is missing. |
||
{ | ||
this.PhpCgiFilePath = this.GetString("php_cgi_bin", Path.Combine("user", "tools", "php", "php-cgi.exe")); | ||
} else { | ||
this.PhpCgiFilePath = this.GetString("php_cgi_bin", "/usr/bin/php-cgi"); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it would be beneficial to include a brief explanation of what this file is, for anyone who might look inside without knowing about Docker.