2026-01-06 05:13:49 -05:00
|
|
|
# =============================================================================
|
|
|
|
|
# Nakama with Custom Chess Modules
|
|
|
|
|
# =============================================================================
|
|
|
|
|
# Two-stage build:
|
|
|
|
|
# 1. Build TypeScript modules with Node.js
|
|
|
|
|
# 2. Copy compiled JS to Nakama runtime
|
|
|
|
|
# =============================================================================
|
|
|
|
|
|
|
|
|
|
# Stage 1: Build TypeScript modules
|
|
|
|
|
FROM node:20-alpine AS builder
|
|
|
|
|
|
2026-01-06 23:00:03 -05:00
|
|
|
# Install git for GitHub dependencies (nakama-runtime) and file for debugging
|
|
|
|
|
RUN apk add --no-cache git file
|
2026-01-06 05:19:07 -05:00
|
|
|
|
2026-01-06 05:13:49 -05:00
|
|
|
WORKDIR /app
|
|
|
|
|
|
2026-01-06 05:17:01 -05:00
|
|
|
# Copy module files and install dependencies
|
2026-01-06 05:13:49 -05:00
|
|
|
COPY modules/package*.json ./
|
2026-01-06 23:00:03 -05:00
|
|
|
# Use npm ci for reproducible builds from lock file
|
|
|
|
|
RUN npm ci && \
|
|
|
|
|
echo "=== Installed versions ===" && \
|
|
|
|
|
npm ls --depth=0
|
2026-01-06 05:13:49 -05:00
|
|
|
|
|
|
|
|
# Copy source and build
|
|
|
|
|
COPY modules/tsconfig.json ./
|
|
|
|
|
COPY modules/src ./src
|
|
|
|
|
|
|
|
|
|
# Build with esbuild (output to build/index.js)
|
|
|
|
|
RUN npm run build
|
|
|
|
|
|
2026-01-06 23:00:03 -05:00
|
|
|
# Verify build output exists and show details
|
|
|
|
|
RUN ls -la build/ && test -f build/index.js && \
|
|
|
|
|
echo "=== File info ===" && \
|
|
|
|
|
file build/index.js && \
|
|
|
|
|
echo "=== Line count ===" && \
|
|
|
|
|
wc -l build/index.js && \
|
|
|
|
|
echo "=== First 5 lines ===" && \
|
|
|
|
|
head -5 build/index.js && \
|
|
|
|
|
echo "=== Lines 1259-1265 ===" && \
|
|
|
|
|
sed -n '1259,1265p' build/index.js
|
2026-01-06 05:13:49 -05:00
|
|
|
|
|
|
|
|
# Stage 2: Nakama runtime with modules
|
2026-01-07 22:20:16 -05:00
|
|
|
FROM registry.heroiclabs.com/heroiclabs/nakama:3.35.1
|
2026-01-06 05:13:49 -05:00
|
|
|
|
|
|
|
|
# Copy compiled JavaScript modules
|
|
|
|
|
# Nakama expects modules at /nakama/data/modules/
|
|
|
|
|
COPY --from=builder /app/build/index.js /nakama/data/modules/main.js
|
|
|
|
|
|
|
|
|
|
# Copy config file (optional - can also be passed via CLI)
|
|
|
|
|
COPY config.yml /nakama/data/config.yml
|