babylon-game-starter

Deployment System Guide

This project uses a settings-driven deployment system designed to support multiple hosts and deployment styles while keeping one source of truth for service topology.

The deployment system is centered around:

Visual Stack Overview

Docker Nginx Rust Go Python

These logos are referenced from the repository-level resources directory for GitHub documentation viewing.

Directory Layout

Core Model

The deployment model expresses:

Service runtime types currently supported:

For python services, a framework must be declared:

Host and Type Compatibility

Rules enforced by type model and script validation:

Settings File

Primary runtime configuration lives in:

Typed companion file for TypeScript consumers:

Example shape:

Service-to-Folder Mapping

Each entry in settings.services maps to a folder under src/server.

If settings declares:

Then scaffolding creates:

The prepare script also emits runtime-specific starter files.

Scaffolding Behavior by Runtime

Node service:

Rust service:

Go service:

Python service:

Conditional Runtime Installation

Conditional installation is used in Docker build stage so language-specific dependencies are only installed when needed by configured routes.

How it works:

  1. runtime-install-plan.mjs reads settings.services.
  2. It emits shell flags:
    • NEED_GO
    • NEED_RUST
    • NEED_PYTHON
    • PYTHON_FRAMEWORKS
  3. Dockerfile evaluates flags.
  4. Only required packages are installed.

Current package behavior:

Host Artifact Generation

prepare-deployment.mjs generates host-specific files based on settings.

Render:

Netlify static:

GitHub Pages static:

Vite Integration

vite.config.ts reads deployment settings and applies:

This keeps local development aligned with deployment topology.

Default Deployment Profile

Current defaults are set for Render free web-service:

Mermaid Diagrams

1) High-Level Deployment Configuration Flow

flowchart TD
  A[settings.mjs] --> B[prepare-deployment.mjs]
  A --> C[vite.config.ts]
  B --> D[src/server service scaffolds]
  B --> E[render.yaml]
  B --> F[netlify.toml]
  B --> G[github pages workflow]
  A --> H[runtime-install-plan.mjs]
  H --> I[Dockerfile conditional installs]
  I --> J[Container image]

2) Conditional Runtime Installation Logic

flowchart TD
  A[Read services array] --> B{Any go service?}
  B -->|Yes| C[Install go]
  B -->|No| D[Skip go]
  C --> E{Any rust service?}
  D --> E
  E -->|Yes| F[Install rust and cargo]
  E -->|No| G[Skip rust]
  F --> H{Any python service?}
  G --> H
  H -->|Yes| I[Install python3 and pip]
  H -->|No| J[Skip python]
  I --> K[Install only declared frameworks]

3) Service Scaffold Mapping

flowchart LR
  A[settings.services] --> B[Service 1: name]
  A --> C[Service 2: name]
  B --> D[src/server/name]
  C --> E[src/server/name]
  D --> F[Runtime starter files]
  E --> F

Typical Workflow

  1. Edit src/deployment/settings/settings.mjs.
  2. Run npm run deploy:prepare.
  3. Review generated artifacts and server scaffolds.
  4. Run local dev and validate service proxy behavior.
  5. Deploy to chosen host.

Switching to Static Hosts

For github.io:

For netlify:

For render static:

Validation and Safety Notes

Validation performed during preparation includes:

Troubleshooting

If a service folder is not created:

If runtime tools are unexpectedly installed in Docker:

If host artifacts are missing:

Future Enhancements

Potential extensions: