Skip to content

Commit

Permalink
Merge pull request #187 from MrDave1999/build/Dockerfile
Browse files Browse the repository at this point in the history
build: Update Dockerfile
  • Loading branch information
MrDave1999 authored Oct 26, 2024
2 parents 21b762b + 961ea62 commit 695cf90
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 53 deletions.
8 changes: 3 additions & 5 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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
Expand Down
90 changes: 42 additions & 48 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,54 +1,49 @@
#
# 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 *.props .

# Copy csproj and restore as distinct layers
COPY src/*.csproj .
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
COPY ["src/", "/app/src/"]
RUN dotnet publish -c Release -o /app/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 /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
WORKDIR /sampserver/samp03
RUN rm -rf filterscripts gamemodes include npcmodes scriptfiles server.cfg

WORKDIR /sampserver/filterscripts
# Delete all directories except .amx files
RUN rm -rf */
WORKDIR /runtime
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

#
# 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
Expand All @@ -60,17 +55,16 @@ 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 scriptfiles scriptfiles
COPY --from=build-env /app/out bin
COPY ["gamemodes/*.amx", "gamemodes/"]
COPY ["filterscripts/*.amx", "filterscripts/"]
COPY ["plugins/*.so", "plugins/"]
COPY ["scriptfiles", "scriptfiles/"]
COPY ["server.cfg.example", "server.cfg"]
COPY --from=tools /runtime runtime
COPY --from=tools /sampserver/samp03 .
RUN echo "" >> server.cfg \
&& echo "coreclr runtime" >> server.cfg \
&& echo "gamemode bin/CTF.Host.dll" >> server.cfg
COPY --from=build /app/out bin
39 changes: 39 additions & 0 deletions server.cfg.example
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 695cf90

Please sign in to comment.