Skip to content

Commit 9f13dd7

Browse files
committed
improvement(self-hosting): tighten compose docs and guard update against in-container uploads
1 parent b7d308d commit 9f13dd7

19 files changed

Lines changed: 206 additions & 133 deletions

‎apps/docs/content/docs/platform/self-hosting/architecture.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ The chart can also render the optional `copilot` service, its separate PostgreSQ
7474
| **Secrets** | `ENCRYPTION_KEY`, `API_ENCRYPTION_KEY`, `BETTER_AUTH_SECRET`, `INTERNAL_API_SECRET`, `CRON_SECRET` | Secret manager and separate recovery copies |
7575

7676
<Callout type="error">
77-
The production Compose file keeps local uploads in the `sim_uploads` volume on its host; the Helm chart mounts no volume for them, so without cloud storage or your own volume, recreating an app pod loses those files. Local files are also invisible to other replicas. Configure [object storage](/platform/self-hosting/object-storage) before storing durable files or scaling.
77+
Without object storage, uploads are local: Compose keeps them in the `sim_uploads` volume on one host, and the Helm chart keeps them on each pod, lost when it is recreated. Configure [object storage](/platform/self-hosting/object-storage) before storing durable files or scaling.
7878
</Callout>
7979

8080
<Callout type="error">

‎apps/docs/content/docs/platform/self-hosting/docker.mdx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ Set `CRON_SECRET` for scheduled work. Without it, the cron service prints instru
6969

7070
### 2. Configure durable uploads
7171

72-
Without object storage, the app stores uploads in `/app/apps/sim/uploads`. The production Compose file mounts the `sim_uploads` volume there, so files survive container recreation and updates. The volume is still local to this host: it is not shared across hosts or app replicas, and it needs its own backup. A one-shot `uploads-init` service makes the volume writable by the app user before the app starts.
72+
Without object storage, the app stores uploads in the `sim_uploads` volume, so they survive container recreation and updates. It stays on this host and needs its own backup. A one-shot `uploads-init` service makes it writable by the app user.
7373

7474
Follow [Object storage](/platform/self-hosting/object-storage) for AWS S3, Azure Blob, or Google Cloud Storage.
7575

7676
#### Existing installs: keep uploads from before the volume
7777

78-
Compose files from before `sim_uploads` stored local uploads inside the app container, and recreating it discards them. Copy them out before you switch to the new Compose file or run `npx sim-setup update`, then copy them into the volume:
78+
If your install predates the `sim_uploads` volume, uploads live inside the app container and recreating it discards them. Copy them out before switching to the new Compose file or running `npx sim-setup update`, then copy them in:
7979

8080
```bash
8181
docker compose -f docker-compose.prod.yml cp simstudio:/app/apps/sim/uploads ./uploads-backup
@@ -133,7 +133,7 @@ sim.yourdomain.com {
133133

134134
Route `/socket.io` to realtime on 3002 and other requests to the app on 3000. The 250 MB decimal Caddy limit clears the configured 220 MiB deployed-chat cap, but the app's current Next.js proxy buffer still limits matching requests to 10 MiB. See [Request size limits](/platform/self-hosting/networking#request-size-limits) before increasing payload sizes. `flush_interval -1` explicitly disables response buffering; Caddy already flushes SSE immediately. It also keeps the upstream request running if the client disconnects. See [Caddy streaming behavior](https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#streaming).
135135

136-
When the proxy runs on the same host, set `SIM_APP_PUBLISH=127.0.0.1:3000` and `SIM_REALTIME_PUBLISH=127.0.0.1:3002` in `.env` so the app and realtime are reachable only through it. Change only the bind address, not the ports: `sim-setup` checks the app on 3000 and realtime on 3002.
136+
When the proxy runs on the same host, set `SIM_APP_PUBLISH=127.0.0.1:3000` and `SIM_REALTIME_PUBLISH=127.0.0.1:3002` in `.env` so the app and realtime are reachable only through it. Keep the ports; `sim-setup` checks 3000 and 3002.
137137

138138
This example assumes Caddy runs on the Docker host. A containerized proxy needs reachable Compose service addresses instead of its own `localhost`. For Nginx, Traefik, cloud load balancers, or separate socket hosts, see [Networking](/platform/self-hosting/networking).
139139

‎apps/docs/content/docs/platform/self-hosting/environment-variables.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ Most enterprise features read their settings from the organization that owns a w
236236

237237
## File storage
238238

239-
By default Sim writes uploads to local disk. Production Compose keeps them in the `sim_uploads` volume on its host; the default Helm chart mounts no upload directory, so configure cloud storage or a persistent local layout there before retaining files. See [Object storage](/platform/self-hosting/object-storage) for the full setup, bucket layout, and IAM policy.
239+
By default Sim writes uploads to local disk. See [Object storage](/platform/self-hosting/object-storage) for the setup, bucket layout, and IAM policy.
240240

241241
| Variable | Description |
242242
|----------|-------------|

‎apps/docs/content/docs/platform/self-hosting/index.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ These are sizing suggestions, not enforced minimums or capacity guarantees. The
5050
- Verify [background jobs](/platform/self-hosting/background-jobs), including the scheduler's `CRON_SECRET`.
5151

5252
<Callout type="warn">
53-
Local uploads live on the Docker host (the `sim_uploads` volume on Compose) and are not shared across hosts; on Kubernetes without object storage, recreating an app pod loses them. Losing an encryption key makes the data encrypted with it unreadable. A database backup does not replace file storage or key backups.
53+
A database backup does not cover local uploads or encryption keys; back them up separately. Losing an encryption key makes the data encrypted with it unreadable.
5454
</Callout>
5555

5656
Run [Verify your install](/platform/self-hosting/verify) before opening the deployment to your team and after upgrades or restores.

‎apps/docs/content/docs/platform/self-hosting/upgrades.mdx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ ghcr.io/simstudioai/migrations
2727
Keep `app`, `realtime`, and `migrations` on the same release. They share a schema; mismatched versions can expect missing columns or incompatible behavior. An application-only rollback needs verified compatibility with the migrated schema.
2828
</Callout>
2929

30-
The production Compose file's app healthcheck calls `/api/health`, which images have served since v0.6.1. An install pinned to an older `SIM_VERSION` never reports healthy with it: upgrade, or keep the Compose file you already run.
31-
3230
<Tabs items={['Kubernetes (Helm)', 'Docker Compose']}>
3331
<Tab value="Kubernetes (Helm)">
3432

@@ -174,11 +172,13 @@ install uses:
174172

175173
Inspect the result with `npx sim-setup logs`, which targets whichever Compose file the install uses.
176174

175+
If your install predates the `sim_uploads` volume, copy its uploads out first: see [keep uploads from before the volume](/platform/self-hosting/docker#existing-installs-keep-uploads-from-before-the-volume). `sim-setup update` stops and asks before recreating an app container that still holds uploads.
176+
177177
`docker-compose.prod.yml` requires `POSTGRES_PASSWORD`. If you manage the file yourself and Compose stops with `required variable POSTGRES_PASSWORD is missing a value`, confirm which password initialized the existing database volume. If it was never set, the old default was `postgres`; restore that value first, then see [Postgres on Compose](/platform/self-hosting/security#postgres-on-compose) to rotate it.
178178

179179
Before updating a pinned production install, replace `SIM_VERSION` in `.env` with the chosen release tag. The update command pulls that configured tag; it does not automatically advance a pin.
180180

181-
The CLI detects only those two files. A stack started with the `docker-compose.ollama.yml` overlay is detected as a `docker-compose.prod.yml` install, and `update` upgrades its Sim services through that file alone, keeping `OLLAMA_URL` from `.env`. It does not touch the Ollama container. To refresh the Ollama image as well, run the update with both files:
181+
The CLI detects installs by those two files. For a stack started with more files, such as the `docker-compose.ollama.yml` overlay, `update` applies every file the stack was started with and saves the set as `COMPOSE_FILE` in `.env`, so it still applies after `docker compose down`. Compose does not record profiles, so the profile-scoped Ollama service is updated only when `.env` sets `COMPOSE_PROFILES` (for example `COMPOSE_PROFILES=gpu`). Otherwise refresh it by hand:
182182

183183
```bash
184184
# The Ollama service is profile-scoped, so pass the profile you installed

‎apps/docs/content/docs/platform/self-hosting/verify.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ docker compose -f docker-compose.prod.yml logs cron
9999
curl -fsS http://localhost:3000/api/health
100100
```
101101

102-
Expect `simstudio`, `realtime`, `db`, `redis`, and `cron` to be running, with `migrations` completed successfully. Without `CRON_SECRET`, the cron service exits instead of running schedules.
102+
Expect `simstudio`, `realtime`, `db`, `redis`, and `cron` to be running, with `migrations` and `uploads-init` completed successfully. Without `CRON_SECRET`, the cron service exits instead of running schedules.
103103

104104
## Read failures [#reading-the-failures]
105105

‎docker-compose.local.yml‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ services:
3737
# resolve, which it does not on Linux by default.
3838
extra_hosts:
3939
- 'host.docker.internal:host-gateway'
40-
# Local file storage. The image creates this directory for the app user, so
41-
# a new volume starts out writable.
40+
# Local file storage; the image creates the directory for the app user.
4241
volumes:
4342
- sim_uploads:/app/apps/sim/uploads
4443
depends_on:
@@ -50,8 +49,6 @@ services:
5049
condition: service_completed_successfully
5150
realtime:
5251
condition: service_healthy
53-
# The first probe runs one interval after start, so a long interval makes
54-
# `up -d` look hung for minutes.
5552
healthcheck:
5653
test: ['CMD', 'curl', '-fsS', 'http://127.0.0.1:3000/api/health']
5754
interval: 15s

‎docker-compose.prod.yml‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ services:
77
# so one variable drives all three. Set SIM_VERSION in .env to upgrade.
88
image: ghcr.io/simstudioai/simstudio:${SIM_VERSION:-latest}
99
restart: unless-stopped
10-
# Set SIM_APP_PUBLISH=127.0.0.1:3000 in .env when a reverse proxy on this
11-
# host fronts the app, so it is not also reachable directly. Change only the
12-
# bind address, not the port: sim-setup probes the app on 3000.
10+
# Set SIM_APP_PUBLISH=127.0.0.1:3000 in .env to expose the app only to a proxy on this host. Keep port 3000; sim-setup probes it.
1311
ports:
1412
- '${SIM_APP_PUBLISH:-3000}:3000'
1513
deploy:
@@ -61,8 +59,7 @@ services:
6159
# resolve, which it does not on Linux by default.
6260
extra_hosts:
6361
- 'host.docker.internal:host-gateway'
64-
# Local file storage (the default when no cloud storage is configured).
65-
# Survives container recreation; it is still local to this host.
62+
# Local file storage when no cloud storage is configured; kept on this host.
6663
volumes:
6764
- sim_uploads:/app/apps/sim/uploads
6865
depends_on:
@@ -76,9 +73,6 @@ services:
7673
condition: service_completed_successfully
7774
realtime:
7875
condition: service_healthy
79-
# The first probe runs one interval after start, and cron waits on this
80-
# check, so a long interval makes `up -d` look hung for minutes. /api/health
81-
# exists from v0.6.1; an older pinned SIM_VERSION never reports healthy.
8276
healthcheck:
8377
test: ['CMD', 'curl', '-fsS', 'http://127.0.0.1:3000/api/health']
8478
interval: 15s
@@ -123,9 +117,7 @@ services:
123117
retries: 3
124118
start_period: 30s
125119

126-
# Hands the uploads volume to the app's non-root user. A new named volume is
127-
# owned by root unless the image already ships the directory, which images
128-
# built before it did not; this keeps those pinned versions writable too.
120+
# Makes the uploads volume writable by the app's non-root user, for images that do not create the directory themselves.
129121
uploads-init:
130122
image: ghcr.io/simstudioai/simstudio:${SIM_VERSION:-latest}
131123
user: '0:0'

‎docker/app.Dockerfile‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,7 @@ RUN mkdir -p apps/sim/.next/cache apps/sim/.next/server/route-cache && \
261261
chmod 1777 /tmp
262262
VOLUME ["/tmp", "/app/apps/sim/.next/cache", "/app/apps/sim/.next/server/route-cache"]
263263

264-
# Local file storage (UPLOAD_DIR_SERVER). Created here so a named volume mounted
265-
# on it starts out owned by the app user; it is not a VOLUME, so nothing is kept
266-
# unless the deployment mounts one.
264+
# Owned by the app user so a named volume mounted here starts writable.
267265
RUN mkdir -p apps/sim/uploads && chown nextjs:nodejs apps/sim/uploads
268266

269267
# Switch to non-root user

‎packages/sim-setup/src/arguments.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ describe('parseSetupArguments', () => {
1616
})
1717
})
1818

19+
it('accepts --yes only for update', () => {
20+
expect(parseSetupArguments(['update', '--yes'])).toEqual({
21+
kind: 'lifecycle',
22+
command: 'update',
23+
yes: true,
24+
})
25+
expect(() => parseSetupArguments(['stop', '--yes'])).toThrow('stop does not accept: --yes')
26+
})
27+
1928
it.each([
2029
[['--url', 'sim.example.com'], 'is not a URL'],
2130
[['--url', 'ftp://sim.example.com'], 'must use http or https'],

0 commit comments

Comments
 (0)