File tree 16 files changed +177
-23
lines changed
16 files changed +177
-23
lines changed Original file line number Diff line number Diff line change
1
+ ** /.dockerignore
2
+ ** /.env
3
+ ** /.git
4
+ ** /.gitignore
5
+ ** /.project
6
+ ** /.settings
7
+ ** /.toolstarget
8
+ ** /.vs
9
+ ** /.vscode
10
+ ** /.idea
11
+ ** /* . * proj.user
12
+ ** /* .dbmdl
13
+ ** /* .jfm
14
+ ** /azds.yaml
15
+ ** /bin
16
+ ** /charts
17
+ ** /docker-compose *
18
+ ** /Dockerfile *
19
+ ** /node_modules
20
+ ** /npm-debug.log
21
+ ** /obj
22
+ ** /secrets.dev.yaml
23
+ ** /values.dev.yaml
24
+ LICENSE
25
+ README.md
Original file line number Diff line number Diff line change 11
11
12
12
<ItemGroup >
13
13
<PackageReference Include =" Caching.dll" Version =" 2.0.0.1" />
14
- <PackageReference Include =" Microsoft.EntityFrameworkCore" Version =" 6.0.5 " />
15
- <PackageReference Include =" Microsoft.EntityFrameworkCore.Relational" Version =" 6.0.5 " />
14
+ <PackageReference Include =" Microsoft.EntityFrameworkCore" Version =" 6.0.6 " />
15
+ <PackageReference Include =" Microsoft.EntityFrameworkCore.Relational" Version =" 6.0.6 " />
16
16
<PackageReference Include =" Wivuu.JsonPolymorphism" Version =" 1.0.16" />
17
17
</ItemGroup >
18
18
Original file line number Diff line number Diff line change 11
11
const string env = "Live" ;
12
12
const string xmlPath = @"C:\Nexon\Library\Library\maplestory2\appdata\Data\Xml.m2d" ;
13
13
const string exportedPath = @"C:\Nexon\Library\Library\maplestory2\appdata\Data\Resource\Exported.m2d" ;
14
- const string connectionString = "Server=localhost;Database=maple-data;User=root;Password=maplestory" ;
15
14
16
15
Console . OutputEncoding = System . Text . Encoding . UTF8 ;
17
16
17
+ string ? dataDbConnection = Environment . GetEnvironmentVariable ( "DATA_DB_CONNECTION" ) ;
18
+ if ( dataDbConnection == null ) {
19
+ throw new ArgumentException ( "DATA_DB_CONNECTION environment variable was not set" ) ;
20
+ }
21
+
18
22
using var xmlReader = new M2dReader ( xmlPath ) ;
19
23
using var exportedReader = new M2dReader ( exportedPath ) ;
20
24
21
25
DbContextOptions options = new DbContextOptionsBuilder ( )
22
- . UseMySql ( connectionString , ServerVersion . AutoDetect ( connectionString ) ) . Options ;
26
+ . UseMySql ( dataDbConnection , ServerVersion . AutoDetect ( dataDbConnection ) ) . Options ;
23
27
24
28
using var metadataContext = new MetadataContext ( options ) ;
25
29
metadataContext . Database . EnsureCreated ( ) ;
Original file line number Diff line number Diff line change 3
3
namespace Maple2 . Server . Core . Constants ;
4
4
5
5
public static class Target {
6
- public const string GAME_DB_CONNECTION = "Server=localhost;Database=game-server;User=root;Password=maplestory" ;
7
- public const string DATA_DB_CONNECTION = "Server=localhost;Database=maple-data;User=root;Password=maplestory" ;
8
-
9
6
public const string SEVER_NAME = "Paperwood" ;
10
7
public const string LOCALE = "NA" ;
11
8
@@ -17,8 +14,8 @@ public static class Target {
17
14
public const ushort GAME_CHANNEL = 1 ;
18
15
19
16
public static readonly IPAddress GRPC_WORLD_IP = IPAddress . Loopback ;
20
- public const ushort GRPC_WORLD_PORT = 20101 ;
17
+ public const ushort GRPC_WORLD_PORT = 20100 ;
21
18
22
19
public static readonly IPAddress GRPC_CHANNEL_IP = IPAddress . Loopback ;
23
- public const ushort GRPC_CHANNEL_PORT = 22101 ;
20
+ public const ushort GRPC_CHANNEL_PORT = 22100 ;
24
21
}
Original file line number Diff line number Diff line change 9
9
10
10
<ItemGroup >
11
11
<PackageReference Include =" Autofac.Extensions.DependencyInjection" Version =" 8.0.0" />
12
- <PackageReference Include =" Google.Protobuf" Version =" 3.21.1 " />
12
+ <PackageReference Include =" Google.Protobuf" Version =" 3.21.2 " />
13
13
<PackageReference Include =" Grpc.AspNetCore.Server" Version =" 2.46.0" />
14
14
<PackageReference Include =" Grpc.Net.ClientFactory" Version =" 2.46.0" />
15
- <PackageReference Include =" Grpc.Tools" Version =" 2.46.3 " >
15
+ <PackageReference Include =" Grpc.Tools" Version =" 2.47.0 " >
16
16
<PrivateAssets >all</PrivateAssets >
17
17
<IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
18
18
</PackageReference >
Original file line number Diff line number Diff line change 1
- using Autofac ;
1
+ using System ;
2
+ using Autofac ;
2
3
using Maple2 . Database . Context ;
3
4
using Maple2 . Database . Storage ;
4
5
using Maple2 . Model . Metadata ;
5
- using Maple2 . Server . Core . Constants ;
6
6
using Microsoft . EntityFrameworkCore ;
7
7
using Module = Autofac . Module ;
8
8
@@ -12,8 +12,13 @@ public class DataDbModule : Module {
12
12
private readonly DbContextOptions options ;
13
13
14
14
public DataDbModule ( ) {
15
+ string ? dataDbConnection = Environment . GetEnvironmentVariable ( "DATA_DB_CONNECTION" ) ;
16
+ if ( dataDbConnection == null ) {
17
+ throw new ArgumentException ( "DATA_DB_CONNECTION environment variable was not set" ) ;
18
+ }
19
+
15
20
options = new DbContextOptionsBuilder ( )
16
- . UseMySql ( Target . DATA_DB_CONNECTION , ServerVersion . AutoDetect ( Target . DATA_DB_CONNECTION ) )
21
+ . UseMySql ( dataDbConnection , ServerVersion . AutoDetect ( dataDbConnection ) )
17
22
. Options ;
18
23
}
19
24
Original file line number Diff line number Diff line change 1
- using System . Reflection ;
1
+ using System ;
2
+ using System . Reflection ;
2
3
using Autofac ;
3
4
using Maple2 . Database . Storage ;
4
- using Maple2 . Server . Core . Constants ;
5
5
using Microsoft . EntityFrameworkCore ;
6
6
using Module = Autofac . Module ;
7
7
@@ -13,8 +13,13 @@ public class GameDbModule : Module {
13
13
private readonly DbContextOptions options ;
14
14
15
15
public GameDbModule ( ) {
16
+ string ? gameDbConnection = Environment . GetEnvironmentVariable ( "GAME_DB_CONNECTION" ) ;
17
+ if ( gameDbConnection == null ) {
18
+ throw new ArgumentException ( "GAME_DB_CONNECTION environment variable was not set" ) ;
19
+ }
20
+
16
21
options = new DbContextOptionsBuilder ( )
17
- . UseMySql ( Target . GAME_DB_CONNECTION , ServerVersion . AutoDetect ( Target . GAME_DB_CONNECTION ) )
22
+ . UseMySql ( gameDbConnection , ServerVersion . AutoDetect ( gameDbConnection ) )
18
23
. Options ;
19
24
}
20
25
Original file line number Diff line number Diff line change
1
+ FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
2
+ WORKDIR /app
3
+ # Game Server
4
+ EXPOSE 22001
5
+ # Channel Service
6
+ EXPOSE 22100
7
+
8
+ FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
9
+ WORKDIR /src
10
+ COPY ["Maple2.Server.Game/Maple2.Server.Game.csproj" , "Maple2.Server.Game/" ]
11
+ COPY ["Maple2.Tools/Maple2.Tools.csproj" , "Maple2.Tools/" ]
12
+ COPY ["Maple2.Model/Maple2.Model.csproj" , "Maple2.Model/" ]
13
+ COPY ["Maple2.Database/Maple2.Database.csproj" , "Maple2.Database/" ]
14
+ COPY ["Maple2.Server.Core/Maple2.Server.Core.csproj" , "Maple2.Server.Core/" ]
15
+ COPY ["Maple2.Script/Maple2.Script.csproj" , "Maple2.Script/" ]
16
+ RUN dotnet restore "Maple2.Server.Game/Maple2.Server.Game.csproj"
17
+ COPY . .
18
+ WORKDIR "/src/Maple2.Server.Game"
19
+ RUN dotnet build "Maple2.Server.Game.csproj" -c Debug -o /app/build
20
+
21
+ FROM build AS publish
22
+ RUN dotnet publish "Maple2.Server.Game.csproj" -c Debug -o /app/publish
23
+
24
+ FROM base AS final
25
+ WORKDIR /app
26
+ COPY --from=publish /app/publish .
27
+ ENTRYPOINT ["dotnet" , "Maple2.Server.Game.dll" ]
Original file line number Diff line number Diff line change 4
4
<OutputType >Exe</OutputType >
5
5
<TargetFramework >net6.0</TargetFramework >
6
6
<Nullable >enable</Nullable >
7
+ <DockerDefaultTargetOS >Linux</DockerDefaultTargetOS >
7
8
</PropertyGroup >
8
9
9
10
<ItemGroup >
Original file line number Diff line number Diff line change
1
+ FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
2
+ WORKDIR /app
3
+ # Login Server
4
+ EXPOSE 20001
5
+
6
+ FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
7
+ WORKDIR /src
8
+ COPY ["Maple2.Server.Login/Maple2.Server.Login.csproj" , "Maple2.Server.Login/" ]
9
+ COPY ["Maple2.Tools/Maple2.Tools.csproj" , "Maple2.Tools/" ]
10
+ COPY ["Maple2.Model/Maple2.Model.csproj" , "Maple2.Model/" ]
11
+ COPY ["Maple2.Database/Maple2.Database.csproj" , "Maple2.Database/" ]
12
+ COPY ["Maple2.Server.Core/Maple2.Server.Core.csproj" , "Maple2.Server.Core/" ]
13
+ RUN dotnet restore "Maple2.Server.Login/Maple2.Server.Login.csproj"
14
+ COPY . .
15
+ WORKDIR "/src/Maple2.Server.Login"
16
+ RUN dotnet build "Maple2.Server.Login.csproj" -c Debug -o /app/build
17
+
18
+ FROM build AS publish
19
+ RUN dotnet publish "Maple2.Server.Login.csproj" -c Debug -o /app/publish
20
+
21
+ FROM base AS final
22
+ WORKDIR /app
23
+ COPY --from=publish /app/publish .
24
+ ENTRYPOINT ["dotnet" , "Maple2.Server.Login.dll" ]
Original file line number Diff line number Diff line change 4
4
<OutputType >Exe</OutputType >
5
5
<TargetFramework >net6.0</TargetFramework >
6
6
<Nullable >enable</Nullable >
7
+ <DockerDefaultTargetOS >Windows</DockerDefaultTargetOS >
7
8
</PropertyGroup >
8
9
9
10
<ItemGroup >
Original file line number Diff line number Diff line change 8
8
</PropertyGroup >
9
9
10
10
<ItemGroup >
11
- <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 16.11.0" />
12
- <PackageReference Include =" MSTest.TestAdapter" Version =" 2.2.7" />
13
- <PackageReference Include =" MSTest.TestFramework" Version =" 2.2.7" />
14
- <PackageReference Include =" coverlet.collector" Version =" 3.1.0" />
11
+ <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 17.2.0" />
12
+ <PackageReference Include =" MSTest.TestAdapter" Version =" 2.2.10" />
13
+ <PackageReference Include =" MSTest.TestFramework" Version =" 2.2.10" />
14
+ <PackageReference Include =" coverlet.collector" Version =" 3.1.2" >
15
+ <PrivateAssets >all</PrivateAssets >
16
+ <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
17
+ </PackageReference >
15
18
</ItemGroup >
16
19
17
20
<ItemGroup >
Original file line number Diff line number Diff line change
1
+ FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
2
+ WORKDIR /app
3
+ # World Service, Global Service
4
+ EXPOSE 20100
5
+
6
+ FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
7
+ WORKDIR /src
8
+ COPY ["Maple2.Server.World/Maple2.Server.World.csproj" , "Maple2.Server.World/" ]
9
+ COPY ["Maple2.Tools/Maple2.Tools.csproj" , "Maple2.Tools/" ]
10
+ COPY ["Maple2.Model/Maple2.Model.csproj" , "Maple2.Model/" ]
11
+ COPY ["Maple2.Database/Maple2.Database.csproj" , "Maple2.Database/" ]
12
+ COPY ["Maple2.Server.Core/Maple2.Server.Core.csproj" , "Maple2.Server.Core/" ]
13
+ RUN dotnet restore "Maple2.Server.World/Maple2.Server.World.csproj"
14
+ COPY . .
15
+ WORKDIR "/src/Maple2.Server.World"
16
+ RUN dotnet build "Maple2.Server.World.csproj" -c Debug -o /app/build
17
+
18
+ FROM build AS publish
19
+ RUN dotnet publish "Maple2.Server.World.csproj" -c Debug -o /app/publish
20
+
21
+ FROM base AS final
22
+ WORKDIR /app
23
+ COPY --from=publish /app/publish .
24
+ ENTRYPOINT ["dotnet" , "Maple2.Server.World.dll" ]
Original file line number Diff line number Diff line change 4
4
<OutputType >Exe</OutputType >
5
5
<TargetFramework >net6.0</TargetFramework >
6
6
<Nullable >enable</Nullable >
7
+ <DockerDefaultTargetOS >Linux</DockerDefaultTargetOS >
7
8
</PropertyGroup >
8
9
9
10
<ItemGroup >
Original file line number Diff line number Diff line change 2
2
using System . IO ;
3
3
using Autofac . Extensions . DependencyInjection ;
4
4
using Maple2 . Database . Context ;
5
- using Maple2 . Server . Core . Constants ;
6
5
using Maple2 . Server . World ;
7
6
using Microsoft . AspNetCore . Hosting ;
8
7
using Microsoft . EntityFrameworkCore ;
19
18
. ReadFrom . Configuration ( configRoot )
20
19
. CreateLogger ( ) ;
21
20
21
+ string ? gameDbConnection = Environment . GetEnvironmentVariable ( "GAME_DB_CONNECTION" ) ;
22
+ if ( gameDbConnection == null ) {
23
+ throw new ArgumentException ( "GAME_DB_CONNECTION environment variable was not set" ) ;
24
+ }
25
+
22
26
IHostBuilder builder = Host . CreateDefaultBuilder ( )
23
27
. ConfigureLogging ( logging => {
24
28
logging . ClearProviders ( ) ;
28
32
. ConfigureWebHostDefaults ( builder => builder . UseStartup < Startup > ( ) ) ;
29
33
30
34
DbContextOptions options = new DbContextOptionsBuilder ( )
31
- . UseMySql ( Target . GAME_DB_CONNECTION , ServerVersion . AutoDetect ( Target . GAME_DB_CONNECTION ) ) . Options ;
35
+ . UseMySql ( gameDbConnection , ServerVersion . AutoDetect ( gameDbConnection ) ) . Options ;
32
36
await using ( var initContext = new InitializationContext ( options ) ) {
33
37
// Initialize database if needed
34
38
if ( ! initContext . Initialize ( ) ) {
Original file line number Diff line number Diff line change
1
+ services :
2
+ world :
3
+ image : maple2-world
4
+ network_mode : bridge
5
+ ports :
6
+ - " 127.0.0.1:20100:20100"
7
+ environment :
8
+ GAME_DB_CONNECTION : " Server=host.docker.internal;Database=game-server;User=root;Password=maplestory"
9
+ DATA_DB_CONNECTION : " Server=host.docker.internal;Database=maple-data;User=root;Password=maplestory"
10
+
11
+ login :
12
+ image : maple2-login
13
+ depends_on :
14
+ - world
15
+ network_mode : bridge
16
+ ports :
17
+ - " 20001:20001"
18
+ environment :
19
+ GAME_DB_CONNECTION : " Server=host.docker.internal;Database=game-server;User=root;Password=maplestory"
20
+ DATA_DB_CONNECTION : " Server=host.docker.internal;Database=maple-data;User=root;Password=maplestory"
21
+
22
+ game :
23
+ image : maple2-game
24
+ depends_on :
25
+ - world
26
+ - login
27
+ network_mode : bridge
28
+ ports :
29
+ - " 22001:22001"
30
+ - " 127.0.0.1:22100:22100"
31
+ environment :
32
+ GAME_DB_CONNECTION : " Server=host.docker.internal;Database=game-server;User=root;Password=maplestory"
33
+ DATA_DB_CONNECTION : " Server=host.docker.internal;Database=maple-data;User=root;Password=maplestory"
You can’t perform that action at this time.
0 commit comments