Compare commits

..

1 commit

Author SHA1 Message Date
Pat Hartl
25e99ccfc8 Dockerfile with nightly workflow and sample compose file 2026-04-08 17:03:51 -05:00
4 changed files with 130 additions and 0 deletions

23
.dockerignore Normal file
View file

@ -0,0 +1,23 @@
.git
.github
docs
proto
build
*.md
CREDITS
LICENSE
# Build outputs
src/**/bin/
src/**/obj/
# Test projects — not needed for the server image
src/MHServerEmu.Core.Tests/
src/MHServerEmu.Games.Tests/
# Tools — separate solution, not part of the server
src/Tools/
# Debug symbols and XML docs
**/*.pdb
**/*.xml

47
.github/workflows/nightly-docker.yml vendored Normal file
View file

@ -0,0 +1,47 @@
name: Nightly Docker Image
on:
schedule:
- cron: '15 7 * * *'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=schedule,pattern=nightly-{{date 'YYYYMMDD'}}
type=raw,value=nightly
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

45
Dockerfile Normal file
View file

@ -0,0 +1,45 @@
# Build stage
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /source
# Copy dep DLLs and project files first to cache the restore layer
COPY dep/ dep/
COPY src/Gazillion/Gazillion.csproj src/Gazillion/
COPY src/MHServerEmu/MHServerEmu.csproj src/MHServerEmu/
COPY src/MHServerEmu.Core/MHServerEmu.Core.csproj src/MHServerEmu.Core/
COPY src/MHServerEmu.DatabaseAccess/MHServerEmu.DatabaseAccess.csproj src/MHServerEmu.DatabaseAccess/
COPY src/MHServerEmu.Frontend/MHServerEmu.Frontend.csproj src/MHServerEmu.Frontend/
COPY src/MHServerEmu.Games/MHServerEmu.Games.csproj src/MHServerEmu.Games/
COPY src/MHServerEmu.Grouping/MHServerEmu.Grouping.csproj src/MHServerEmu.Grouping/
COPY src/MHServerEmu.Leaderboards/MHServerEmu.Leaderboards.csproj src/MHServerEmu.Leaderboards/
COPY src/MHServerEmu.PlayerManagement/MHServerEmu.PlayerManagement.csproj src/MHServerEmu.PlayerManagement/
COPY src/MHServerEmu.WebFrontend/MHServerEmu.WebFrontend.csproj src/MHServerEmu.WebFrontend/
RUN dotnet restore src/MHServerEmu/MHServerEmu.csproj --runtime linux-x64
# Copy source and publish as self-contained linux-x64
COPY src/ src/
RUN dotnet publish src/MHServerEmu/MHServerEmu.csproj \
--no-restore \
--configuration Release \
--runtime linux-x64 \
--self-contained true \
--output /build/publish
# Runtime stage — runtime-deps is sufficient for self-contained binaries
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0
WORKDIR /build
COPY --from=build /build/publish /server
# Data directory holds the SQLite database, Config.ini overrides, and game assets.
# Mount a host directory here to persist player data across container restarts.
VOLUME ["/server"]
# 4306 — game client frontend
# 8080 — web frontend / dashboard
EXPOSE 4306
EXPOSE 8080
ENTRYPOINT ["./MHServerEmu"]

15
docker-compose.yml Normal file
View file

@ -0,0 +1,15 @@
services:
mhservereemu:
image: ghcr.io/crypto137/mhservereemu:nightly
container_name: mhservereemu
restart: unless-stopped
ports:
- "4306:4306" # Game client frontend
- "8080:8080" # Web frontend / dashboard
volumes:
# Persists the SQLite database, backups, and any other runtime data.
# Place your game asset files (CalligraphyData.sip, etc.) here before first run.
- mhservereemu-data:/server
volumes:
mhservereemu-data: