Production Deployment
The recommended way to run MachinaOs in production is the built-in self-deploy CLI. One command provisions a login-gated MachinaOs VM on a cloud provider, installs the app, and runs it behind the login screen.- Cloud CLI (auth + context) - the provider adapter (currently
gcloud; AWS is a follow-on) verifies your cloud CLI is installed and authenticated, resolves the project/region/zone, checks Application Default Credentials, and enables the required cloud APIs. - Terraform - generates fresh secrets and owner credentials, packages your local build, then creates all resources: the VM (always named
machinaos), firewall rule, artifact bucket, and service account. A cloud-init startup script installs Node.js and uv, installs the package, and runsmachina serveunder systemd on a single public port.
machina serve fronts the API, WebSocket, and the built single-page app plus the Node.js sidecar all on one port. No separate frontend container or reverse proxy is required for the standard path.Prerequisites
- A cloud account (Google Cloud for the
gcpprovider). - The
gcloudCLI installed and authenticated: - Node.js 22+ and npm on your local machine (used to package the local build via
npm pack). - Terraform is auto-installed by the deploy CLI if it is not already on PATH.
Deploy
--owner-password, a strong password is generated and printed once - save it.
Common options
Cloud provider.
gcp today; AWS is a follow-on.Login email for the owner account (single-owner mode).
Login password (min 8 chars). Generated and printed once if omitted.
VM size.
Public port the app binds and the firewall opens.
Firewall source range. Restrict to your own IP with something like
203.0.113.4/32.Cloud region (provider default if omitted).
Cloud zone (provider default if omitted).
GCP project (defaults to your
gcloud config).The Login Gate
The deploy path always provisions a login-gated, single-owner instance:VITE_AUTH_ENABLED=trueandAUTH_MODE=single.- The owner credential is generated at deploy time and seeded on first boot.
- Fresh
JWT_SECRET_KEY,SECRET_KEY, andAPI_KEY_ENCRYPTION_KEYare minted per deployment.
Status and Health
/health. The VM takes a few minutes on first boot to install Node, npm, and build the app.
Updating
Re-runningdeploy up re-applies Terraform safely (the VM stays named machinaos). To ship a new local build, run machina deploy up again from an updated checkout.
Tearing Down
terraform destroy and clears the local deployment state.
Deployment state lives at
<user-data>/deploy/machinaos/. It is preserved by machina clean - only machina deploy destroy removes it, because it tracks live cloud resources.Verify
Security Checklist
Owner login credentials are saved somewhere safe (password shown once)
Firewall source range restricted with —allow-cidr where possible
A TLS terminator + domain in front, with JWT_COOKIE_SECURE=true, before exposing publicly
SSH key authentication only on the VM (disable password auth)
Self-Managed Deployment (Legacy)
If you prefer to run MachinaOs on a server you manage yourself with Docker Compose behind nginx and SSL, the following is a reference topology. Themachina deploy path above is the recommended and maintained approach; the Docker Compose stack is a legacy reference.
Server Requirements
- Ubuntu 20.04+ or similar Linux
- 2+ CPU cores
- 2GB+ RAM
- Docker and Docker Compose
- Domain name (for SSL)
Topology
Server Setup
Clone and Configure
Environment files bootstrap from
.env.template (not .env.example). Copy it and override the values you need.Production Environment
Build and Start
Configure nginx
Create nginx configuration:SSL Certificate
Firewall
Maintenance
Updates
Backups
Monitoring
Troubleshooting
502 Bad Gateway
502 Bad Gateway
- Check if containers are running:
docker-compose ps - Verify ports match nginx config
- Check backend logs:
docker-compose logs backend
WebSocket connection fails
WebSocket connection fails
- Verify nginx WebSocket config has Upgrade headers
- Check proxy_read_timeout is set
- Ensure firewall allows connections
SSL certificate issues
SSL certificate issues
High memory usage
High memory usage
- Check for memory leaks:
docker stats - Restart containers:
docker-compose restart - Increase server RAM if needed
Related
Docker Setup
Local Docker development
Installation
Environment variables and local setup