From 13700a11594481e448d3cf5594133047d89c6048 Mon Sep 17 00:00:00 2001 From: MrDave1999 Date: Wed, 23 Oct 2024 16:41:19 -0500 Subject: [PATCH 1/7] build: Update Dockerfile --- Dockerfile | 83 +++++++++++++++++++++++------------------------------- 1 file changed, 36 insertions(+), 47 deletions(-) diff --git a/Dockerfile b/Dockerfile index f981888f..ddfb64a2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,54 +1,45 @@ # -# Build app +# Build stage/image # -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /app +COPY *.sln . +COPY *.props . # Copy csproj and restore as distinct layers -COPY src/*.csproj . +COPY ["src/Host/*.csproj", "src/Host/"] +COPY ["src/Application/*.csproj", "src/Application/"] +COPY ["src/Persistence/Persistence.InMemory/*.csproj", "src/Persistence/Persistence.InMemory/"] +COPY ["src/Persistence/Persistence.MariaDB/*.csproj", "src/Persistence/Persistence.MariaDB/"] +COPY ["src/Persistence/Persistence.SQLite/*.csproj", "src/Persistence/Persistence.SQLite/"] +COPY ["src/Persistence/*.props", "src/Persistence/"] RUN dotnet restore # Copy everything else and build -COPY src . -RUN dotnet publish -c Release -o out +COPY ["src/", "."] +RUN dotnet publish -c Release -o out --no-restore # -# Install SA-MP server with samptcl +# Download SA-MP server and dotnet linux-x86 # -FROM southclaws/sampctl AS samp-server -WORKDIR /sampserver - -COPY pawn.json . -RUN sampctl package ensure \ - && rm -rf dependencies +FROM ubuntu:20.04 AS tools +RUN apt-get update && apt-get install -y --no-install-recommends wget -COPY include include -COPY filterscripts filterscripts -COPY build-filterscripts.sh . -RUN chmod u+x build-filterscripts.sh -RUN ["./build-filterscripts.sh"] -RUN rm -rf include \ - pawn.json \ - build-filterscripts.sh +WORKDIR /samp-server +RUN wget https://gta-multiplayer.cz/downloads/samp037svr_R2-2-1.tar.gz --no-check-certificate \ + && tar -xf samp037svr_R2-2-1.tar.gz \ + && rm -f samp037svr_R2-2-1.tar.gz +COPY ["samp037svr_R2-2-1/samp03/", "."] +RUN rm -rf filterscripts gamemodes include npcmodes scriptfiles -WORKDIR /sampserver/filterscripts -# Delete all directories except .amx files -RUN rm -rf */ +WORKDIR /dotnet-runtime +RUN wget https://github.com/Servarr/dotnet-linux-x86/releases/download/v8.0.4-90/dotnet-runtime-8.0.4-linux-x86.tar.gz --no-check-certificate \ + && tar -xf dotnet-runtime-8.0.4-linux-x86.tar.gz \ + && rm -f dotnet-runtime-8.0.4-linux-x86.tar.gz +COPY ["dotnet-runtime-8.0.4-linux-x86/shared/Microsoft.NETCore.App/8.0.4/", "."] # -# Get .NET 6 Runtime x86 -# -FROM ubuntu:20.04 AS net-runtime -WORKDIR /dotnet - -RUN apt-get update && apt-get install -y --no-install-recommends wget - -RUN wget https://deploy.timpotze.nl/packages/runtime_603_20220324.tar.gz --no-check-certificate \ - && tar -xf runtime_603_20220324.tar.gz \ - && rm -f runtime_603_20220324.tar.gz - -# -# Build runtime image +# Final stage/image # FROM ubuntu:20.04 WORKDIR /app @@ -60,17 +51,15 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libstdc++6:i386 \ libssl1.1:i386 \ libicu-dev:i386 \ - tzdata \ && rm -rf /var/lib/apt/lists/* -COPY gamemodes gamemodes -COPY wait-for-it.sh . -RUN chmod u+x wait-for-it.sh - -COPY --from=net-runtime /dotnet dotnet -COPY --from=samp-server /sampserver . -RUN echo "coreclr dotnet/runtime" >> server.cfg \ - && echo "gamemode bin/CaptureTheFlag.dll" >> server.cfg +COPY ["gamemodes/*.amx", "gamemodes/"] +COPY ["filterscripts/*.amx", "filterscripts/"] +COPY ["plugins/*.so", "plugins/"] +COPY ["scriptfiles", "scriptfiles/"] +COPY --from=tools /dotnet-runtime dotnet-runtime +COPY --from=tools /samp-server . +RUN echo "coreclr dotnet-runtime" >> server.cfg \ + && echo "gamemode bin/CTF.Host.dll" >> server.cfg -COPY scriptfiles scriptfiles -COPY --from=build-env /app/out bin +COPY --from=build /app/out bin \ No newline at end of file From 49f52e71e5ea0665ad0c53bd51a6a5f3e1d91d01 Mon Sep 17 00:00:00 2001 From: MrDave1999 Date: Thu, 24 Oct 2024 07:54:30 -0500 Subject: [PATCH 2/7] Add sample server.cfg --- server.cfg.example | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 server.cfg.example diff --git a/server.cfg.example b/server.cfg.example new file mode 100644 index 00000000..dbecbc66 --- /dev/null +++ b/server.cfg.example @@ -0,0 +1,39 @@ +echo Executing Server Config... +gamemode0 empty +skip_empty_check true +plugins libSampSharp.so streamer.so +filterscripts +rcon_password password +port 7777 +hostname [CTF] Capture The Flag | TDM +maxplayers 30 +language +mapname San Andreas +weburl www.sa-mp.com +gamemodetext Unknown +announce 1 +lanmode 0 +query 1 +rcon 0 +lagcompmode 1 +logqueries 0 +sleep 5 +maxnpc 0 +stream_rate 1000 +stream_distance 200.000000 +onfoot_rate 30 +incar_rate 30 +weapon_rate 30 +chatlogging 1 +timestamp 1 +messageholelimit 3000 +messageslimit 500 +ackslimit 3000 +playertimeout 10000 +minconnectiontime 0 +connseedtime 300000 +db_logging 0 +db_log_queries 0 +conncookies 1 +cookielogging 0 +output 1 \ No newline at end of file From dab15415e01d733ce92f1f5ffd551e09b8a4755c Mon Sep 17 00:00:00 2001 From: MrDave1999 Date: Thu, 24 Oct 2024 07:56:08 -0500 Subject: [PATCH 3/7] Add server.cfg to docker image --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ddfb64a2..8760c335 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,7 +30,7 @@ RUN wget https://gta-multiplayer.cz/downloads/samp037svr_R2-2-1.tar.gz --no-chec && tar -xf samp037svr_R2-2-1.tar.gz \ && rm -f samp037svr_R2-2-1.tar.gz COPY ["samp037svr_R2-2-1/samp03/", "."] -RUN rm -rf filterscripts gamemodes include npcmodes scriptfiles +RUN rm -rf filterscripts gamemodes include npcmodes scriptfiles server.cfg WORKDIR /dotnet-runtime RUN wget https://github.com/Servarr/dotnet-linux-x86/releases/download/v8.0.4-90/dotnet-runtime-8.0.4-linux-x86.tar.gz --no-check-certificate \ @@ -57,6 +57,7 @@ COPY ["gamemodes/*.amx", "gamemodes/"] COPY ["filterscripts/*.amx", "filterscripts/"] COPY ["plugins/*.so", "plugins/"] COPY ["scriptfiles", "scriptfiles/"] +COPY ["server.cfg.example", "server.cfg"] COPY --from=tools /dotnet-runtime dotnet-runtime COPY --from=tools /samp-server . RUN echo "coreclr dotnet-runtime" >> server.cfg \ From 6b547594d74a9f97697eb3e6192791d5788f0362 Mon Sep 17 00:00:00 2001 From: MrDave1999 Date: Thu, 24 Oct 2024 10:24:46 -0500 Subject: [PATCH 4/7] Update Dockerfile --- Dockerfile | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8760c335..b16b63eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,21 +3,22 @@ # FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build WORKDIR /app -COPY *.sln . COPY *.props . # Copy csproj and restore as distinct layers COPY ["src/Host/*.csproj", "src/Host/"] +COPY ["src/Host/*.targets", "src/Host/"] COPY ["src/Application/*.csproj", "src/Application/"] COPY ["src/Persistence/Persistence.InMemory/*.csproj", "src/Persistence/Persistence.InMemory/"] COPY ["src/Persistence/Persistence.MariaDB/*.csproj", "src/Persistence/Persistence.MariaDB/"] COPY ["src/Persistence/Persistence.SQLite/*.csproj", "src/Persistence/Persistence.SQLite/"] COPY ["src/Persistence/*.props", "src/Persistence/"] +WORKDIR /app/src/Host RUN dotnet restore # Copy everything else and build -COPY ["src/", "."] -RUN dotnet publish -c Release -o out --no-restore +COPY ["src/", "/app/src/"] +RUN dotnet publish -c Release -o /app/out --no-restore # # Download SA-MP server and dotnet linux-x86 @@ -25,18 +26,17 @@ RUN dotnet publish -c Release -o out --no-restore FROM ubuntu:20.04 AS tools RUN apt-get update && apt-get install -y --no-install-recommends wget -WORKDIR /samp-server +WORKDIR /sampserver RUN wget https://gta-multiplayer.cz/downloads/samp037svr_R2-2-1.tar.gz --no-check-certificate \ && tar -xf samp037svr_R2-2-1.tar.gz \ && rm -f samp037svr_R2-2-1.tar.gz -COPY ["samp037svr_R2-2-1/samp03/", "."] +WORKDIR /sampserver/samp03 RUN rm -rf filterscripts gamemodes include npcmodes scriptfiles server.cfg -WORKDIR /dotnet-runtime +WORKDIR /runtime RUN wget https://github.com/Servarr/dotnet-linux-x86/releases/download/v8.0.4-90/dotnet-runtime-8.0.4-linux-x86.tar.gz --no-check-certificate \ && tar -xf dotnet-runtime-8.0.4-linux-x86.tar.gz \ && rm -f dotnet-runtime-8.0.4-linux-x86.tar.gz -COPY ["dotnet-runtime-8.0.4-linux-x86/shared/Microsoft.NETCore.App/8.0.4/", "."] # # Final stage/image @@ -58,9 +58,8 @@ COPY ["filterscripts/*.amx", "filterscripts/"] COPY ["plugins/*.so", "plugins/"] COPY ["scriptfiles", "scriptfiles/"] COPY ["server.cfg.example", "server.cfg"] -COPY --from=tools /dotnet-runtime dotnet-runtime -COPY --from=tools /samp-server . -RUN echo "coreclr dotnet-runtime" >> server.cfg \ +COPY --from=tools /runtime/shared/Microsoft.NETCore.App/8.0.4 runtime +COPY --from=tools /sampserver/samp03 . +RUN echo "coreclr runtime" >> server.cfg \ && echo "gamemode bin/CTF.Host.dll" >> server.cfg - COPY --from=build /app/out bin \ No newline at end of file From 1f1841b0f79de8676711fbe2f068dd9210498d85 Mon Sep 17 00:00:00 2001 From: MrDave1999 Date: Thu, 24 Oct 2024 10:27:52 -0500 Subject: [PATCH 5/7] Update .dockerignore --- .dockerignore | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.dockerignore b/.dockerignore index 2aad2bfd..cf79dcb7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,14 +1,12 @@ **/bin **/obj **/dependencies -filterscripts/*.amx dotnet/runtime/ .vscode/ -plugins/ .git/ -*.exe -*.dll -*.so +announce.exe +samp-server.exe +samp-npc.exe announce samp03svr samp-npc From 81caa5d5cd9b05f68057943d409fd9efb5498d74 Mon Sep 17 00:00:00 2001 From: MrDave1999 Date: Thu, 24 Oct 2024 10:54:18 -0500 Subject: [PATCH 6/7] Add new line at the beginning --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b16b63eb..3b75ad9e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -60,6 +60,7 @@ COPY ["scriptfiles", "scriptfiles/"] COPY ["server.cfg.example", "server.cfg"] COPY --from=tools /runtime/shared/Microsoft.NETCore.App/8.0.4 runtime COPY --from=tools /sampserver/samp03 . -RUN echo "coreclr runtime" >> server.cfg \ +RUN echo "" >> server.cfg \ + && echo "coreclr runtime" >> server.cfg \ && echo "gamemode bin/CTF.Host.dll" >> server.cfg COPY --from=build /app/out bin \ No newline at end of file From 961ea62ece730e0c48a4edc3dfca873be76e7156 Mon Sep 17 00:00:00 2001 From: MrDave1999 Date: Sat, 26 Oct 2024 11:39:53 -0500 Subject: [PATCH 7/7] Set runtime version with env vars --- Dockerfile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3b75ad9e..9fdb91a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,9 +34,13 @@ WORKDIR /sampserver/samp03 RUN rm -rf filterscripts gamemodes include npcmodes scriptfiles server.cfg WORKDIR /runtime -RUN wget https://github.com/Servarr/dotnet-linux-x86/releases/download/v8.0.4-90/dotnet-runtime-8.0.4-linux-x86.tar.gz --no-check-certificate \ - && tar -xf dotnet-runtime-8.0.4-linux-x86.tar.gz \ - && rm -f dotnet-runtime-8.0.4-linux-x86.tar.gz +ENV VERSION="8.0.4" +RUN wget https://github.com/Servarr/dotnet-linux-x86/releases/download/v${VERSION}-90/dotnet-runtime-${VERSION}-linux-x86.tar.gz --no-check-certificate \ + && mkdir runtime \ + && tar -xf dotnet-runtime-${VERSION}-linux-x86.tar.gz -C runtime \ + && rm -f dotnet-runtime-${VERSION}-linux-x86.tar.gz \ + && cp -rf runtime/shared/Microsoft.NETCore.App/${VERSION}/** . \ + && rm -rf runtime # # Final stage/image @@ -58,7 +62,7 @@ COPY ["filterscripts/*.amx", "filterscripts/"] COPY ["plugins/*.so", "plugins/"] COPY ["scriptfiles", "scriptfiles/"] COPY ["server.cfg.example", "server.cfg"] -COPY --from=tools /runtime/shared/Microsoft.NETCore.App/8.0.4 runtime +COPY --from=tools /runtime runtime COPY --from=tools /sampserver/samp03 . RUN echo "" >> server.cfg \ && echo "coreclr runtime" >> server.cfg \