From aaade96257581f4d9224d8addcdfdf8ee821641a Mon Sep 17 00:00:00 2001 From: wylab Date: Tue, 16 Dec 2025 07:41:49 +0100 Subject: [PATCH] refactor: Switch to SS14.Watchdog for auto-updates from CDN - Watchdog automatically downloads and updates game server from CDN manifest - No need to rebuild image for game updates - Game server binaries pulled from https://cdn.wylab.me/fork/wylab/manifest - Dev branch retains the build-from-source approach --- Dockerfile | 89 +++++++++++++++++++++++------------------------------- 1 file changed, 37 insertions(+), 52 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3036ecc..b52d8e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,77 +1,62 @@ # +# SS14 Watchdog Docker Image +# Auto-updates game server from CDN manifest +# # syntax=docker/dockerfile:1.7 -# Build stage +# Build stage - compile the watchdog FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build -ARG SOURCE_REPO=https://git.wylab.me/wylab/wylab-station-14.git -ARG SOURCE_REF=master ARG TARGETPLATFORM -ARG TARGET_PLATFORM=auto -# Install dependencies needed to build and package the server -RUN --mount=type=cache,target=/var/cache/apt \ - --mount=type=cache,target=/var/lib/apt/lists \ - apt-get update && \ - apt-get install -y --no-install-recommends git python3 unzip +RUN apt-get update && \ + apt-get install -y --no-install-recommends git && \ + rm -rf /var/lib/apt/lists/* WORKDIR /src -# Clone the wylab-station-14 source -RUN git clone "${SOURCE_REPO}" content -WORKDIR /src/content -RUN git checkout "${SOURCE_REF}" +# Clone and build SS14.Watchdog +RUN git clone --recursive https://github.com/space-wizards/SS14.Watchdog.git watchdog -# Initialize submodules / engine checkout -RUN python3 RUN_THIS.py --quiet +WORKDIR /src/watchdog -# Build and package the server for the requested platform +# Build for the target platform RUN --mount=type=cache,target=/root/.nuget/packages \ - if [ "${TARGET_PLATFORM}" = "auto" ]; then \ - case "${TARGETPLATFORM:-linux/amd64}" in \ - "linux/amd64") SERVER_RID="linux-x64" ;; \ - "linux/arm64") SERVER_RID="linux-arm64" ;; \ - "linux/arm/v7"|"linux/arm/v6") SERVER_RID="linux-arm" ;; \ - *) echo "Unsupported TARGETPLATFORM '${TARGETPLATFORM}'. Set TARGET_PLATFORM explicitly."; exit 1 ;; \ - esac; \ + if [ "${TARGETPLATFORM:-linux/amd64}" = "linux/arm64" ]; then \ + RUNTIME="linux-arm64"; \ else \ - SERVER_RID="${TARGET_PLATFORM}"; \ + RUNTIME="linux-x64"; \ fi && \ - echo "Building server runtime for ${SERVER_RID} (docker TARGETPLATFORM=${TARGETPLATFORM:-unknown})" && \ - dotnet run --project Content.Packaging/Content.Packaging.csproj server \ - --platform "${SERVER_RID}" \ - --configuration Release + dotnet publish SS14.Watchdog -c Release -r "$RUNTIME" --no-self-contained -o /app -# Extract packaged build into the filesystem layout the runtime stage expects -RUN mkdir -p /ss14-default && \ - unzip "release/SS14.Server_${TARGET_PLATFORM}.zip" -d /ss14-default/ - -# Server stage -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS server +# Runtime stage +FROM mcr.microsoft.com/dotnet/aspnet:9.0 RUN apt-get update && \ - apt-get install -y --no-install-recommends ca-certificates python3 && \ + apt-get install -y --no-install-recommends ca-certificates && \ rm -rf /var/lib/apt/lists/* -# Copy from the build stage -COPY --from=build /ss14-default /ss14-default -COPY update_build_metadata.py /update_build_metadata.py +# Copy watchdog from build stage +COPY --from=build /app /app -# Expose necessary ports +WORKDIR /app + +# Create instance directory structure +RUN mkdir -p /app/instances/wylab/data + +# Copy configuration files +COPY appsettings.yml /app/appsettings.yml +COPY server_config.toml /app/instances/wylab/config.toml + +# Expose ports +# 8080 = Watchdog API +# 1212 = Game server (TCP status + UDP game) +EXPOSE 8080/tcp EXPOSE 1212/tcp EXPOSE 1212/udp -EXPOSE 8080/tcp -# Set volume -VOLUME [ "/ss14" ] +# Volume for persistent data (game saves, database, etc.) +VOLUME ["/app/instances"] -# Add configurations (files go to root, not publish/) -ADD appsettings.yml /ss14-default/appsettings.yml -ADD server_config.toml /ss14-default/server_config.toml - -COPY start.sh /start.sh -RUN python3 /update_build_metadata.py /ss14-default/server_config.toml || true && \ - chmod +x /start.sh - -# Set the entry point for the container -ENTRYPOINT ["/start.sh"] +# Run the watchdog +ENTRYPOINT ["./SS14.Watchdog"]