Skip to content
Start free

Services and Settings

Open in ClaudeOpen in ChatGPT

Every DocSpring Enterprise install runs the same pieces from the Docker image, whatever platform it’s on. Our deployment configs set all of this up for Docker Compose, Kubernetes, AWS ECS, Convox and Aptible. This page is for checking them, or for setting up a platform we don’t have a config for.

Run each as its own container (a Kubernetes Deployment, an ECS service, a Compose service), with the same image and settings.

ServiceCommandWhat it does
webrun_as_deploy puma -C config/puma.rbThe app, the API and the admin dashboard, on port 4001.
workerrun_as_deploy sidekiqGenerates PDFs and Word documents, and sends email and webhooks.
worker_gjrun_as_deploy good_jobAccount exports and imports (Admin API).

Every command starts with run_as_deploy, which blocks the cloud metadata address, switches to the unprivileged deploy user and runs the command under an init process that cleans up after Chromium and LibreOffice. Never leave it out.

How many of each to run, and their CPU and memory, is on the Requirements page. web and worker can run as many copies as you like; one worker_gj is enough.

web answers on port 4001 (the PORT setting):

  • /health/site answers 200 once the app has booted. Use it for liveness, readiness and your load balancer’s target health. The first boot takes up to a minute.
  • /health also checks the database, Redis and the cache. Use it for uptime monitoring, not for readiness, or a short database outage takes every web container out of service at once.

A request waits for a free web server thread, so when every thread is busy these checks can time out although the server is fine. With DOCSPRING_PUMA_READINESS_PORT set, web also answers readiness checks on that port (any path) while its worker processes are running, without waiting for a thread. It needs WEB_CONCURRENCY of 1 or more.

The workers have no HTTP port. Set your platform to restart any container that exits.

When a container is told to stop (SIGTERM), web finishes the requests it’s running and the workers finish their jobs, then they exit. Give them time:

  • web: 240 seconds, since some requests run for up to 210 seconds. Where your platform allows less (AWS Fargate allows 120), a long request that’s still running is cut off.
  • worker and worker_gj: 60 seconds. Sidekiq finishes its jobs for 25 seconds, then puts the rest back on the queue to run again.

worker_gj, the release command and the scheduled tasks need a direct connection to PostgreSQL. If DATABASE_URL points at a connection pooler such as PgBouncer in transaction mode, give those a DATABASE_URL that points at the database itself. Most installs connect directly and need nothing extra.

run_as_deploy rake db:prepare

Run it once for each new release, after you pull the new image and before the new release’s services start. On an empty database it loads the schema and creates the first admin user from DOCSPRING_ADMIN_EMAIL and DOCSPRING_ADMIN_PASSWORD; afterwards it runs the release’s database migrations. It’s safe to run again, and the services of the previous release keep working while it runs.

Three commands, run hourly, daily and weekly: see Scheduled tasks.

DocSpring is configured with environment variables. Give every service, the release command and the scheduled tasks the same ones. These are required:

SettingWhat it is
DATABASE_URLpostgres://user:password@host:5432/docspring
REDIS_URLredis://host:6379/0, or rediss:// for TLS
SECRET_KEY_BASESigns sessions and links. Generate it once with openssl rand -hex 64.
DOCSPRING_SUBMISSION_DATA_ENCRYPTION_KEYEncrypts submission data in the database. Generate it once with openssl rand -hex 32, keep a copy somewhere safe, and never change it: without it the data can’t be read.
DOCSPRING_LICENSEYour license key.
DOCSPRING_DOMAIN_NAMEThe host name people use, such as docspring.example.com. See Domains and HTTPS.

For the first install, also set DOCSPRING_ADMIN_EMAIL and DOCSPRING_ADMIN_PASSWORD (Admin users), and the settings for your file storage and email. Every other setting is optional: Environment variables lists them all.

Keep the secret ones in your platform’s secret store (Kubernetes Secrets, AWS Secrets Manager) rather than in plain configuration.

The container starts as root, so that run_as_deploy can block the cloud metadata address and switch to deploy. The app itself never runs as root. Don’t set a USER, runAsUser or runAsNonRoot.

Give the containers as few privileges as this needs:

  • Drop every Linux capability, then add back SETUID and SETGID (to switch to deploy) and KILL (so a stop signal reaches the app).
  • Add NET_ADMIN where your platform allows it. run_as_deploy uses it to add a firewall rule that blocks the cloud metadata address (169.254.169.254), so nothing in the app can read your server’s cloud credentials, even if a customer’s document exploited a bug in a document tool. Where it isn’t allowed (AWS Fargate, Aptible, a Kubernetes namespace below the privileged Pod Security level), run_as_deploy logs a warning and carries on: block that address with a Kubernetes NetworkPolicy instead, or run where it isn’t reachable, as on Fargate.
  • Don’t allow privilege escalation (allowPrivilegeEscalation: false, or Docker’s no-new-privileges), and use the runtime’s default seccomp profile.
  • Leave the root file system writable: the app writes temporary files while it makes documents.

In Docker Compose:

cap_drop: [ALL]
cap_add: [NET_ADMIN, SETUID, SETGID, KILL]
security_opt: ["no-new-privileges:true"]

In Kubernetes:

securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: [ALL]
add: [NET_ADMIN, SETUID, SETGID, KILL]
seccompProfile:
type: RuntimeDefault