1
0
Fork 0

fix(docker): keep runner as the final stage, move runner-arena above it

Coolify builds Main Website without --target (dockerfile_target_build is
null), so Docker takes the LAST stage as the web image. The previous
commit appended runner-arena at the end, and the resulting auto-deploy
(16:33) built the arena image for the web app; it failed its health
check and Coolify kept the old container, so prod never went down.

Reorder: base -> prod-deps -> builder -> runner-arena -> runner (last).
Adds a warning comment at the runner stage so future stages are never
appended after it. The arena service sets an explicit build target.
This commit is contained in:
Jason Fraley 2026-10-19 12:39:06 -04:00
parent 394db6dfa1
commit d82e8057ba

View file

@ -132,6 +132,43 @@ ENV SOURCE_COMMIT=$SOURCE_COMMIT \
GIT_COMMIT_SUBJECT=$GIT_COMMIT_SUBJECT
RUN bun run build
# ───────────────────────── runner-arena ────────────────────────────
# Arena: standalone real-time match server (src/arena/) hosting live Ordnance
# Disposal drills over WebSockets. Coolify builds this target as a SECOND
# service from the same repo (different build target + start command). Node-only
# like the runner: the production host CPU lacks AVX/AVX2, so never Bun. Runs
# via tsx so the @/ tsconfig path alias resolves, same trick as the Discord bot.
# Deliberately does NOT depend on the builder stage: the arena imports only the
# pure engine + ws + jose, so its image needs no Next build (src ships straight
# from the build context).
FROM node:22-alpine AS runner-arena
RUN apk add --no-cache libc6-compat wget
WORKDIR /app
ENV NODE_ENV=production \
ARENA_PORT=4100
# The `node` user already exists in `node:*-alpine` images.
RUN mkdir -p /app && chown -R node:node /app
# Full prod deps (ws, jose, tsx live here) from the shared prod-deps stage.
COPY --from=prod-deps --chown=node:node /app/node_modules ./node_modules
# Source + tsconfig (tsx path alias resolution) + package.json.
COPY --chown=node:node src ./src
COPY --chown=node:node package.json tsconfig.json ./
EXPOSE 4100
# Liveness probe on the arena's own /health (no DB, no Next dependency).
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
CMD wget -qO- "http://127.0.0.1:${ARENA_PORT:-4100}/health" >/dev/null 2>&1 || exit 1
USER node
CMD ["node", "--import", "tsx", "src/arena/server.ts"]
# WARNING: keep `runner` as the LAST stage. Coolify builds Main Website
# without --target (dockerfile_target_build unset), so Docker uses the final
# stage as the web image; any stage appended after it silently becomes prod.
# ─────────────────────────── runner ──────────────────────────────
# Final production image: Next standalone runtime + full prod deps +
# src/migrations. Node-only (see header): the production host CPU has no
@ -207,37 +244,3 @@ USER node
# (Next is shipped and tested on Node).
ENTRYPOINT ["/bin/sh", "/docker-entrypoint.sh"]
CMD ["node", "server.js"]
# ───────────────────────── runner-arena ────────────────────────────
# Arena: standalone real-time match server (src/arena/) hosting live Ordnance
# Disposal drills over WebSockets. Coolify builds this target as a SECOND
# service from the same repo (different build target + start command). Node-only
# like the runner: the production host CPU lacks AVX/AVX2, so never Bun. Runs
# via tsx so the @/ tsconfig path alias resolves, same trick as the Discord bot.
# Deliberately does NOT depend on the builder stage: the arena imports only the
# pure engine + ws + jose, so its image needs no Next build (src ships straight
# from the build context).
FROM node:22-alpine AS runner-arena
RUN apk add --no-cache libc6-compat wget
WORKDIR /app
ENV NODE_ENV=production \
ARENA_PORT=4100
# The `node` user already exists in `node:*-alpine` images.
RUN mkdir -p /app && chown -R node:node /app
# Full prod deps (ws, jose, tsx live here) from the shared prod-deps stage.
COPY --from=prod-deps --chown=node:node /app/node_modules ./node_modules
# Source + tsconfig (tsx path alias resolution) + package.json.
COPY --chown=node:node src ./src
COPY --chown=node:node package.json tsconfig.json ./
EXPOSE 4100
# Liveness probe on the arena's own /health (no DB, no Next dependency).
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
CMD wget -qO- "http://127.0.0.1:${ARENA_PORT:-4100}/health" >/dev/null 2>&1 || exit 1
USER node
CMD ["node", "--import", "tsx", "src/arena/server.ts"]