Files
source-gamepanel/docker-compose.yml
T
hibna 55e0a3cde6
CI / Docker Build (push) Has been skipped
CI / Lint & Type Check (push) Successful in 4m13s
CI / Daemon Build & Test (push) Successful in 6m24s
CI / Publish images (push) Failing after 12s
Make the API and web images build and run
The image builds were never exercised: the docker job needs lint, and
lint was failing, so nothing downstream of it ever ran. Four defects
had accumulated behind that gate, each fatal on its own.

- pnpm creates no node_modules for a package without dependencies, and
  @source/shared has none. Three COPY lines named that path and failed.
- The production stage copied apps/api/dist, which tsc never wrote:
  tsconfig.base.json sets noEmit and no package overrides it. Rather
  than turn emit on — every @source/* package points main at its
  TypeScript source, and @source/proto derives daemon.proto's location
  from a /src/index.ts module URL — the stage now runs the sources
  through tsx, exactly as the migrate stage has always done.
- tsx lives in apps/api/node_modules/.bin under pnpm's isolated layout,
  so the command only resolves from the package directory.
- Both healthchecks probed localhost, which musl resolves to ::1 while
  the servers bind IPv4. Every probe was refused, so the containers sat
  unhealthy forever — and `docker compose up --wait`, which is how a
  panel installs this stack, waits for healthy.

Also fixed the postgres healthcheck in both compose files. pg_isready
without -h asks over the unix socket, which answers during the image's
init phase before the server listens on TCP; the migrate container then
started and died with ECONNREFUSED against a container Compose had just
called healthy.

Verified by running the full stack from docker-compose.panel.yml with
locally built images: migrations and seed complete, api, web, daemon,
postgres and redis all report healthy, and /api/health answers 200
through the web container's proxy.
2026-08-02 21:48:51 +03:00

134 lines
4.4 KiB
YAML

# GamePanel — single-host deployment.
#
# ./scripts/install.sh generates .env with fresh secrets
# docker compose up -d builds and starts everything
#
# Serves plain HTTP on ${WEB_PORT} by design. Put your own reverse proxy
# (Caddy, nginx, Traefik, Cloudflare Tunnel…) in front of it for TLS and a
# domain — see INSTALLATION.md.
services:
# --- PostgreSQL ---
postgres:
image: postgres:16-alpine
container_name: gamepanel-postgres
restart: unless-stopped
environment:
POSTGRES_USER: ${DB_USER:-gamepanel}
POSTGRES_PASSWORD: ${DB_PASSWORD:-gamepanel}
POSTGRES_DB: ${DB_NAME:-gamepanel}
volumes:
- postgres_data:/var/lib/postgresql/data
# Not published by default — only the API needs it. Set DB_PORT to expose it.
expose:
- "5432"
healthcheck:
# -h forces a TCP probe. Without it pg_isready talks over the unix
# socket, which answers during the image's init phase while the
# server is not listening on 5432 yet — dependents then start and
# get ECONNREFUSED from a container Compose just called healthy.
test: ["CMD-SHELL", "pg_isready -h 127.0.0.1 -U ${DB_USER:-gamepanel}"]
interval: 10s
timeout: 5s
retries: 5
# --- Redis (rate limiting, session cache) ---
redis:
image: redis:7-alpine
container_name: gamepanel-redis
restart: unless-stopped
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD:-gamepanel}
volumes:
- redis_data:/data
expose:
- "6379"
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD:-gamepanel}", "ping"]
interval: 10s
timeout: 5s
retries: 5
# --- Schema migration + seed (runs to completion, then exits) ---
migrate:
build:
context: .
dockerfile: apps/api/Dockerfile
target: migrate
container_name: gamepanel-migrate
restart: "no"
depends_on:
postgres:
condition: service_healthy
environment:
DATABASE_URL: postgresql://${DB_USER:-gamepanel}:${DB_PASSWORD:-gamepanel}@postgres:5432/${DB_NAME:-gamepanel}
# --- API ---
api:
build:
context: .
dockerfile: apps/api/Dockerfile
container_name: gamepanel-api
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
migrate:
condition: service_completed_successfully
environment:
NODE_ENV: production
DATABASE_URL: postgresql://${DB_USER:-gamepanel}:${DB_PASSWORD:-gamepanel}@postgres:5432/${DB_NAME:-gamepanel}
REDIS_URL: redis://:${REDIS_PASSWORD:-gamepanel}@redis:6379
PORT: 3000
HOST: 0.0.0.0
JWT_SECRET: ${JWT_SECRET:?set JWT_SECRET in .env — run ./scripts/install.sh}
JWT_REFRESH_SECRET: ${JWT_REFRESH_SECRET:?set JWT_REFRESH_SECRET in .env — run ./scripts/install.sh}
CORS_ORIGIN: ${CORS_ORIGIN:-http://localhost}
RATE_LIMIT_MAX: ${RATE_LIMIT_MAX:-100}
RATE_LIMIT_WINDOW_MS: ${RATE_LIMIT_WINDOW_MS:-60000}
expose:
- "3000"
# --- Web (nginx + SPA, also reverse-proxies /api and /socket.io) ---
web:
build:
context: .
dockerfile: apps/web/Dockerfile
args:
VITE_API_URL: /api
container_name: gamepanel-web
restart: unless-stopped
depends_on:
- api
ports:
- "${WEB_PORT:-80}:80"
# --- Daemon (runs on game server nodes) ---
daemon:
build:
context: .
dockerfile: apps/daemon/Dockerfile
container_name: gamepanel-daemon
restart: unless-stopped
depends_on:
- api
environment:
DAEMON_CONFIG: /etc/gamepanel/config.yml
# Game containers are created through the host's Docker socket, so their
# bind mounts are resolved by the *host*, not by this container. Without
# this the daemon and the game would end up looking at two different
# directories and every file written from the panel would vanish.
DAEMON_HOST_DATA_PATH: ${DAEMON_DATA_PATH:-/var/lib/gamepanel/servers}
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${DAEMON_DATA_PATH:-/var/lib/gamepanel/servers}:/var/lib/gamepanel/servers
- ${DAEMON_BACKUP_PATH:-/var/lib/gamepanel/backups}:/var/lib/gamepanel/backups
- ./daemon-config.yml:/etc/gamepanel/config.yml:ro
ports:
- "${DAEMON_GRPC_PORT:-50051}:50051"
volumes:
postgres_data:
redis_data: