Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:4thfever Cultivation world simulator Docker Deployment Environment

From Leeroopedia
Knowledge Sources
Domains Infrastructure, Deployment
Last Updated 2026-10-22 16:00 GMT

Overview

Docker Compose deployment with Python 3.12 backend and nginx frontend, using `CWS_DATA_DIR` for persistent data storage.

Description

The Docker deployment environment packages the Cultivation World Simulator into two containers: a backend running `python:3.12-bookworm` with uvicorn, and a frontend running nginx that proxies API calls to the backend. Data persistence is unified through the `CWS_DATA_DIR` environment variable pointing to a mounted volume. The backend container is configured with `CWS_DISABLE_AUTO_SHUTDOWN=1` to prevent automatic exit when WebSocket connections drop. Health checks verify the full proxy chain (frontend → backend) by hitting the runtime status API.

Usage

Use this environment for production or self-hosted deployment of the Cultivation World Simulator. Run `docker-compose up` to start both backend and frontend containers. This is the mandatory environment for server deployments that need to survive process restarts and serve multiple clients.

System Requirements

Category Requirement Notes
OS Linux (Docker host) Docker Engine + Docker Compose v3.8+
Hardware 2GB+ RAM, 1+ CPU cores LLM calls are remote; no GPU needed
Disk 1GB+ for images + saves volume Saves grow with simulation length
Network Ports 8002 (backend) and 8123 (frontend) Configurable in docker-compose.yml

Dependencies

System Packages

  • Docker Engine
  • Docker Compose (v3.8+ format)

Container Images

  • Backend: `python:3.12-bookworm` base
  • Frontend: nginx (built from `deploy/Dockerfile.frontend`)

Python Packages (backend container)

  • Only `requirements-runtime.txt` (no test dependencies in production image)
  • `PyYAML` >= 6.0, `omegaconf` >= 2.3.0, `json5` >= 0.9.0
  • `fastapi` >= 0.100.0, `uvicorn` >= 0.20.0, `websockets` >= 11.0

Credentials

The following environment variables must be set in `docker-compose.yml` or passed at runtime:

Note: LLM API keys should be injected via Docker secrets or environment variables, not baked into the image.

Quick Install

# Build and start both containers
docker-compose up -d

# Check health
curl http://localhost:8002/api/v1/query/runtime/status
curl http://localhost:8123/api/v1/query/runtime/status

Code Evidence

Docker Compose service definition from `docker-compose.yml:4-25`:

backend:
  build:
    context: .
    dockerfile: deploy/Dockerfile.backend
  container_name: cultivation-backend
  ports:
    - "8002:8002"
  environment:
    - PYTHONUNBUFFERED=1
    - CWS_DATA_DIR=/data
    - CWS_DISABLE_AUTO_SHUTDOWN=1
  restart: unless-stopped
  healthcheck:
    test: ["CMD", "curl", "-f", "http://127.0.0.1:8002/api/v1/query/runtime/status"]

Backend Dockerfile from `deploy/Dockerfile.backend:1-33`:

FROM python:3.12-bookworm
WORKDIR /app
COPY requirements-runtime.txt .
RUN pip install --no-cache-dir -r requirements-runtime.txt
COPY src/ ./src/
COPY static/ ./static/
COPY assets/ ./assets/
EXPOSE 8002
CMD ["uvicorn", "src.server.main:app", "--host", "0.0.0.0", "--port", "8002"]

Auto-shutdown disable from `src/server/main.py:230`:

raw = os.environ.get("CWS_DISABLE_AUTO_SHUTDOWN", "")

Common Errors

Error Message Cause Solution
Container exits immediately `CWS_DISABLE_AUTO_SHUTDOWN` not set Add `CWS_DISABLE_AUTO_SHUTDOWN=1` to environment
Frontend health check fails Backend not ready or proxy misconfigured Check `depends_on: condition: service_healthy` and nginx config
Data lost after restart No volume mounted to `/data` Add `volumes: - ./docker-data:/data`
`pip install` fails in CI Third-party PyPI mirror unavailable Use `--build-arg PIP_INDEX_URL=https://pypi.org/simple`

Compatibility Notes

  • Production image: Only installs `requirements-runtime.txt`; test dependencies (`pytest`, `polib`, `Pillow`) are NOT included.
  • Health check chain: Frontend health check hits `http://127.0.0.1:80/api/v1/query/runtime/status` which proxies to backend, verifying the full chain.
  • Volume persistence: All saves, settings, and logs go to `/data` (mapped from `CWS_DATA_DIR`). Do not use `/app/assets/saves` or `/app/logs`.
  • Port mapping: Backend exposes 8002, frontend exposes 8123 (nginx). Adjust as needed in `docker-compose.yml`.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment