forked from LiamAEdwards/SS14-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:
39
.github/workflows/main.yml
vendored
39
.github/workflows/main.yml
vendored
@@ -1,7 +1,6 @@
|
||||
#
|
||||
name: Build SS14 Watchdog Server
|
||||
|
||||
# Build on main branch (watchdog) - simpler build, no game source compilation
|
||||
on:
|
||||
push:
|
||||
branches: ['main']
|
||||
@@ -21,7 +20,7 @@ jobs:
|
||||
packages: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
@@ -33,17 +32,24 @@ jobs:
|
||||
username: ${{ secrets.REGISTRY_USERNAME || github.actor }}
|
||||
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)
|
||||
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/arm64
|
||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-watchdog-arm64
|
||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-watchdog-arm64,mode=max
|
||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-arm64
|
||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-arm64,mode=max
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:arm64
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-arm64
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
build-amd64:
|
||||
runs-on: [self-hosted, linux-amd64]
|
||||
@@ -53,7 +59,7 @@ jobs:
|
||||
packages: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
@@ -65,16 +71,19 @@ jobs:
|
||||
username: ${{ secrets.REGISTRY_USERNAME || github.actor }}
|
||||
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)
|
||||
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64
|
||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-watchdog-amd64
|
||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-watchdog-amd64,mode=max
|
||||
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-amd64
|
||||
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-amd64,mode=max
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:amd64
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-amd64
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
93
Dockerfile
93
Dockerfile
@@ -1,62 +1,65 @@
|
||||
#
|
||||
# SS14 Watchdog Docker Image
|
||||
# Auto-updates game server from CDN manifest
|
||||
#
|
||||
# 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
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends git && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
# Update and install necessary tools
|
||||
RUN apt-get -y update && \
|
||||
apt-get -y install curl unzip wget git jq
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
# Clone and build SS14.Watchdog
|
||||
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"; \
|
||||
# Determine platform RID based on Docker TARGETPLATFORM
|
||||
RUN if [ "${TARGETPLATFORM:-linux/amd64}" = "linux/arm64" ]; then \
|
||||
echo "linux-arm64" > /tmp/platform_rid; \
|
||||
else \
|
||||
RUNTIME="linux-x64"; \
|
||||
echo "linux-x64" > /tmp/platform_rid; \
|
||||
fi && \
|
||||
dotnet publish SS14.Watchdog -c Release -r "$RUNTIME" --no-self-contained -o /app
|
||||
echo "Building for platform: $(cat /tmp/platform_rid)"
|
||||
|
||||
# Runtime stage
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:9.0
|
||||
# Download and extract SS14 server from WYLAB CDN
|
||||
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 && \
|
||||
apt-get install -y --no-install-recommends ca-certificates && \
|
||||
# Download and build Watchdog
|
||||
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/*
|
||||
|
||||
# Copy watchdog from build stage
|
||||
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 necessary ports
|
||||
EXPOSE 1212/tcp
|
||||
EXPOSE 1212/udp
|
||||
EXPOSE 8080/tcp
|
||||
|
||||
# Volume for persistent data (game saves, database, etc.)
|
||||
VOLUME ["/app/instances"]
|
||||
# Set volume
|
||||
VOLUME [ "/ss14" ]
|
||||
|
||||
# Run the watchdog
|
||||
ENTRYPOINT ["./SS14.Watchdog"]
|
||||
# Add configurations
|
||||
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"]
|
||||
|
||||
@@ -25,14 +25,10 @@ Serilog:
|
||||
AllowedHosts: "*"
|
||||
|
||||
# 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"
|
||||
|
||||
# API URL your watchdog is accessible from.
|
||||
# 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/
|
||||
|
||||
Servers:
|
||||
@@ -43,7 +39,7 @@ Servers:
|
||||
ApiPort: 1212
|
||||
TimeoutSeconds: 120
|
||||
|
||||
# Override the baseUrl to use localhost instead of [::]
|
||||
# Override the baseUrl to use localhost
|
||||
EnvironmentVariables:
|
||||
ROBUST_CVAR_watchdog__baseUrl: "http://localhost:8080/"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user