Auto-detect target platform
Some checks failed
Build and publish wylab SS14 server / build-arm64 (push) Successful in 7m22s
Build and publish wylab SS14 server / build-amd64 (push) Has been cancelled

This commit is contained in:
Codex Agent
2025-12-15 00:50:55 +01:00
parent 2a615a644a
commit ea4f55a8dc
2 changed files with 25 additions and 4 deletions

View File

@@ -6,7 +6,8 @@ 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 TARGET_PLATFORM=linux-x64
ARG TARGETPLATFORM
ARG TARGET_PLATFORM=auto
# Install dependencies needed to build and package the server
RUN --mount=type=cache,target=/var/cache/apt \
@@ -26,8 +27,19 @@ RUN python3 RUN_THIS.py --quiet
# Build and package the server for the requested 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; \
else \
SERVER_RID="${TARGET_PLATFORM}"; \
fi && \
echo "Building server runtime for ${SERVER_RID} (docker TARGETPLATFORM=${TARGETPLATFORM:-unknown})" && \
dotnet run --project Content.Packaging/Content.Packaging.csproj server \
--platform "${TARGET_PLATFORM}" \
--platform "${SERVER_RID}" \
--configuration Release
# Extract packaged build into the filesystem layout the runtime stage expects

View File

@@ -34,13 +34,22 @@ This project is for those who prefer containerized solutions. It's based on the
docker build \
--build-arg SOURCE_REPO=https://git.wylab.me/wylab/wylab-station-14.git \
--build-arg SOURCE_REF=master \
--build-arg TARGET_PLATFORM=linux-x64 \
--build-arg TARGET_PLATFORM=auto \
-t git.wylab.me/wylab/WS14-Docker-Linux-Server:local .
```
- `SOURCE_REPO` Git URL of the content repo to compile (defaults to the wylab fork).
- `SOURCE_REF` Branch, tag, or commit to check out (defaults to `master`).
- `TARGET_PLATFORM` Runtime identifier passed to the packaging tool (defaults to `linux-x64`).
- `TARGET_PLATFORM` Runtime identifier passed to the packaging tool. Use `auto` (default) to match the Docker target platform automatically, or override with `linux-x64`, `linux-arm64`, or `linux-arm` to force an architecture.
If you are building on one architecture and running on another (for example, building on x86 and deploying to an ARM board), build with an explicit platform to avoid `exec format error`:
```bash
docker buildx build \
--platform linux/arm64 \
--build-arg TARGET_PLATFORM=linux-arm64 \
-t git.wylab.me/wylab/WS14-Docker-Linux-Server:arm64 .
```
The build container clones the selected ref, runs `RUN_THIS.py --quiet` to fetch submodules, and executes `dotnet run --project Content.Packaging server` to generate a release zip that is baked into the final layer.