forked from wylab/WS14-Docker-Linux-Server
Refactor to LiamAEdwards watchdog approach
- Dockerfile: Download server from wylab CDN at build time, build watchdog - start.sh: Simplified to copy defaults and run watchdog - appsettings.yml: Configure for wylab instance with CDN manifest - main.yml: Simplified workflow with auto-tagging via metadata-action - Delete update_build_metadata.py (no longer needed) Based on: https://github.com/LiamAEdwards/SS14-Docker-Linux-Server 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+24
-15
@@ -1,7 +1,6 @@
|
|||||||
#
|
#
|
||||||
name: Build SS14 Watchdog Server
|
name: Build SS14 Watchdog Server
|
||||||
|
|
||||||
# Build on main branch (watchdog) - simpler build, no game source compilation
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: ['main']
|
branches: ['main']
|
||||||
@@ -21,7 +20,7 @@ jobs:
|
|||||||
packages: write
|
packages: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -33,17 +32,24 @@ jobs:
|
|||||||
username: ${{ secrets.REGISTRY_USERNAME || github.actor }}
|
username: ${{ secrets.REGISTRY_USERNAME || github.actor }}
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
flavor: |
|
||||||
|
suffix=-arm64
|
||||||
|
|
||||||
- name: Build and push Docker image (arm64)
|
- name: Build and push Docker image (arm64)
|
||||||
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
|
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/arm64
|
platforms: linux/arm64
|
||||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-watchdog-arm64
|
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-arm64
|
||||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-watchdog-arm64,mode=max
|
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-arm64,mode=max
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:arm64
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-arm64
|
|
||||||
|
|
||||||
build-amd64:
|
build-amd64:
|
||||||
runs-on: [self-hosted, linux-amd64]
|
runs-on: [self-hosted, linux-amd64]
|
||||||
@@ -53,7 +59,7 @@ jobs:
|
|||||||
packages: write
|
packages: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -65,16 +71,19 @@ jobs:
|
|||||||
username: ${{ secrets.REGISTRY_USERNAME || github.actor }}
|
username: ${{ secrets.REGISTRY_USERNAME || github.actor }}
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.REGISTRY_PASSWORD || secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
|
||||||
- name: Build and push Docker image (amd64)
|
- name: Build and push Docker image (amd64)
|
||||||
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
|
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-watchdog-amd64
|
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-amd64
|
||||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-watchdog-amd64,mode=max
|
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-amd64,mode=max
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:amd64
|
|
||||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-amd64
|
|
||||||
|
|||||||
+48
-45
@@ -1,62 +1,65 @@
|
|||||||
#
|
|
||||||
# SS14 Watchdog Docker Image
|
|
||||||
# Auto-updates game server from CDN manifest
|
|
||||||
#
|
|
||||||
# syntax=docker/dockerfile:1.7
|
# syntax=docker/dockerfile:1.7
|
||||||
|
#
|
||||||
|
# SS14 Watchdog Docker Image (based on LiamAEdwards/SS14-Docker-Linux-Server)
|
||||||
|
# Downloads game server from CDN and builds SS14.Watchdog
|
||||||
|
#
|
||||||
|
|
||||||
# Build stage - compile the watchdog
|
# Build stage
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
|
|
||||||
RUN apt-get update && \
|
# Update and install necessary tools
|
||||||
apt-get install -y --no-install-recommends git && \
|
RUN apt-get -y update && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
apt-get -y install curl unzip wget git jq
|
||||||
|
|
||||||
WORKDIR /src
|
# Determine platform RID based on Docker TARGETPLATFORM
|
||||||
|
RUN if [ "${TARGETPLATFORM:-linux/amd64}" = "linux/arm64" ]; then \
|
||||||
# Clone and build SS14.Watchdog
|
echo "linux-arm64" > /tmp/platform_rid; \
|
||||||
RUN git clone --recursive https://github.com/space-wizards/SS14.Watchdog.git watchdog
|
|
||||||
|
|
||||||
WORKDIR /src/watchdog
|
|
||||||
|
|
||||||
# Build for the target platform
|
|
||||||
RUN --mount=type=cache,target=/root/.nuget/packages \
|
|
||||||
if [ "${TARGETPLATFORM:-linux/amd64}" = "linux/arm64" ]; then \
|
|
||||||
RUNTIME="linux-arm64"; \
|
|
||||||
else \
|
else \
|
||||||
RUNTIME="linux-x64"; \
|
echo "linux-x64" > /tmp/platform_rid; \
|
||||||
fi && \
|
fi && \
|
||||||
dotnet publish SS14.Watchdog -c Release -r "$RUNTIME" --no-self-contained -o /app
|
echo "Building for platform: $(cat /tmp/platform_rid)"
|
||||||
|
|
||||||
# Runtime stage
|
# Download and extract SS14 server from WYLAB CDN
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:9.0
|
RUN PLATFORM_RID=$(cat /tmp/platform_rid) && \
|
||||||
|
SERVER_URL=$(curl -sL https://cdn.wylab.me/fork/wylab/manifest | \
|
||||||
|
jq -r ".builds | to_entries | sort_by(.value.time) | last | .value.server.\"${PLATFORM_RID}\".url") && \
|
||||||
|
echo "Downloading server from: $SERVER_URL" && \
|
||||||
|
wget -O SS14.Server.zip "$SERVER_URL" && \
|
||||||
|
unzip SS14.Server.zip -d /ss14-default/
|
||||||
|
|
||||||
RUN apt-get update && \
|
# Download and build Watchdog
|
||||||
apt-get install -y --no-install-recommends ca-certificates && \
|
RUN PLATFORM_RID=$(cat /tmp/platform_rid) && \
|
||||||
|
wget https://github.com/space-wizards/SS14.Watchdog/archive/refs/heads/master.zip -O Watchdog.zip && \
|
||||||
|
unzip Watchdog.zip -d Watchdog && \
|
||||||
|
cd Watchdog/SS14.Watchdog-master && \
|
||||||
|
dotnet publish SS14.Watchdog -c Release -r "${PLATFORM_RID}" --no-self-contained -o /ss14-default/publish
|
||||||
|
|
||||||
|
# Server stage
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS server
|
||||||
|
|
||||||
|
# Copy from the build stage
|
||||||
|
COPY --from=build /ss14-default /ss14-default
|
||||||
|
|
||||||
|
# Install necessary tools
|
||||||
|
RUN apt-get -y update && apt-get -y install unzip && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Copy watchdog from build stage
|
# Expose necessary ports
|
||||||
COPY --from=build /app /app
|
|
||||||
|
|
||||||
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/tcp
|
||||||
EXPOSE 1212/udp
|
EXPOSE 1212/udp
|
||||||
|
EXPOSE 8080/tcp
|
||||||
|
|
||||||
# Volume for persistent data (game saves, database, etc.)
|
# Set volume
|
||||||
VOLUME ["/app/instances"]
|
VOLUME [ "/ss14" ]
|
||||||
|
|
||||||
# Run the watchdog
|
# Add configurations
|
||||||
ENTRYPOINT ["./SS14.Watchdog"]
|
COPY appsettings.yml /ss14-default/publish/appsettings.yml
|
||||||
|
COPY server_config.toml /ss14-default/publish/server_config.toml
|
||||||
|
|
||||||
|
COPY start.sh /start.sh
|
||||||
|
RUN chmod +x /start.sh
|
||||||
|
|
||||||
|
# Set the entry point for the container
|
||||||
|
ENTRYPOINT ["/start.sh"]
|
||||||
|
|||||||
+1
-5
@@ -25,14 +25,10 @@ Serilog:
|
|||||||
AllowedHosts: "*"
|
AllowedHosts: "*"
|
||||||
|
|
||||||
# Force Kestrel to bind to 0.0.0.0 (IPv4) instead of [::] (IPv6)
|
# Force Kestrel to bind to 0.0.0.0 (IPv4) instead of [::] (IPv6)
|
||||||
# This fixes the Host header issue with http://[::]:8080
|
|
||||||
Urls: "http://0.0.0.0:8080"
|
Urls: "http://0.0.0.0:8080"
|
||||||
|
|
||||||
# API URL your watchdog is accessible from.
|
# API URL your watchdog is accessible from.
|
||||||
# This NEEDS to be reachable by the game server.
|
# This NEEDS to be reachable by the game server.
|
||||||
# If you don't want the watchdog to be public,
|
|
||||||
# do `http://localhost:8080/` here.
|
|
||||||
#BaseUrl: https://your.domain.com/watchdog/
|
|
||||||
BaseUrl: http://localhost:8080/
|
BaseUrl: http://localhost:8080/
|
||||||
|
|
||||||
Servers:
|
Servers:
|
||||||
@@ -43,7 +39,7 @@ Servers:
|
|||||||
ApiPort: 1212
|
ApiPort: 1212
|
||||||
TimeoutSeconds: 120
|
TimeoutSeconds: 120
|
||||||
|
|
||||||
# Override the baseUrl to use localhost instead of [::]
|
# Override the baseUrl to use localhost
|
||||||
EnvironmentVariables:
|
EnvironmentVariables:
|
||||||
ROBUST_CVAR_watchdog__baseUrl: "http://localhost:8080/"
|
ROBUST_CVAR_watchdog__baseUrl: "http://localhost:8080/"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user