|
1 | 1 | # SPDX-License-Identifier: PMPL-1.0-or-later |
2 | 2 | # game-server-admin Container Image |
3 | 3 | # |
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. |
7 | 6 | # |
8 | 7 | # Build with Podman: |
9 | 8 | # podman build -t gsa:latest -f container/Containerfile . |
10 | 9 | # |
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 |
13 | 12 | # |
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 |
16 | 15 |
|
17 | 16 | # ============================================================================ |
18 | | -# Stage 1: Builder |
| 17 | +# Stage 1: Zig Builder |
19 | 18 | # ============================================================================ |
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 | + |
51 | 20 | FROM cgr.dev/chainguard/wolfi-base:latest AS builder |
52 | 21 |
|
53 | | -# TODO: Install your language toolchain |
54 | | -RUN apk add --no-cache build-base |
| 22 | +RUN apk add --no-cache zig build-base curl |
55 | 23 |
|
56 | 24 | WORKDIR /build |
57 | 25 |
|
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 |
61 | 32 |
|
62 | 33 | # ============================================================================ |
63 | 34 | # Stage 2: Runtime |
64 | 35 | # ============================================================================ |
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 | + |
69 | 37 | FROM cgr.dev/chainguard/wolfi-base:latest |
70 | 38 |
|
71 | | -# OCI image labels (compatible with cerro-torre .ctp bundle metadata) |
| 39 | +# OCI image labels |
72 | 40 | LABEL org.opencontainers.image.title="game-server-admin" \ |
73 | 41 | 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" \ |
76 | 44 | org.opencontainers.image.vendor="hyperpolymath" \ |
77 | 45 | org.opencontainers.image.licenses="PMPL-1.0-or-later" \ |
78 | 46 | org.opencontainers.image.authors="Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>" \ |
79 | 47 | dev.cerrotorre.manifest="container/manifest.toml" \ |
80 | | - dev.cerrotorre.gatekeeper="container/.gatekeeper.yaml" \ |
81 | 48 | dev.stapeln.compose="container/compose.toml" |
82 | 49 |
|
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 |
89 | 51 | RUN apk add --no-cache ca-certificates curl |
90 | 52 |
|
91 | | -# Create non-root user for the application. |
92 | | -# Running as root inside containers is a security anti-pattern. |
| 53 | +# Create non-root user |
93 | 54 | RUN addgroup -S appuser && adduser -S appuser -G appuser |
94 | 55 |
|
95 | 56 | WORKDIR /app |
96 | 57 |
|
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/ |
102 | 64 |
|
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 |
104 | 72 | COPY container/entrypoint.sh /app/entrypoint.sh |
105 | 73 | RUN chmod +x /app/entrypoint.sh |
106 | 74 |
|
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 |
109 | 76 | COPY container/manifest.toml /app/manifest.toml |
110 | 77 |
|
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 |
112 | 82 | RUN mkdir -p /data && chown appuser:appuser /data |
113 | 83 |
|
114 | | -# Set ownership of the application directory |
| 84 | +# Set ownership |
115 | 85 | RUN chown -R appuser:appuser /app |
116 | 86 |
|
117 | | -# Environment variables — customise for your application |
| 87 | +# Environment |
118 | 88 | 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 |
122 | 94 |
|
123 | | -# Declare /data as a volume for persistent storage |
| 95 | +# Volume for persistent data |
124 | 96 | VOLUME ["/data"] |
125 | 97 |
|
126 | 98 | # Run as non-root |
127 | 99 | USER appuser |
128 | 100 |
|
129 | | -# Expose the application port |
130 | | -EXPOSE 8090 |
| 101 | +EXPOSE 8080 |
131 | 102 |
|
132 | | -# Health check — the application must respond 2xx at /health |
| 103 | +# Health check |
133 | 104 | HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ |
134 | 105 | CMD curl -sf http://localhost:${APP_PORT}/health || exit 1 |
135 | 106 |
|
|
0 commit comments