Skip to content

Commit d4784ac

Browse files
hyperpolymathclaude
andcommitted
feat: wire Zig build into GSA app Containerfile
Replace template TODO stubs with actual Zig FFI build: - Stage 1: Chainguard Wolfi + Zig, builds libgsa.so in ReleaseFast - Stage 2: Copies libgsa.so, game profiles, GUI panels, Ephapax core - LD_LIBRARY_PATH set for libgsa.so - Env vars for both VeriSimDB instances (8090 main, 8091 backup) - Icon asset included Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 33d14d9 commit d4784ac

1 file changed

Lines changed: 49 additions & 78 deletions

File tree

container/Containerfile

Lines changed: 49 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,106 @@
11
# SPDX-License-Identifier: PMPL-1.0-or-later
22
# game-server-admin Container Image
33
#
4-
# Multi-stage build template for Chainguard Wolfi base images.
5-
# Customise the builder stage for your language and copy the
6-
# resulting binary/release into the minimal runtime stage.
4+
# Builds libgsa.so (Zig FFI) and packages it with game profiles,
5+
# GUI panels, and the Gossamer entry point.
76
#
87
# Build with Podman:
98
# podman build -t gsa:latest -f container/Containerfile .
109
#
11-
# Run:
12-
# podman run -p 8090:8090 gsa:latest
10+
# Run (requires gsa-verisimdb on port 8090):
11+
# podman run -p 8080:8080 --network=host gsa:latest
1312
#
14-
# Run with persistent volume:
15-
# podman run -p 8090:8090 -v gsa-data:/data gsa:latest
13+
# Run with custom VeriSimDB URL:
14+
# podman run -e GSA_VERISIMDB_URL=http://[::1]:8090 gsa:latest
1615

1716
# ============================================================================
18-
# Stage 1: Builder
17+
# Stage 1: Zig Builder
1918
# ============================================================================
20-
#
21-
# Install build tools and compile the application.
22-
# This stage is discarded after the build — only the compiled output
23-
# is copied into the runtime stage.
24-
#
25-
# Language-specific examples (uncomment the one you need):
26-
#
27-
# --- Rust ---
28-
# RUN apk add --no-cache rust pkgconf build-base
29-
# COPY Cargo.toml Cargo.lock ./
30-
# COPY src/ ./src/
31-
# RUN cargo build --release
32-
# # Output: /build/target/release/gsa
33-
#
34-
# --- Elixir ---
35-
# RUN apk add --no-cache erl27-elixir-1.18 erlang-27 erlang-27-dev git build-base
36-
# COPY mix.exs mix.lock ./
37-
# COPY lib/ ./lib/
38-
# COPY config/ ./config/
39-
# ENV MIX_ENV=prod
40-
# RUN mix local.hex --force && mix local.rebar --force && \
41-
# mix deps.get --only prod && mix compile && mix release
42-
# # Output: /build/_build/prod/rel/gsa/
43-
#
44-
# --- Zig ---
45-
# RUN apk add --no-cache zig build-base
46-
# COPY build.zig build.zig.zon ./
47-
# COPY src/ ./src/
48-
# RUN zig build -Doptimize=ReleaseFast
49-
# # Output: /build/zig-out/bin/gsa
50-
#
19+
5120
FROM cgr.dev/chainguard/wolfi-base:latest AS builder
5221

53-
# TODO: Install your language toolchain
54-
RUN apk add --no-cache build-base
22+
RUN apk add --no-cache zig build-base curl
5523

5624
WORKDIR /build
5725

58-
# TODO: Copy source files and build
59-
COPY . .
60-
# RUN <your-build-command>
26+
# Copy Zig FFI source
27+
COPY src/interface/ffi/build.zig src/interface/ffi/build.zig
28+
COPY src/interface/ffi/src/ src/interface/ffi/src/
29+
30+
# Build libgsa shared library (release optimised)
31+
RUN cd src/interface/ffi && zig build -Doptimize=ReleaseFast
6132

6233
# ============================================================================
6334
# Stage 2: Runtime
6435
# ============================================================================
65-
#
66-
# Minimal production image. Only the compiled binary/release and runtime
67-
# dependencies are included. No compilers, no source code, no build tools.
68-
#
36+
6937
FROM cgr.dev/chainguard/wolfi-base:latest
7038

71-
# OCI image labels (compatible with cerro-torre .ctp bundle metadata)
39+
# OCI image labels
7240
LABEL org.opencontainers.image.title="game-server-admin" \
7341
org.opencontainers.image.description="Universal game server probe, config management, and administration via Gossamer + VeriSimDB" \
74-
org.opencontainers.image.url="https://github/hyperpolymath/game-server-admin" \
75-
org.opencontainers.image.source="https://github/hyperpolymath/game-server-admin" \
42+
org.opencontainers.image.url="https://github.com/hyperpolymath/game-server-admin" \
43+
org.opencontainers.image.source="https://github.com/hyperpolymath/game-server-admin" \
7644
org.opencontainers.image.vendor="hyperpolymath" \
7745
org.opencontainers.image.licenses="PMPL-1.0-or-later" \
7846
org.opencontainers.image.authors="Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>" \
7947
dev.cerrotorre.manifest="container/manifest.toml" \
80-
dev.cerrotorre.gatekeeper="container/.gatekeeper.yaml" \
8148
dev.stapeln.compose="container/compose.toml"
8249

83-
# Install minimal runtime dependencies.
84-
# Adjust this list for your application:
85-
# - ca-certificates: TLS root certificates
86-
# - curl: health check probe
87-
# - libstdc++: C++ standard library (if needed by native deps)
88-
# - ncurses: terminal UI (if needed, e.g. Elixir IEx)
50+
# Minimal runtime dependencies
8951
RUN apk add --no-cache ca-certificates curl
9052

91-
# Create non-root user for the application.
92-
# Running as root inside containers is a security anti-pattern.
53+
# Create non-root user
9354
RUN addgroup -S appuser && adduser -S appuser -G appuser
9455

9556
WORKDIR /app
9657

97-
# TODO: Copy compiled binary/release from builder stage.
98-
# Examples:
99-
# COPY --from=builder /build/target/release/gsa /app/gsa
100-
# COPY --from=builder /build/_build/prod/rel/gsa /app/release/
101-
# COPY --from=builder /build/zig-out/bin/gsa /app/gsa
58+
# Copy libgsa from builder
59+
COPY --from=builder /build/src/interface/ffi/zig-out/lib/libgsa.so /app/lib/libgsa.so
60+
COPY --from=builder /build/src/interface/ffi/zig-out/lib/libgsa.a /app/lib/libgsa.a
61+
62+
# Copy game profiles
63+
COPY profiles/ /app/profiles/
10264

103-
# Copy entrypoint script
65+
# Copy GUI panels and host HTML
66+
COPY src/gui/ /app/gui/
67+
68+
# Copy Ephapax core (for Gossamer integration)
69+
COPY src/core/ /app/core/
70+
71+
# Copy entrypoint
10472
COPY container/entrypoint.sh /app/entrypoint.sh
10573
RUN chmod +x /app/entrypoint.sh
10674

107-
# Copy stapeln integration files (svalinn gatekeeper policy, cerro-torre manifest)
108-
COPY container/.gatekeeper.yaml /etc/svalinn/gatekeeper.yaml
75+
# Copy stapeln integration files
10976
COPY container/manifest.toml /app/manifest.toml
11077

111-
# Create data directory for persistent storage (mountable volume)
78+
# Copy icon
79+
COPY assets/icon-256.png /app/icon.png
80+
81+
# Create data directory
11282
RUN mkdir -p /data && chown appuser:appuser /data
11383

114-
# Set ownership of the application directory
84+
# Set ownership
11585
RUN chown -R appuser:appuser /app
11686

117-
# Environment variables — customise for your application
87+
# Environment
11888
ENV APP_HOST=[::]
119-
ENV APP_PORT=8090
120-
ENV APP_LOG_FORMAT=json
121-
ENV APP_DATA_DIR=/data
89+
ENV APP_PORT=8080
90+
ENV GSA_VERISIMDB_URL=http://[::1]:8090
91+
ENV GSA_BACKUP_VERISIMDB_URL=http://[::1]:8091
92+
ENV GSA_PROFILES_DIR=/app/profiles
93+
ENV LD_LIBRARY_PATH=/app/lib
12294

123-
# Declare /data as a volume for persistent storage
95+
# Volume for persistent data
12496
VOLUME ["/data"]
12597

12698
# Run as non-root
12799
USER appuser
128100

129-
# Expose the application port
130-
EXPOSE 8090
101+
EXPOSE 8080
131102

132-
# Health check — the application must respond 2xx at /health
103+
# Health check
133104
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
134105
CMD curl -sf http://localhost:${APP_PORT}/health || exit 1
135106

0 commit comments

Comments
 (0)