From fa0870784a6f2cc77b91da95c5719dcd7fc4fdc5 Mon Sep 17 00:00:00 2001 From: Robert Paciorek Date: Tue, 19 Mar 2024 20:45:56 +0000 Subject: [PATCH] add run.sh/bat, simplify/update docker config, ... - add run.sh and run.bat - change docker config - by default include source in docker image for simple debug (can be disabled via uncoment section in Dockerfile) - add docker-compose.yml - change default time to start first battle event after server start (login first player) to 3 minutes --- .dockerignore | 7 ------- docker-compose.yml | 21 +++++++++++++++++++++ run.bat | 3 +++ run.sh | 1 + src/Dockerfile | 26 ++++++++++++-------------- src/appsettings.json | 2 +- 6 files changed, 38 insertions(+), 22 deletions(-) create mode 100644 docker-compose.yml create mode 100755 run.bat create mode 100755 run.sh diff --git a/.dockerignore b/.dockerignore index 3729ff0..18759fb 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,8 +1,5 @@ **/.classpath -**/.dockerignore **/.env -**/.git -**/.gitignore **/.project **/.settings **/.toolstarget @@ -14,12 +11,8 @@ **/azds.yaml **/bin **/charts -**/docker-compose* -**/Dockerfile* **/node_modules **/npm-debug.log **/obj **/secrets.dev.yaml **/values.dev.yaml -LICENSE -README.md \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..79bf549 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ +version: '3.8' +services: + sodoffmmo: + build: + context: . + dockerfile: src/Dockerfile + ports: + - "9933:9933" + networks: + - sodoff_network + +networks: + sodoff_network: + name: sodoff_network + # bellow network configuration should be put in at least one file + # - but it may be in many or all + # - without it it will work like `external: true` + driver: bridge + ipam: + config: + - subnet: "172.16.99.0/24" diff --git a/run.bat b/run.bat new file mode 100755 index 0000000..9651b8c --- /dev/null +++ b/run.bat @@ -0,0 +1,3 @@ +dotnet run --project src/sodoffmmo.csproj + +pause diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..710f74e --- /dev/null +++ b/run.sh @@ -0,0 +1 @@ +dotnet run --project src/sodoffmmo.csproj diff --git a/src/Dockerfile b/src/Dockerfile index 1728f7b..3775637 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -1,20 +1,18 @@ -#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. - -FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base -WORKDIR /app - +# Use the official .NET SDK image for building the application FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src -COPY ["src/sodoffmmo.csproj", "src/"] -RUN dotnet restore "src/sodoffmmo.csproj" + +# Copy the source code COPY . . -WORKDIR "/src/src" -RUN dotnet build "sodoffmmo.csproj" -c Release -o /app/build -FROM build AS publish -RUN dotnet publish "sodoffmmo.csproj" -c Release -o /app/publish /p:UseAppHost=false +# Restore dependencies and build the application +RUN dotnet build -c Release -o /app -FROM base AS final +# Create clean run environment (without source and sdk) +# FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base +# WORKDIR /app +# COPY --from=build /app . + +# Run the application WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "sodoffmmo.dll"] \ No newline at end of file +ENTRYPOINT ["./sodoffmmo"] diff --git a/src/appsettings.json b/src/appsettings.json index cd6f75a..df5e2fe 100644 --- a/src/appsettings.json +++ b/src/appsettings.json @@ -10,7 +10,7 @@ "EnableChat": true, "// FirstEventTimer": "time to start of first world event (battle ship event) after start MMO server", - "FirstEventTimer": 10, + "FirstEventTimer": 3, "// EventTimer": "time between start of world events (battle ship events)", "EventTimer": 30,