SHADE is young: 0.1.0-next.2 is a pre-release, and 0.1.0 isn't out yet.

SHADE
Run SHADE

Self-hosting by hand

The reference behind Self-hosting without Coolify, where shade install and shade update do all of this for you. Read on when you run SHADE with a proxy of your own, without Docker, or want to know what each part does.

SHADE runs on any Linux server with Docker, or with plain Node.js. This page sets one up without Coolify: Postgres, Redis, SHADE's image in its three container roles (admin, which also serves the admin screens; public, the visitor routes and the content reads of server-rendered frontends; worker, the background work) and the site, behind a reverse proxy for HTTPS. Every instance has a worker: without one, scheduled publish, retention and the modules' schedules do not run, and the admin says so on every screen. Setting up an instance (Coolify) explains the parts in more detail; everything there about SHADE's settings applies here too.

Where the secrets go

SHADE has two kinds of secrets:

  • The server's own, which it needs before it can start: DATABASE_URL (and the owner's and backup role's addresses, DATABASE_OWNER_URL and DATABASE_BACKUP_URL, in files of their own below), REDIS_URL (with Redis's password) and APP_SECRET (it signs sessions and encrypts the secrets stored in the database), and the storage keys when media are on S3. They live in an env file on the server.
  • Everything else is entered in the admin, never in a file: mail and payment keys (Settings), and modules' API keys (Modules). SHADE stores them encrypted with APP_SECRET and never shows them again. A module cannot read environment variables: its package is refused when it tries.

The env file is the equivalent of WordPress's wp-config.php, kept safer:

WordPressSHADE
wp-config.php, inside the web folder, safe as long as PHP runs it instead of serving it/etc/shade/shade.env, outside the app; SHADE never serves its app folder anyway
moving it one folder up and chmod 400 are recommendationsSHADE refuses to start when other users of the server can read or change the file, or when it sits in a folder SHADE serves
keys and salts generated at installenv-file writes a new file with a generated APP_SECRET
modules' API keys stored readable in the databasestored encrypted, filled in on the Modules screen

SHADE_ENV_FILE names the file; it may name several, separated by commas (the admin reads shade.env and shade-owner.env, step 2). SHADE reads them at start, also in production, and create-admin reads it too. Variables set in the environment itself win over the file (the Docker image sets its paths that way: NODE_ENV, HOST, PORT, ADMIN_DIST, MIGRATIONS_DIR, OPERATOR_STEPS_FILE, LOCALES_DIR, MODULE_PACKAGES_DIR, STORAGE_LOCAL_ROOT, NODE_OPTIONS; leave them out of the file). The permission check works on Linux and macOS; on Windows, protect the file with its access rules.

Why a mounted file rather than Docker Compose's env_file: env_file copies the values into the container's configuration, where anyone allowed to run docker inspect reads them. A file mounted read-only keeps its permissions, and SHADE checks them.

1. The env file

On the server, with SHADE's image built (step 2) or pulled:

sudo mkdir -p /etc/shade
sudo docker run --rm --user root -v /etc/shade:/etc/shade shade node console/new-env-file.mjs /etc/shade/shade.env --url https://admin.example.com
sudo chown 1000:1000 /etc/shade/shade.env

It writes the variables to fill in, with a new APP_SECRET, readable by its owner only (chmod 600), and never overwrites a file. The container runs as user 1000 (node), hence the chown. Fill in DATABASE_URL (in the Compose file below: postgres://shade_app:<password>@postgres:5432/shade, the running role) and REDIS_URL (redis://:<redis password>@redis:6379), and check SHADE_API_URL.

Two more files, each with one line, mode 600 and owned by user 1000 like the first: shade-owner.env with DATABASE_OWNER_URL=postgres://shade:<owner password>@postgres:5432/shade, which only the admin container mounts, and shade-backup.env with DATABASE_BACKUP_URL=postgres://shade_backup:<backup password>@postgres:5432/shade, which only the worker mounts. Both name the same host, port and database as DATABASE_URL. The three roles are explained in The database's roles. From a SHADE checkout, pnpm env:new /etc/shade/shade.env --url https://admin.example.com does the same.

Keep the file in your backups, with the database: without its APP_SECRET the encrypted secrets cannot be read and everyone has to sign in again.

Two lines decide which modules may be trusted. SHADE_TRUSTED_MODULE_KEYS lists the keys whose signed server packages install. You can trust more than one key per signer: ask your module supplier for their backup key too (Keeping a signing key). SHADE_PACKAGE_APPROVAL=true also lets an admin approve a server package nobody signed, after signing in again with their password and two-factor or a passkey (Approving a server package). It is off when left out, and it lives only here: nobody can switch it on from the admin, not even with an admin's session. Switch it on only for an instance whose admins you trust to review code; switched off again, approved packages stop running at the next start.

SHADE_MODULE_CATALOGUE may point at a folder of signed module packages with a purposes.json. A new instance then asks its first admin what the site is for and preselects modules from it (Setting up a new instance). Every package still installs through the admin's checks and consent.

The team can sign in with the client's Microsoft Entra ID, Google Workspace or Keycloak: set the SHADE_OIDC_* lines for it (Identity providers). Like the approval switch, they live only here.

2. Docker Compose

The setup below runs the three container roles apart. A small instance may run them as one all container instead: the SHADE repository's deploy/compose.small.yml, with what that gives up (the small profile).

Build the images from the SHADE workspace (git clone --recurse-submodules; the site builds on SHADE's packages next to it). The workspace is for SHADE's maintainers for now, and a tested route for everyone else comes later:

docker build -f shade/apps/api/Dockerfile -t shade shade
docker build -f site/Dockerfile --target runner -t shade-site .

/srv/shade/docker-compose.yml:

services:
  postgres:
    image: postgres:18-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: postgres
      POSTGRES_DB: postgres
      POSTGRES_PASSWORD_FILE: /run/secrets/postgres-password
    volumes:
      # Postgres 18 keeps its data in /var/lib/postgresql/18/docker, inside this volume.
      - postgres-data:/var/lib/postgresql
      - /etc/shade/postgres-password:/run/secrets/postgres-password:ro
      - /etc/shade/shade-db-owner-password:/run/secrets/shade-db-owner-password:ro
      - /etc/shade/shade-db-password:/run/secrets/shade-db-password:ro
      - /etc/shade/shade-db-backup-password:/run/secrets/shade-db-backup-password:ro
      # Makes SHADE's three roles and its database on the first start (decision 0007 point 9): none a superuser.
      - /etc/shade/postgres-init.sh:/docker-entrypoint-initdb.d/10-shade-roles.sh:ro

  # Work in flight only: a password, refusing writes when full instead of evicting, nothing on disk.
  # Valkey, BSD-licensed; any server that speaks the Redis protocol works.
  redis:
    image: valkey/valkey:9.1-alpine
    restart: unless-stopped
    user: valkey
    read_only: true
    tmpfs:
      - /data
    volumes:
      - /etc/shade/redis.conf:/etc/redis.conf:ro
    command: valkey-server /etc/redis.conf

  # The team, the admin screens, the content API, MCP and uploads; it migrates the database, as the owner.
  shade:
    image: shade
    restart: unless-stopped
    depends_on: [postgres, redis]
    environment:
      SHADE_ENV_FILE: /run/shade/shade.env,/run/shade/shade-owner.env
      SHADE_API_ROLE: admin
      MIGRATE_ON_START: 'true'
    volumes:
      - /etc/shade/shade.env:/run/shade/shade.env:ro
      - /etc/shade/shade-owner.env:/run/shade/shade-owner.env:ro
      - shade-data:/app/data
    ports:
      - '127.0.0.1:4000:4000'

  # The account API (forms, accounts, checkout, plugins' public routes).
  public:
    image: shade
    restart: unless-stopped
    depends_on: [shade]
    environment:
      SHADE_ENV_FILE: /run/shade/shade.env
      SHADE_API_ROLE: public
      MIGRATE_ON_START: 'false'
      MODULE_PACKAGES_DIR: /tmp/module-packages
    volumes:
      - /etc/shade/shade.env:/run/shade/shade.env:ro
    ports:
      - '127.0.0.1:4001:4000'

  # The background work: core's and the plugins' schedules. No port: it serves only /health.
  worker:
    image: shade
    restart: unless-stopped
    depends_on: [shade]
    stop_grace_period: 40s
    environment:
      SHADE_ENV_FILE: /run/shade/shade.env,/run/shade/shade-backup.env
      SHADE_API_ROLE: worker
      MIGRATE_ON_START: 'false'
      # Its own copy of the server packages: never the admin's, which it would empty at every start.
      MODULE_PACKAGES_DIR: /tmp/module-packages
    volumes:
      - /etc/shade/shade.env:/run/shade/shade.env:ro
      # The backup role's address: only the worker takes the dump.
      - /etc/shade/shade-backup.env:/run/shade/shade-backup.env:ro
      # The media it cleans up (left-behind files, retention).
      - shade-data:/app/data

  site:
    image: shade-site
    restart: unless-stopped
    depends_on: [shade, public]
    # The site's build token reads published content only; its file is the site's own.
    env_file: /etc/shade/site.env
    environment:
      SHADE_API_URL: http://shade:4000
      ACCOUNT_API_URL: http://public:4000
    volumes:
      - site-builds:/app/site/builds
    ports:
      - '127.0.0.1:8080:8080'

volumes:
  postgres-data:
  shade-data:
  site-builds:

/etc/shade/postgres-password holds the bootstrap superuser's password, and shade-db-owner-password, shade-db-password and shade-db-backup-password the passwords of the owner shade, the running role shade_app and the backup role shade_backup (the same as in their addresses), each chmod 600 and readable by Postgres (uid 70). /etc/shade/postgres-init.sh makes the three roles and the database. None is a superuser and none may create databases or roles, so a leaked DATABASE_URL reaches SHADE's rows only, never the schema. Postgres runs it once, when its volume is new:

#!/bin/sh
set -e
psql -v ON_ERROR_STOP=1 \
  -v owner_password="$(cat /run/secrets/shade-db-owner-password)" \
  -v app_password="$(cat /run/secrets/shade-db-password)" \
  -v backup_password="$(cat /run/secrets/shade-db-backup-password)" \
  --username postgres --dbname postgres <<'SQL'
CREATE ROLE shade LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS PASSWORD :'owner_password';
CREATE ROLE shade_app LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS PASSWORD :'app_password';
CREATE ROLE shade_backup LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION BYPASSRLS PASSWORD :'backup_password';
ALTER ROLE shade_backup SET default_transaction_read_only = on;
CREATE DATABASE shade OWNER shade;
\connect shade
ALTER DEFAULT PRIVILEGES FOR ROLE shade GRANT USAGE ON SCHEMAS TO shade_app, shade_backup;
ALTER DEFAULT PRIVILEGES FOR ROLE shade GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO shade_app;
ALTER DEFAULT PRIVILEGES FOR ROLE shade GRANT USAGE, SELECT ON SEQUENCES TO shade_app;
ALTER DEFAULT PRIVILEGES FOR ROLE shade GRANT SELECT ON TABLES TO shade_backup;
ALTER DEFAULT PRIVILEGES FOR ROLE shade GRANT SELECT ON SEQUENCES TO shade_backup;
SQL

/etc/shade/redis.conf holds Redis's settings, readable by the container's valkey user (uid 999) only, with the password of REDIS_URL (letters and digits, openssl rand -hex 32):

requirepass <redis password>
maxmemory 64mb
maxmemory-policy noeviction
appendonly no
save ""

Without persistence a Redis restart loses for good only the health history of modules and features (with their unhealthy streaks), up to five minutes of request counts, and the tickets of a module approval or a take-data export in progress, which then has to be started again. Queued jobs under way are sent again from Postgres within seconds, and everything else is rebuilt.

/etc/shade/site.env holds the site's settings, filled in after step 3: SHADE_API_TOKEN (a build token), SITE_REBUILD_TOKEN (openssl rand -hex 24), SHADE_ACCOUNT_URL=https://www.example.com and ASTRO_KEY (npx astro create-key).

The variables set under environment win over the env file, so the three containers share one file and differ only in their container role. A reverse proxy in front gives HTTPS. Route as SHADE's own routes do, shown as the Caddyfile in What it sets up: the account API (/api/v1/account/*) to the public container (127.0.0.1:4001 here), everything else on the admin's address to shade (127.0.0.1:4000), the site's domain to the site (127.0.0.1:8080), and no address at all for the worker.

A server-rendered frontend on the same server reads the content API from the public container (http://127.0.0.1:4001) with a read token, so its traffic never loads the admin; the site's build keeps the admin's address, since a build token is refused there.

Point the proxy's health check at /health, the readiness answer: it is 503 while the container starts, waits for migrations, has lost Postgres or Redis, or is stopping, so no request is sent to it then. A proxy that looks containers up by name and has no health check, as the template's Caddy does, needs a different way to keep requests away from a container that is not ready. Set SHADE_HEALTH_PORT (the template uses 4001) on the container: /health and /health/live answer on that port from the start, and the API's own port opens only once the container is ready. Until then a connection to it is refused, and the proxy tries another container. Don't publish or route the health port. Without the variable there is one port, which listens at once and answers 503 starting until the container is ready. /health/live only says the process runs. A stopping container (SIGTERM) first goes on serving for SHADE_DRAIN_DELAY_MS (3 seconds), so the proxy has time to see /health turn 503 without losing a connection. Then it finishes the requests in flight and ends live streams and sockets with a notice that makes the page reconnect, all within SHADE_STOP_GRACE_MS (30 seconds; 120 on the admin and all roles, for long uploads). Give the container a stop grace above the two together (stop_grace_period: 40s, or 130s for admin and all, as in the template). The public and worker containers wait up to SHADE_MIGRATION_WAIT_MS (5 minutes) for the admin to apply the migrations of their image, so they may be started before it. With one compose file an update restarts the containers in a few seconds; for updates without a gap run more than one public container behind the proxy, and update the admin first.

Keep the proxy's idle timeout for connections to the API below the API's own. The API keeps an idle connection open for 125 seconds (KEEP_ALIVE_TIMEOUT_MS). Caddy keeps one 2 minutes, Traefik 90 seconds, nginx and AWS's load balancer about 60, so their defaults are fine. If the proxy keeps idle connections longer, it may send a request on a connection the API is just closing, and the visitor gets a 502. Then lower the proxy's timeout, or raise KEEP_ALIVE_TIMEOUT_MS above it (at most 280000).

Let the proxy pass WebSocket upgrades on the account API (/api/v1/account/*): a module may keep two-way connections with visitors (decision 0014 point 15). Caddy and Traefik do by default; nginx needs proxy_http_version 1.1;, proxy_set_header Upgrade $http_upgrade;, proxy_set_header Connection "upgrade"; and a proxy_read_timeout above 25 seconds (the API pings every 25 seconds). A stopping container closes them with code 1001 and the page opens a new one (Realtime).

Let the proxy pass large uploads to the admin's address: the media library takes a video or audio file of up to 100 MB, and up to 200 MB in one upload of several files. Caddy and Traefik pass any size by default; nginx takes 1 MB unless you set client_max_body_size 200m;.

3. First start

cd /srv/shade && docker compose up -d postgres redis shade public worker
docker compose logs shade | grep create-owner

The log line holds the address to open, https://admin.example.com/create-owner, and a one-time code that works once, for an hour (docker compose restart shade prints a new one). Open it, enter the code, your name, email address and a password, and set up two-factor or a passkey when the admin asks. From a script, docker compose exec shade node console/create-admin.mjs makes the first admin instead; it reads the same env file. Then, signed in at https://admin.example.com, as in Setting up an instance (Coolify):

  • Settings: the Site URL (https://www.example.com).
  • Modules: install and switch on the website module; in its settings the Preview address (the same address: the site container serves /preview) and the build hook http://site:8081/rebuild?token=<SITE_REBUILD_TOKEN>.
  • API tokens: a build token for the site; put it in /etc/shade/site.env.

Then start the site: docker compose up -d site.

4. Client programs (optional: shade-programs)

Only when the client runs programs of their own beside SHADE (Client programs); Setting up an instance (Coolify) explains the parts. The host holds the server's Docker socket, which is as good as root on that server: it gets no published port, and only the instance reaches it, on the compose file's network.

Build its image from a checkout of shadehq-dev/shade-programs until its first release (then use ghcr.io/shadehq-dev/shade-programs:<version>), and install gVisor's runsc for untrusted client programs (runsc install, then restart Docker). Without it, leave SHADE_PROGRAMS_GVISOR on: trusted programs run either way, and an untrusted one refuses to start until gVisor is there. off runs untrusted programs in plain containers, for development only, never on a server:

docker build -t shade-programs shade-programs

Add it to /srv/shade/docker-compose.yml, under services, and shade-programs-data: under volumes:

  # The client programs. No port: the instance reaches it on this network.
  shade-programs:
    image: shade-programs
    restart: unless-stopped
    # A fixed name: the host joins each client program's network under it, for the egress proxy.
    container_name: shade-programs
    # The Docker socket and its group (stat -c %g /var/run/docker.sock).
    group_add: ['<socket group id>']
    env_file: /etc/shade/shade-programs.env
    environment:
      # The API as the client programs reach it: the admin container, which serves the content and data APIs.
      SHADE_API_URL: http://shade:4000
      SHADE_PROGRAMS_CONTAINER: shade-programs
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - shade-programs-data:/data

/etc/shade/shade-programs.env holds SHADE_PROGRAMS_TOKEN=<openssl rand -hex 32>, chmod 600. Add the same token and the host's address to /etc/shade/shade.env, which the three SHADE containers share:

SHADE_PROGRAMS_URL=http://shade-programs:8090
SHADE_PROGRAMS_TOKEN=<the same token>

Then docker compose up -d shade-programs shade public worker. The host logs listening on 8090 and egress proxy on 3128; Programs in the admin shows no notice about the host. Every setting of the host is in shade-programs' README.

Without Docker

With Node.js 26, Postgres, Redis (Valkey or any server that speaks its protocol, with requirepass, maxmemory-policy noeviction and no persistence, as above) and a SHADE checkout in /opt/shade (pnpm install && pnpm build), a systemd template unit runs the API as its own user, once per container role:

# /etc/systemd/system/shade@.service
[Service]
User=shade
WorkingDirectory=/opt/shade/apps/api
Environment=NODE_ENV=production
Environment=SHADE_ENV_FILE=/etc/shade/shade.env
Environment=SHADE_API_ROLE=%i
EnvironmentFile=/etc/shade/%i.env
ExecStart=/usr/bin/node dist/server.mjs
Restart=on-failure
TimeoutStopSec=40

[Install]
WantedBy=multi-user.target

/etc/shade/admin.env holds PORT=4000 and MIGRATE_ON_START=true, /etc/shade/public.env PORT=4001, and /etc/shade/worker.env PORT=4002 and MODULE_PACKAGES_DIR=/var/lib/shade/worker-packages (a folder of its own). Then systemctl enable --now shade@admin shade@public shade@worker.

The env file then belongs to the shade user (sudo chown shade: /etc/shade/shade.env). Its paths default to the checkout (ADMIN_DIST, MIGRATIONS_DIR, LOCALES_DIR, STORAGE_LOCAL_ROOT relative to apps/api); the admin's unit migrates on start, or run the migrate console command after each update (Console commands).

What SHADE refuses at start

ProblemMessage (abridged)
SHADE_ENV_FILE names no fileSHADE_ENV_FILE … does not exist
other users can read or change it… can be read or changed by every user of the server (mode 644): run chmod 600 …
its group can change it… can be changed by its group (mode 660): run chmod 600 …
it sits in a folder SHADE serves (admin files, uploads, server packages)… is inside …, which SHADE serves: keep it outside every served folder
a required variable is missing or invalid[config] APP_SECRET: APP_SECRET must be at least 32 characters and the like
REDIS_URL is missing, or has no password[config] REDIS_URL: REDIS_URL is required: every instance has a Redis … / … needs the password Redis is started with …
Redis does not answer (or refuses the password)Cannot reach Redis at redis://:***@redis:6379: … Check REDIS_URL and its password …

Details

  • Media storage: STORAGE_DRIVER=local (default) keeps files under STORAGE_LOCAL_ROOT (a Docker volume in production), written atomically (temp file then rename), empty month folders tidied on delete, keys with .., backslashes, absolute paths or empty segments refused. STORAGE_DRIVER=s3: any S3-compatible bucket, SHADE signing its own requests (no SDK; decision 0008 point 13); STORAGE_S3_BUCKET, _REGION, _ENDPOINT, _ACCESS_KEY_ID, _SECRET_ACCESS_KEY, _FORCE_PATH_STYLE, _PREFIX; .env.example has examples for Scaleway (nl-ams), Hetzner (fsn1), Cloudflare R2 and AWS; the app refuses to start when bucket, keys or STORAGE_PUBLIC_BASE_URL are missing; objects get Cache-Control: public, max-age=31536000, immutable (SVGs also Content-Disposition: attachment); each call times out after 30 seconds; errors never contain credentials. Public URLs: STORAGE_PUBLIC_BASE_URL, or ${SHADE_API_URL}/uploads when empty (local only). With the local driver the admin serves /uploads/*: only jpg, jpeg, png, webp, avif, gif, svg, pdf, woff2, cached for a year, nosniff, a default-src 'none' CSP for images and fonts (the SVG policy for SVGs), Cross-Origin-Resource-Policy: cross-origin so /preview can load them, fonts also Access-Control-Allow-Origin: *. With S3 give the bucket a CORS rule allowing GET from the site's origin, or the preview shows the fallback font; with S3 /uploads serves nothing; the public API role answers 404 on /uploads. The site build downloads from SHADE_MEDIA_BASE_URL, or ${SHADE_API_URL}/uploads when empty; with S3 it must be set to the bucket's public URL.