albion/Dockerfile
Заид Омар Медхат 337dac78ba
All checks were successful
Deploy / deploy (push) Successful in 3m58s
Client/server split, Postgres, auth, Windows agent, Docker deploy
- Extract world-parse + packet capture into @albion/shared (reused by
  server and a new standalone agent workspace).
- Migrate the data layer from SQLite/better-sqlite3 to shared Postgres
  (async pg with a ?->$n helper; economy engine preloads the item/recipe
  graph so its sync recursion still works).
- API-key auth (ALBION_API_KEY) on all /api routes except health; web UI
  sends it via a fetch wrapper + key-entry gate; server serves the built
  UI with a path-traversal-safe static handler (drops @fastify/static).
- Windows companion agent: pushes world map + captured market orders to
  /api/ingest/*; runs on the gaming PC where the game traffic lives.
- Docker + docker-compose (external proxy + backend networks for Nginx
  Proxy Manager and shared Postgres) and a Forgejo deploy workflow.
- Validated end-to-end against Postgres 16 and a full compose run.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-23 04:10:08 +05:00

46 lines
1.4 KiB
Docker

# syntax=docker/dockerfile:1
# Multi-stage build: install workspace deps, build the web UI, run the server
# (which serves the built UI and connects to the shared Postgres). The agent
# workspace is NOT in the image — it runs on the player's PC.
FROM node:22-bookworm-slim AS build
WORKDIR /app
# Install deps using the workspace manifests (better layer caching). No native
# toolchain needed — the data layer is pure-JS `pg`.
COPY package.json package-lock.json ./
COPY shared/package.json ./shared/
COPY server/package.json ./server/
COPY web/package.json ./web/
COPY agent/package.json ./agent/
RUN npm ci
# Copy sources and build the web UI.
COPY shared ./shared
COPY server ./server
COPY web ./web
RUN npm run build -w web
# ---- runtime image ----
FROM node:22-bookworm-slim AS runtime
WORKDIR /app
ENV NODE_ENV=production \
HOST=0.0.0.0 \
PORT=4310 \
ALBION_DATA_DIR=/data \
WEB_DIST=/app/web/dist
COPY --from=build /app/node_modules ./node_modules
COPY --from=build /app/package.json ./package.json
COPY --from=build /app/shared ./shared
COPY --from=build /app/server ./server
COPY --from=build /app/web/dist ./web/dist
# Downloaded game-data JSON cache lives here (the DB is external Postgres).
RUN mkdir -p /data
VOLUME /data
EXPOSE 4310
# The server creates its schema and, on first boot with an empty DB, downloads
# and parses game data in the background.
CMD ["node", "--import", "tsx", "server/src/index.ts"]