Files
ServerKit/docker-compose.yml
T
Juan DenisandClaude Opus 4.8 ca66629780 feat(deploy): serve panel frontend from host nginx, retire the container
The panel is now fully off Docker: the React SPA is served as static
files directly by host nginx from frontend/dist, eliminating the
serverkit-frontend container and the double nginx hop (host nginx ->
container nginx -> dist). Docker is now used ONLY for managed app
workloads.

- nginx sites (serverkit.conf + serverkit-insecure.conf): `location /`
  now roots at /opt/serverkit/frontend/dist with a try_files SPA
  fallback and a long-cache /assets/ block, instead of proxying
  127.0.0.1:3847. Root tracks the /opt/serverkit symlink so blue/green
  updates swap assets atomically.
- install.sh: launch_services no longer builds/starts a frontend
  container; adds apply_frontend_root (rewrites the dist root for a
  custom SERVERKIT_DIR) and selinux_label_frontend_dist (httpd_sys_-
  content_t so SELinux hosts can read the bundle from /opt).
- update.sh: refresh_config carries the same root rewrite across
  upgrades; selinux_label_dist relabels the switched-in slot; dropped
  the `docker compose up -d --force-recreate frontend` from both the
  forward and rollback paths.
- docker-compose.yml: frontend service moved behind a `legacy-frontend`
  profile (opt-in escape hatch); default `up -d` starts nothing.
- docs/DEPLOYMENT.md: documents the off-Docker panel model.

Tests: T14 (refresh_config rewrites dist root for custom install dir),
T15 (shipped nginx configs serve static, never proxy :3847). 16 passed.

Note: live nginx -t / SELinux file-serving not validated on a RHEL box
from this dev host; logic is best-effort guarded.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 02:24:22 -04:00

59 lines
2.2 KiB
YAML

# ============================================
# ServerKit Docker Compose (optional legacy frontend container)
# ============================================
# ServerKit runs FULLY OFF DOCKER for the panel itself:
# - the backend runs on the host via systemd `serverkit.service`, and
# - the React frontend is served as static files directly by the host nginx
# from frontend/dist (built by install.sh) — NO container.
# This keeps a ServerKit update from ever touching the workloads: managed apps
# are the only things in Docker, and host nginx (which fronts them) is never
# stopped, only gracefully reloaded.
#
# The `frontend` service below is retained ONLY as an opt-in escape hatch for
# anyone who specifically wants the panel UI in a container. It sits behind the
# `legacy-frontend` profile, so the default `docker compose up -d` starts
# NOTHING. To use it, also repoint nginx `location /` back at 127.0.0.1:3847:
#
# docker compose --profile legacy-frontend up -d --build
#
# Want a quick, throwaway demo with NO host management? Use the single-container
# image built from ./Dockerfile instead — it bundles both tiers but, as its
# header notes, cannot manage the host.
# ============================================
services:
frontend:
profiles: ["legacy-frontend"]
build:
context: ./frontend
dockerfile: Dockerfile
container_name: serverkit-frontend
ports:
- "3847:80"
# Resolve `backend` (used by frontend/nginx.conf) to the host, where the
# ServerKit backend listens on :5000 under systemd.
extra_hosts:
- "backend:host-gateway"
# install.sh builds the SPA to ./frontend/dist on the host; serve that build
# directly so a rebuild doesn't require rebuilding the image.
volumes:
- ./frontend/dist:/usr/share/nginx/html:ro
networks:
- serverkit-network
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1/"]
interval: 30s
timeout: 10s
retries: 3
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
networks:
serverkit-network:
driver: bridge
name: serverkit-network