|
16 | 16 | # Stage 1: Zig FFI Builder |
17 | 17 | # ============================================================================ |
18 | 18 |
|
| 19 | +# Cartridge source is fetched on demand from the canonical registry rather than |
| 20 | +# bundled in this repo. Override the ref/repo at build time if needed: |
| 21 | +# podman build --build-arg BOJ_CARTRIDGES_REF=v1.2.3 ... |
| 22 | +ARG BOJ_CARTRIDGES_REF=main |
| 23 | +ARG BOJ_CARTRIDGES_REPO=https://github.com/hyperpolymath/boj-server-cartridges.git |
| 24 | + |
19 | 25 | FROM cgr.dev/chainguard/wolfi-base:latest AS zig-builder |
20 | 26 |
|
21 | | -RUN apk add --no-cache zig build-base |
| 27 | +RUN apk add --no-cache zig build-base git bash |
22 | 28 |
|
23 | 29 | WORKDIR /build |
24 | 30 |
|
25 | | -# Copy Zig source and cartridge FFI sources |
| 31 | +# Copy Zig source |
26 | 32 | COPY ffi/zig/ ffi/zig/ |
27 | | -COPY cartridges/ cartridges/ |
| 33 | + |
| 34 | +# Fetch the cartridge tree from the registry into /build/cartridges, flattened to |
| 35 | +# <name>/ (the layout the build loops below and the runtime Catalog both expect). |
| 36 | +ARG BOJ_CARTRIDGES_REF |
| 37 | +ARG BOJ_CARTRIDGES_REPO |
| 38 | +COPY scripts/fetch-cartridges.sh /tmp/fetch-cartridges.sh |
| 39 | +RUN BOJ_CARTRIDGES_REF="$BOJ_CARTRIDGES_REF" \ |
| 40 | + BOJ_CARTRIDGES_REPO="$BOJ_CARTRIDGES_REPO" \ |
| 41 | + BOJ_CARTRIDGES_PATH=/build/cartridges \ |
| 42 | + bash /tmp/fetch-cartridges.sh |
28 | 43 |
|
29 | 44 | # Build boj-invoke CLI (x86_64-linux-gnu target so it uses DlDynLib/real dlopen) |
30 | 45 | RUN cd ffi/zig && zig build invoke -Doptimize=ReleaseFast |
@@ -104,9 +119,11 @@ RUN for cart_dir in /tmp/cartridges-src/*/; do \ |
104 | 119 | done && \ |
105 | 120 | rm -rf /tmp/cartridges-src |
106 | 121 |
|
107 | | -# Copy cartridge metadata (cartridge.json files — loaded by Catalog GenServer) |
| 122 | +# Copy cartridge metadata (cartridge.json files — loaded by Catalog GenServer). |
| 123 | +# Sourced from the fetched tree in the zig-builder stage, not the build context, |
| 124 | +# so the image build no longer depends on a bundled cartridges/ directory. |
108 | 125 | RUN mkdir -p /app-cartridges-meta |
109 | | -COPY cartridges/ /tmp/carts-meta/ |
| 126 | +COPY --from=zig-builder /build/cartridges/ /tmp/carts-meta/ |
110 | 127 | RUN for cart_dir in /tmp/carts-meta/*/; do \ |
111 | 128 | cart="$(basename "$cart_dir")" && \ |
112 | 129 | if [ -f "${cart_dir}cartridge.json" ]; then \ |
|
0 commit comments