Operations Deployment - osama1998H/Moca GitHub Wiki

Deployment

Deploy Moca to production using your preferred method.

Architecture

Moca Processes

Process Role Scaling
moca-server HTTP + WebSocket API gateway Horizontal — multiple replicas behind load balancer
moca-worker Background job consumer (Redis Streams) Horizontal — scale to match queue depth
moca-scheduler Cron job dispatcher Single instance (leader election built-in)
moca-outbox Transactional outbox poller → Kafka Single instance per site recommended

Infrastructure Services

Service Required Purpose
PostgreSQL 16+ Yes Primary data store, schema-per-tenant isolation
Redis 7+ Yes Cache, job queue (Redis Streams), pub/sub events
Meilisearch v1.12 Yes Full-text search, index-per-tenant

Deployment Methods

Method Guide Best For
Single Server Single Server Deployment Small teams, staging, cost-sensitive production
Docker Docker Deployment Containerized environments, easy local parity
Kubernetes Kubernetes Deployment Large-scale, multi-tenant, cloud-native

Infrastructure Generation

Moca can generate infrastructure configuration files for your chosen stack:

moca generate caddy        # Caddy reverse proxy config with automatic TLS
moca generate nginx        # NGINX reverse proxy config
moca generate systemd      # systemd service units for all processes
moca generate docker       # Dockerfile and docker-compose.yml
moca generate k8s          # Kubernetes manifests (Deployments, Services, HPA)
moca generate supervisor   # Supervisor process config
moca generate env          # .env template with all required variables

Deployment Orchestration

The moca deploy command orchestrates end-to-end deployment operations:

moca deploy setup          # Initial server provisioning (14-step pipeline)
moca deploy update         # Zero-downtime rolling update
moca deploy rollback       # Roll back to previous release
moca deploy promote        # Promote staging to production
moca deploy status         # Show current deployment state across all processes
moca deploy history        # List deployment history and release log

Related