Skip to content

Commit

Permalink
Update docker files (#205)
Browse files Browse the repository at this point in the history
* Update docker files

* Update .NET

* Add container to ingest metadata

* Add container to process database seeding and file ingestion

* Add entrypoint for db-seed container

* Remove unused ENV variables

* Clean up

* Clean up
  • Loading branch information
sgessa authored and AngeloTadeucci committed Aug 3, 2024
1 parent 6d5c58b commit 3db3ec7
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 49 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Maple2.File.Ingest

# To use with docker, rename MS2_DATA_FOLDER to MS2_DOCKER_DATA_FOLDER
MS2_DATA_FOLDER=C:/Nexon/Library/maplestory2/

# Database connection
Expand Down
13 changes: 13 additions & 0 deletions Maple2.Database.Seed/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

if [ ! -f /root/.dotnet/tools/dotnet-ef ]; then
echo -n 'Installing dotnet EF... '
dotnet tool install --global dotnet-ef 2>&1 > /dev/null
echo 'done'
fi

export PATH="$PATH:/root/.dotnet/tools"

cd /app/Maple2.Database.Seed

dotnet run
4 changes: 2 additions & 2 deletions Maple2.Server.Game/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
# Game Server
#EXPOSE 20002
# Channel Service
#EXPOSE 21002

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["Maple2.Server.Game/Maple2.Server.Game.csproj", "Maple2.Server.Game/"]
COPY ["Maple2.Tools/Maple2.Tools.csproj", "Maple2.Tools/"]
Expand Down
5 changes: 2 additions & 3 deletions Maple2.Server.Login/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
# Login Server
EXPOSE 20001

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["Maple2.Server.Login/Maple2.Server.Login.csproj", "Maple2.Server.Login/"]
COPY ["Maple2.Tools/Maple2.Tools.csproj", "Maple2.Tools/"]
Expand All @@ -21,4 +21,3 @@ RUN dotnet publish -r win-x64 "Maple2.Server.Login.csproj" -c Debug -o /app/publ
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Maple2.Server.Login.dll"]
4 changes: 2 additions & 2 deletions Maple2.Server.Web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM mcr.microsoft.com/dotnet/runtime:7.0 AS base
FROM mcr.microsoft.com/dotnet/runtime:8.0 AS base
WORKDIR /app
# Web Service (HTTP)
EXPOSE 80
# Web Service (HTTPS)
# EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["Maple2.Server.Web/Maple2.Server.Web.csproj", "Maple2.Server.Web/"]
COPY ["Maple2.Database/Maple2.Database.csproj", "Maple2.Database/"]
Expand Down
5 changes: 2 additions & 3 deletions Maple2.Server.World/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
# World Service, Global Service
EXPOSE 21001

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["Maple2.Server.World/Maple2.Server.World.csproj", "Maple2.Server.World/"]
COPY ["Maple2.Tools/Maple2.Tools.csproj", "Maple2.Tools/"]
Expand All @@ -21,4 +21,3 @@ RUN dotnet publish -r win-x64 "Maple2.Server.World.csproj" -c Debug -o /app/publ
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Maple2.Server.World.dll"]
4 changes: 2 additions & 2 deletions Maple2.Tools/Dotenv.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;

namespace Maple2.Tools;
Expand All @@ -7,7 +7,7 @@ public static void Load() {
string dotenv = Path.Combine(Paths.SOLUTION_DIR, ".env");

if (!File.Exists(dotenv)) {
throw new FileNotFoundException(".env file not found!");
return;
}

foreach (string line in File.ReadAllLines(dotenv)) {
Expand Down
140 changes: 103 additions & 37 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -1,81 +1,147 @@
services:
world:
build:
context: .
dockerfile: ./Maple2.Server.World/Dockerfile
image: maple2-world:dev
ports:
- "21001:21001"
db-seed:
container_name: maple2-db-seed
image: mcr.microsoft.com/dotnet/sdk:8.0
entrypoint: /app/Maple2.Database.Seed/docker-entrypoint.sh
depends_on:
- mysql
links:
- mysql
env_file:
- .env
environment:
GAME_DB_CONNECTION: "Server=host.docker.internal;Database=game-server;User=root;Password=maplestory;oldguids=true"
DATA_DB_CONNECTION: "Server=host.docker.internal;Database=maple-data;User=root;Password=maplestory;oldguids=true"
CHANNEL_SERVICE: "game-main,game-alt"
GAME_IP: "127.0.0.1"
LOGIN_IP: "127.0.0.1"
DB_IP: mysql
volumes:
- .:/app
- dotnet_tools:/root/.dotnet/tools

file-ingest:
container_name: maple2-file-ingest
image: mcr.microsoft.com/dotnet/sdk:8.0
working_dir: /app/Maple2.File.Ingest
command: dotnet run
depends_on:
- mysql
links:
- mysql
env_file:
- .env
environment:
DB_IP: mysql
MS2_DATA_FOLDER: /ClientData
volumes:
- .:/app
- ${MS2_DOCKER_DATA_FOLDER}:/ClientData

login:
build:
context: .
dockerfile: ./Maple2.Server.Login/Dockerfile
image: maple2-login:dev
container_name: maple2-login
image: maple2/login
command: dotnet Maple2.Server.Login.dll
depends_on:
- world
mysql:
condition: service_started
world:
condition: service_started
ports:
- "20001:20001"
- 20001:20001
links:
- "world"
- world
env_file:
- .env
environment:
GAME_DB_CONNECTION: "Server=host.docker.internal;Database=game-server;User=root;Password=maplestory;oldguids=true"
DATA_DB_CONNECTION: "Server=host.docker.internal;Database=maple-data;User=root;Password=maplestory;oldguids=true"
WORLD_SERVICE: "world"
LOGIN_IP: "127.0.0.1"
WEB_URI: "http://127.0.0.1"
DB_IP: mysql
WORLD_SERVICE: world

world:
build:
context: .
dockerfile: ./Maple2.Server.World/Dockerfile
container_name: maple2-world
image: maple2/world
command: dotnet Maple2.Server.World.dll
depends_on:
- mysql
ports:
- 21001:21001
env_file:
- .env
environment:
DB_IP: mysql
CHANNEL_SERVICE: "game-main,game-alt"

game-main:
build:
context: .
dockerfile: ./Maple2.Server.Game/Dockerfile
image: maple2-game:dev
image: maple2/game
depends_on:
- mysql
- world
ports:
- "20002:20002"
- "21002:21002"
- 20002:20002
- 21002:21002
env_file:
- .env
environment:
GAME_DB_CONNECTION: "Server=host.docker.internal;Database=game-server;User=root;Password=maplestory;oldguids=true"
DATA_DB_CONNECTION: "Server=host.docker.internal;Database=maple-data;User=root;Password=maplestory;oldguids=true"
DB_IP: mysql
GAME_CHANNEL: 1
GAME_PORT: 20002
GRPC_CHANNEL_PORT: 21002
WORLD_SERVICE: "world"
WORLD_SERVICE: world
GAME_IP: "127.0.0.1"

game-alt:
build:
context: .
dockerfile: ./Maple2.Server.Game/Dockerfile
image: maple2-game:dev
image: maple2/game
depends_on:
- mysql
- world
ports:
- "20003:20003"
- "21003:21003"
- 20003:20003
- 21003:21003
env_file:
- .env
environment:
GAME_DB_CONNECTION: "Server=host.docker.internal;Database=game-server;User=root;Password=maplestory;oldguids=true"
DATA_DB_CONNECTION: "Server=host.docker.internal;Database=maple-data;User=root;Password=maplestory;oldguids=true"
DB_IP: mysql
GAME_CHANNEL: 2
GAME_PORT: 20003
GRPC_CHANNEL_PORT: 21003
WORLD_SERVICE: "world"
WORLD_SERVICE: world
GAME_IP: "127.0.0.1"

web:
build:
context: .
dockerfile: ./Maple2.Server.Web/Dockerfile
image: maple2-web:dev
image: maple2/web
depends_on:
- mysql
ports:
- "80:80"
- "443:443"
- 80:80
- 443:443
env_file:
- .env
environment:
GAME_DB_CONNECTION: "Server=host.docker.internal;Database=game-server;User=root;Password=maplestory;oldguids=true"
DB_IP: mysql

mysql:
image: mysql:8.0
restart: unless-stopped
container_name: maple2-db
env_file:
- .env
environment:
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
volumes:
- mysql:/var/lib/mysql
ports:
- 3306:3306

volumes:
dotnet_tools:
mysql:

0 comments on commit 3db3ec7

Please sign in to comment.