---
title: Deploying with managed services (cloud) · Machines docs
description: The cloud topology runs only the application processes, all from the backend image (the web app, its migrations, the BullMQ worker and beat), and leaves the…
url: https://spaceworkslabs.tech/docs/machines/deployment-cloud/
updated: 2026-10-29
---

[Space Works Machines](https://spaceworkslabs.tech/docs/machines/) Overview
- [Overview](https://spaceworkslabs.tech/docs/machines/overview/)
- [Email and chat notifications](https://spaceworkslabs.tech/docs/machines/notifications/)
Install and run
- [Deploying on a server (VPS)](https://spaceworkslabs.tech/docs/machines/deployment-vps/)
- [Deploying with managed services (cloud)](https://spaceworkslabs.tech/docs/machines/deployment-cloud/)
- [Hosting the site on Netlify](https://spaceworkslabs.tech/docs/machines/deployment-netlify/)
- [Configuration reference](https://spaceworkslabs.tech/docs/machines/configuration/)
Developers
- [Space Works Machines REST API and webhooks](https://spaceworkslabs.tech/docs/machines/api/)
[All docs](https://spaceworkslabs.tech/docs/)

Space Works Machines · Install and run

# Deploying with managed services (cloud)

The cloud topology runs only the application processes, all from the backend image (the web app, its migrations, the BullMQ worker and beat), and leaves the data to managed services: PostgreSQL with TLS, Redis over TLS, an S3-compatible bucket and an SMTP relay. It uses`docker-compose.cloud.yml`through`scripts/spaceworks-compose.sh cloud`, like the other Space Works apps.

## What you need

| Service | Examples | Notes |
| --- | --- | --- |
| PostgreSQL 16 | Supabase, Neon, RDS, Cloud SQL | `sslmode=require`(or`verify-full`). Behind a transaction pooler (Supabase`:6543`) add`pgbouncer=true`to`DATABASE_URL`and give the direct or session URL as`DIRECT_URL`for migrations. |
| Redis 7 | Upstash, ElastiCache, Redis Cloud | Must be`rediss://`(TLS). Holds rate limits and the BullMQ queues, so choose a plan without eviction (`noeviction`) and with room for steady polling by the worker. |
| Object storage | Cloudflare R2, Amazon S3, Backblaze B2 | A**private**bucket and a key limited to it.`S3_FORCE_PATH_STYLE=1`works with all of them. |
| SMTP | Brevo, Amazon SES, Postmark | A verified sending domain. |
| HTTPS | Your platform's load balancer, Cloudflare, or a reverse proxy | Terminates TLS in front of`APP_PORT`and overwrites the client-IP header named in`TRUSTED_PROXY_IP_HEADER`. |

### Harden the database connection

`sslmode=require`encrypts the connection but doesn't check who is at the other end. In production:
- **Verify the server.**Use`sslmode=verify-full`with your provider's CA (`sslrootcert=/path/to/ca.pem`, mounted read-only into the app, worker and beat containers). Supabase, Neon and RDS all publish their CA bundles.
- **Run the app as a data-only role.**Migrations need the schema owner; the running app doesn't. Create a second role with`CONNECT`,`USAGE`on the schema and`SELECT, INSERT, UPDATE, DELETE`on its tables (plus`USAGE, SELECT`on sequences and`ALTER DEFAULT PRIVILEGES`so new tables follow), put that role in`DATABASE_URL`, and keep the owner only in`DIRECT_URL`, which only the`migrate`role uses. This is how the bundled VPS stack runs (`swmach_app`), and it means a compromised app process can't alter the schema.

## Docker host with Compose `git clone https://github.com/SpaceWorks-Labs/SpaceWorks-Machines.git /opt/spaceworks-machines cd /opt/spaceworks-machines sudo install -D -m 600 .env.production.example /etc/spaceworks-machines/cloud.env sudoedit /etc/spaceworks-machines/cloud.env # fill every value; see docs/CONFIGURATION.md export SWM_IMAGE_TAG=0.1.0-main.42.a1b2c3d4e5f6 # a published release, or latest scripts/spaceworks-compose.sh cloud pull scripts/spaceworks-compose.sh cloud up -d --wait scripts/spaceworks-compose.sh cloud run --rm ops # TLS, migrations, Redis, bucket, readiness`

Generate the keys with`openssl rand -base64 32`(`NEXT_SERVER_ACTIONS_ENCRYPTION_KEY`,`MFA_ENCRYPTION_KEY`,`PAYMENT_SECRETS_KEY`) and`openssl rand -base64 48`(`AUTH_SECRET`,`CRON_SECRET`,`HEALTHCHECK_SECRET`). Keep an offline copy: without`MFA_ENCRYPTION_KEY`and`PAYMENT_SECRETS_KEY`, saved authenticator seeds and gateway keys cannot be read.`SWM_STATIC_ENV_FILE`points the wrapper at another settings file.

| Service | Role |
| --- | --- |
| `migrate` | `--role migrate`:`prisma migrate deploy`on`DIRECT_URL`(falls back to`DATABASE_URL`), then exits |
| `backend` | `--role backend`: the app and API on`${APP_BIND:-127.0.0.1}:${APP_PORT:-8080}` |
| `worker` | `--role worker node dist/worker.js`: runs every queued job (email and chat delivery, retention, the registry in`lib/queue/registry.ts`); health on`:3460/health` |
| `beat` | `--role beat node dist/beat.js`: keeps the repeatable schedules in Redis; health on`:3460/health` |
| `ops`(profile`tools`) | `--role ops`: operator checks on demand |

Block`/api/internal/*`at your edge; the endpoints also refuse any request without`CRON_SECRET`. One beat is enough; more workers share the load, and a second beat does no harm.

**Updating:**back up the database with your provider (point-in-time recovery or a snapshot), then set the new`SWM_IMAGE_TAG`and run`pull`and`up -d --wait`again.`scripts/update.sh`is for the bundled topology.

## Render

[`render.yaml`](https://github.com/SpaceWorks-Labs/SpaceWorks-Machines/blob/b60fee1002f713b8c045e5eca202ac17565a11ab/render.yaml) defines a Docker web service (`swmach-backend`, health check`/api/health`,`MIGRATE_ON_START=1`) and two background workers,`swmach-worker`(`--role worker node dist/worker.js`) and`swmach-beat`(`--role beat node dist/beat.js`), sharing the`swmach-prod`environment group. Render builds the Dockerfile's last stage with your real`NEXT_PUBLIC_BASE_URL`and`NEXT_SERVER_ACTIONS_ENCRYPTION_KEY`as build arguments. Render's own Key Value is plain`redis://`, which production refuses, so use a TLS Redis such as Upstash.

Render background workers need a paid plan. Without them, keep at least the worker (it does the delivery) and replace beat with the cron fallback below.

## Without a beat process (cron fallback)

Hosts that cannot keep a long-running beat call two endpoints once a minute from any cron service (a Render cron job, GitHub Actions, a systemd timer): `curl -fsS -X POST -H "Authorization: Bearer $CRON_SECRET" https://<backend>/api/internal/jobs curl -fsS -X POST -H "Authorization: Bearer $CRON_SECRET" https://<backend>/api/internal/outbox`

`/api/internal/jobs`queues the registry's due jobs and`/api/internal/outbox`queues due outbox rows; a worker still has to run to do the work. Repeated calls within the same minute are harmless. Both answer 404 without the secret, so the calls must reach the backend directly, not through an edge that blocks`/api/internal/*`.

## Other platforms

Any container platform works with the published image:
- web:`ghcr.io/spaceworks-labs/spaceworks-machines-backend:<version>`with the default command (`--role backend node server.js`) and the variables in[CONFIGURATION.md](https://spaceworkslabs.tech/docs/machines/configuration/) ;
- a release or pre-deploy job: the same image with`--role migrate`;
- a background worker: the same image with`--role worker node dist/worker.js`;
- a second background process: the same image with`--role beat node dist/beat.js`, or the cron fallback above.

The worker and beat need the same settings as the web service (database, Redis, SMTP, keys); they listen on`JOBS_HEALTH_PORT`(3460) for`GET /health`, which a platform health check can use.

## Website on Netlify

Set`DEPLOYMENT_MODE=backend`and`FRONTEND_GATEWAY_SECRET`here, and`PUBLIC_APP_BASE_URL`to the website's origin; see[DEPLOYMENT_NETLIFY.md](https://spaceworkslabs.tech/docs/machines/deployment-netlify/) .

From[SpaceWorks-Machines/docs/DEPLOYMENT_CLOUD.md](https://github.com/SpaceWorks-Labs/SpaceWorks-Machines/blob/b60fee1002f713b8c045e5eca202ac17565a11ab/docs/DEPLOYMENT_CLOUD.md) at b60fee1, updated 2026-10-29.[Suggest a change](https://github.com/SpaceWorks-Labs/SpaceWorks-Machines/edit/main/docs/DEPLOYMENT_CLOUD.md)  [PreviousDeploying on a server (VPS)](https://spaceworkslabs.tech/docs/machines/deployment-vps/) [NextHosting the site on Netlify](https://spaceworkslabs.tech/docs/machines/deployment-netlify/)

On this page
- [What you need](#what-you-need)
- [Harden the database connection](#harden-the-database-connection)
- [Docker host with Compose](#docker-host-with-compose)
- [Render](#render)
- [Without a beat process (cron fallback)](#without-a-beat-process-cron-fallback)
- [Other platforms](#other-platforms)
- [Website on Netlify](#website-on-netlify)
