Files
ServerKit/docker-compose.yml
T
Juan Denis 8921b6ff0a Compose: containerize backend & build frontend
Move the backend into docker-compose and switch the frontend to a multi-stage Docker build. Key changes:

- Added backend/.dockerignore to ignore virtualenv, pycache, env files, instance, etc.
- Updated backend Flask app to safely serve index.html only if it exists and return JSON status/errors when frontend assets are absent.
- Removed docker-compose.dev.yml and expanded docker-compose.yml to run both backend and frontend in Docker (backend service, healthcheck, restart/logging, new ports 5849:5000 & 3847:80, and named volumes).
- Frontend changes: remove file ignores that prevented in-container builds, replace nginx-only image with a Node builder stage + nginx runtime (builds assets in Docker), and update nginx proxy to target the backend service (proxy_pass http://backend:5000).
- Updated dev script (scripts/dev/dev.bat) to use plain `docker compose` commands and the new service/container names and ports.

These changes enable fully containerized local/dev runs where the frontend is built inside Docker and the backend runs as a service in the compose network.
2026-03-01 14:30:21 -05:00

81 lines
2.0 KiB
YAML

# ============================================
# ServerKit Docker Compose
# ============================================
# Runs both backend and frontend in Docker.
# Note: System management features (PHP install,
# firewall, etc.) won't work in Docker.
#
# Usage:
# docker compose up --build -d
#
# Access:
# Frontend: http://localhost:3847
# Backend: http://localhost:5849
# ============================================
services:
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: serverkit-backend
environment:
- FLASK_ENV=development
- SECRET_KEY=dev-secret-key-not-for-production
- JWT_SECRET_KEY=dev-jwt-key-not-for-production
- DATABASE_URL=sqlite:////app/instance/serverkit.db
- CORS_ORIGINS=http://localhost,http://localhost:3847,http://localhost:5173
ports:
- "5849:5000"
volumes:
- serverkit-data:/app/instance
- serverkit-config:/etc/serverkit
networks:
- serverkit-network
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5000/api/v1/system/health"]
interval: 10s
timeout: 5s
retries: 3
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: serverkit-frontend
ports:
- "3847:80"
depends_on:
backend:
condition: service_healthy
networks:
- serverkit-network
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost/"]
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
volumes:
serverkit-data:
name: serverkit-data
serverkit-config:
name: serverkit-config