HTTPS & Domains
Place a reverse proxy (nginx, Caddy, Traefik) in front. Update BETTER_AUTH_URL and NEXT_PUBLIC_BETTER_AUTH_URL to your public HTTPS domains.
This guide covers running Comp with Docker Compose. The stack includes:
| Service | Purpose | Port |
|---|---|---|
migrator |
Runs Prisma migrations against your database | - |
seeder |
Loads reference data (frameworks, controls) | - |
app |
Main Comp application | 3000 |
portal |
Customer trust portal | 3002 |
| File | Services |
|---|---|
packages/db/.env |
migrator, seeder |
apps/app/.env |
app |
apps/portal/.env |
portal |
Each service reads only its designated env file via env_file: in docker-compose.yml.
For a functional Docker deployment, you need:
DATABASE_URL="postgresql://user:pass@host:5432/db?sslmode=require"# DatabaseDATABASE_URL="postgresql://user:pass@host:5432/db?sslmode=require"
# AuthAUTH_SECRET="<openssl rand -base64 32>"SECRET_KEY="<openssl rand -base64 32>"BETTER_AUTH_URL="https://app.yourdomain.com"NEXT_PUBLIC_BETTER_AUTH_URL="https://app.yourdomain.com"NEXT_PUBLIC_PORTAL_URL="https://portal.yourdomain.com"
# EmailRESEND_API_KEY="re_..."
# Workflows (required)TRIGGER_SECRET_KEY="tr_..."
# RevalidationREVALIDATION_SECRET="<random string>"# DatabaseDATABASE_URL="postgresql://user:pass@host:5432/db?sslmode=require"
# AuthBETTER_AUTH_SECRET="<openssl rand -base64 32>"BETTER_AUTH_URL="https://portal.yourdomain.com"NEXT_PUBLIC_BETTER_AUTH_URL="https://portal.yourdomain.com"
# EmailRESEND_API_KEY="re_..."See the Environment Reference for all variables.
| Phase | Variables | How They’re Set |
|---|---|---|
| Build-time | NEXT_PUBLIC_* |
Docker build args in docker-compose.yml |
| Runtime | Everything else | Service env files (.env) |
The Dockerfile defines these build args for the app:
NEXT_PUBLIC_BETTER_AUTH_URLNEXT_PUBLIC_PORTAL_URLNEXT_PUBLIC_POSTHOG_KEYNEXT_PUBLIC_POSTHOG_HOSTNEXT_PUBLIC_IS_DUB_ENABLEDNEXT_PUBLIC_API_URLFor portal, only NEXT_PUBLIC_BETTER_AUTH_URL is used at build time.
# Copy examples to create your env filescp packages/db/.env.example packages/db/.envcp apps/app/.env.example apps/app/.envcp apps/portal/.env.example apps/portal/.env
# Edit each file with your production valuesExport the build-time variables needed by docker-compose.yml:
export BETTER_AUTH_URL="https://app.yourdomain.com"export BETTER_AUTH_URL_PORTAL="https://portal.yourdomain.com"docker compose build --no-cachedocker compose run --rm migratordocker compose run --rm seederdocker compose up -d app portalcurl -s http://localhost:3000/api/healthcurl -s http://localhost:3002/Trigger.dev runs as a hosted service. Deploy your tasks from your workstation:
cd apps/appbunx trigger.dev@latest loginbunx trigger.dev@latest deploySet TRIGGER_SECRET_KEY in apps/app/.env from your Trigger.dev project settings.
To remove all images and volumes for a clean rebuild:
docker compose down --rmi all --volumes --remove-orphansdocker builder prune --all --forceDocker Compose is configured with log rotation to prevent disk exhaustion. All services use the json-file driver with these defaults:
| Setting | Value | Description |
|---|---|---|
max-size |
10m | Rotate logs at 10 MB |
max-file |
5 | Keep up to 5 rotated files (~50 MB per service) |
compress |
true | Compress rotated files |
# Tail logs for a specific servicedocker compose logs -f app
# Tail multiple servicesdocker compose logs -f app portal
# View last 100 linesdocker compose logs --tail=100 app
# View logs for one-shot jobsdocker compose logs migratordocker compose logs seederTo adjust logging for a specific service (e.g., if app is particularly chatty), create a docker-compose.override.yml:
services: app: logging: driver: json-file options: max-size: '50m' max-file: '10' compress: 'true'HTTPS & Domains
Place a reverse proxy (nginx, Caddy, Traefik) in front. Update BETTER_AUTH_URL and NEXT_PUBLIC_BETTER_AUTH_URL to your public HTTPS domains.
Strong Secrets
Generate secrets with openssl rand -base64 32. Rotate periodically.
Database Security
Require SSL. Restrict network access via VPC, IP allowlist, or private networking.
Disk Monitoring
Monitor /var/lib/docker disk usage. Periodically prune unused containers and images.
The Dockerfile sets SKIP_ENV_VALIDATION=true at build time, so missing env vars are only caught at runtime.
Check logs to identify missing variables:
docker compose logs appdocker compose logs portalLook for errors mentioning process.env.* or “Missing env var”, then compare with the Environment Reference.
| Issue | Solution |
|---|---|
Using root .env |
Docker reads per-service env files only |
Missing DATABASE_URL |
Must be set in all three env files |
Missing TRIGGER_SECRET_KEY |
Required in apps/app/.env for workflows |
| Mismatched auth URLs | Ensure BETTER_AUTH_URL matches NEXT_PUBLIC_BETTER_AUTH_URL |
| Build args not exported | Export BETTER_AUTH_URL and BETTER_AUTH_URL_PORTAL before build |
# Check if container existsdocker compose ps -a
# View detailed logsdocker compose logs --tail=100 appDATABASE_URL format: postgresql://user:pass@host:5432/db?sslmode=requiredocker compose run --rm app sh -c "nc -zv <db-host> 5432"