This commit is contained in:
parent
cc39b528e6
commit
bdc4ade8cf
9 changed files with 1120 additions and 1787 deletions
|
|
@ -1,50 +1,37 @@
|
|||
# =============================================================================
|
||||
# Nakama with Custom Chess Modules
|
||||
# Nakama with Custom Go Chess Modules
|
||||
# =============================================================================
|
||||
# Two-stage build:
|
||||
# 1. Build TypeScript modules with Node.js
|
||||
# 2. Copy compiled JS to Nakama runtime
|
||||
# 1. Build Go plugin using official Nakama plugin builder
|
||||
# 2. Copy compiled plugin to Nakama runtime
|
||||
# =============================================================================
|
||||
|
||||
# Stage 1: Build TypeScript modules
|
||||
FROM node:20-alpine AS builder
|
||||
# Stage 1: Build Go plugin
|
||||
# IMPORTANT: Plugin builder version MUST match Nakama server version
|
||||
FROM heroiclabs/nakama-pluginbuilder:3.35.1 AS builder
|
||||
|
||||
# Install git for GitHub dependencies (nakama-runtime) and file for debugging
|
||||
RUN apk add --no-cache git file
|
||||
WORKDIR /backend
|
||||
|
||||
WORKDIR /app
|
||||
# Copy Go module files
|
||||
COPY go-modules/go.mod go-modules/go.sum* ./
|
||||
|
||||
# Copy module files and install dependencies
|
||||
COPY modules/package*.json ./
|
||||
# Use npm ci for reproducible builds from lock file
|
||||
RUN npm ci && \
|
||||
echo "=== Installed versions ===" && \
|
||||
npm ls --depth=0
|
||||
# Download dependencies
|
||||
RUN go mod download 2>/dev/null || go mod tidy
|
||||
|
||||
# Copy source and build
|
||||
COPY modules/tsconfig.json ./
|
||||
COPY modules/src ./src
|
||||
# Copy source
|
||||
COPY go-modules/*.go ./
|
||||
|
||||
# Build with esbuild (output to build/index.js)
|
||||
RUN npm run build
|
||||
# Build the plugin as a shared library
|
||||
RUN go build -buildmode=plugin -trimpath -o backend.so .
|
||||
|
||||
# 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
|
||||
# Verify build
|
||||
RUN ls -la backend.so && file backend.so
|
||||
|
||||
# Stage 2: Nakama runtime with modules
|
||||
# Stage 2: Nakama runtime with Go plugin
|
||||
FROM registry.heroiclabs.com/heroiclabs/nakama:3.35.1
|
||||
|
||||
# Copy compiled JavaScript modules
|
||||
# Nakama expects modules at /nakama/data/modules/
|
||||
COPY --from=builder /app/build/index.js /nakama/data/modules/main.js
|
||||
# Copy compiled Go plugin
|
||||
COPY --from=builder /backend/backend.so /nakama/data/modules/backend.so
|
||||
|
||||
# Copy config file (optional - can also be passed via CLI)
|
||||
# Copy config file
|
||||
COPY config.yml /nakama/data/config.yml
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue