Skip to content

Docker Compose ​

The Compose file, deploy/selfhosted.compose.yml, runs the server with its own PostgreSQL and Redis on one host, with deploy/Caddyfile.selfhosted beside it for HTTPS. The Quickstart has both files in full and walks through a first start; this page is what the file contains and how to run it in production.

Drawing the diagram…

The services of the Compose file. PostgreSQL and Redis are on an internal network that only the server reaches.

Start it ​

deploy/.env holds the only values the file needs:

sh
echo "POSTGRES_PASSWORD=$(openssl rand -hex 24)" > deploy/.env
echo "JOOBQUI_SELF_HOSTED_DOMAIN=jobs.example.com" >> deploy/.env
echo "JOOBQUI_SELF_HOSTED_IMAGE=ghcr.io/azutoolkit/joobqui-selfhosted:vX.Y.Z" >> deploy/.env
docker compose -f deploy/selfhosted.compose.yml --env-file deploy/.env --profile https up -d

Then finish the setup page. It offers the bundled Redis and PostgreSQL already; type the PostgreSQL password from deploy/.env.

Profiles ​

ProfileAddsNeeds
httpsCaddy on ports 80 and 443, with a certificate from Let's EncryptJOOBQUI_SELF_HOSTED_DOMAIN pointing at the host

Your own workers do not go in this file: Deploy a worker has a Compose file for them.

Without https, the server instances listen on loopback ports 4100 to 4109 (JOOBQUI_SELF_HOSTED_PORTS): put your own TLS proxy in front, and read TLS and proxies for the header setting that goes with it.

What the file sets for you ​

  • Hardening. The server runs as UID 10001 with a read-only file system, no Linux capabilities and no-new-privileges. It writes only to /data and a 16 MB /tmp.
  • Stopping. stop_grace_period is 60 seconds, above the 20 seconds an orderly shutdown may take.
  • Redis. Append-only persistence and maxmemory-policy noeviction, so a full Redis refuses writes instead of dropping jobs.
  • Volumes. selfhosted_data (/data), selfhosted_postgres, selfhosted_redis, and Caddy's certificates. The first three are what you back up: see Backups and retention.
  • The client address. JOOBQUI_CLIENT_IP_HEADER is X-Real-IP, which Caddy overwrites on every request. With another proxy, or none, change it in deploy/.env: see TLS and proxies.

Every variable of deploy/.env is in the Configuration reference.

More instances ​

Once setup is finished, set JOOBQUI_SELF_HOSTED_REPLICAS in deploy/.env and run up -d again. The instances share /data; Caddy finds them through Docker's DNS and sends requests round robin. See Scale the server.

Moving a running stack to JoobQ 0.8 ​

A release on JoobQ 0.8 keeps its Redis keys under joobq:v1:. Changing the image tag and running up -d neither stops every old process first nor migrates the old keys. Instead stop the SDK workers (let them report to the old server, or wait for their leases to expire), then the Compose services, keep postgres and redis running, pull the new image (an older one does not know the task and answers Unknown task), and migrate with a one-shot container:

sh
docker compose -f deploy/selfhosted.compose.yml --env-file deploy/.env stop app
docker compose -f deploy/selfhosted.compose.yml --env-file deploy/.env --profile worker --profile join-worker stop worker join-worker
docker compose -f deploy/selfhosted.compose.yml --env-file deploy/.env pull app
docker compose -f deploy/selfhosted.compose.yml --env-file deploy/.env run --rm app ./joobqui keyspace:migrate --dry-run
docker compose -f deploy/selfhosted.compose.yml --env-file deploy/.env run --rm app ./joobqui keyspace:migrate --all-found

Run the last command only after the dry run lists nothing but your own queues: on a Redis shared with another application, name your queues with --queue NAME instead of --all-found. Without --queue, --all-found or --leave-unnamed the task stops (exit 1) when it finds lists nobody named. Then up -d. What the task refuses, and its flags, are in Moving to JoobQ 0.8.

Moving from an earlier Compose file ​

Earlier Compose files passed DATABASE_URL, REDIS_URL, SESSION_SECRET and JOOBQUI_SDK_TOKEN as Docker secrets and ran a migrate service. The current file passes none of them. For a deployment that already runs, either keep your earlier file, or move to the new one and keep the secrets it already has: set SESSION_SECRET (and JOOBQUI_SECRETS_KEY and JOOBQUI_PAYLOAD_KEYS if you set them) on the app service as before. The setup page generates only the secrets the environment does not set; new ones would sign everybody out and leave the secrets sealed with the old keys unreadable. Enter the same PostgreSQL and Redis on the setup page (or keep their variables too), and save the SDK token on the Settings → Security page.