Skip to main content

Overview

The Conformly.ai backend runs as a set of Docker containers: FastAPI backend, Celery workers, Redis, and optional monitoring tools.

Architecture

Quick Start

1. Prerequisites

  • Docker and Docker Compose installed
  • .env file configured in conformly-core/

2. Environment Setup

cd conformly-core
cp env.example .env
# Edit .env with your Supabase, Stripe, and AI credentials

3. Build and Start

docker compose up -d

4. Verify

docker compose ps                    # Check status
docker compose logs -f backend       # Watch logs
curl http://localhost:8000/health     # Test health

Services

Backend API

  • Port: 8000
  • Health check: http://localhost:8000/health
  • API docs: http://localhost:8000/docs
  • Hot reload: Enabled via --reload — code changes take effect immediately (source is volume-mounted)
The development docker-compose.yml overrides the Dockerfile CMD to add --reload:
backend:
  command: ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000",
            "--reload", "--proxy-headers", "--forwarded-allow-ips", "*"]
  volumes:
    - .:/app

Redis

  • Port: 6379
  • Purpose: Message broker and result backend for Celery, caching

Celery Worker

  • Purpose: Executes background analysis tasks (gap analysis, completeness, checklist, traceability)
  • Scaling: docker compose up -d --scale celery-worker=3

Celery Beat

  • Purpose: Scheduled periodic tasks (cleanup, maintenance)

Flower (Optional)

Monitor Celery tasks:
docker compose --profile monitoring up -d
Access at http://localhost:5555.

Key Docker Compose Configuration

The docker-compose.yml overrides Redis URLs so that containers communicate via the Docker network:
backend:
  environment:
    - REDIS_URL=redis://redis:6379/0
    - CELERY_BROKER_URL=redis://redis:6379/0
    - CELERY_RESULT_BACKEND=redis://redis:6379/0
  env_file:
    - .env
You do not need to change REDIS_URL in .env — the Docker Compose environment block takes precedence.

Restarting After Changes

Code changes are picked up automatically via --reload. .env changes require a container restart:
docker compose up -d --force-recreate backend
Dependency changes (requirements.txt) require a rebuild:
docker compose build backend
docker compose up -d

Production Deployment

For production (e.g., EC2), use the production compose file or override the command to remove --reload:
# docker-compose.prod.yml
backend:
  command: ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000",
            "--proxy-headers", "--forwarded-allow-ips", "*"]
Additional production steps:
  1. Set ENVIRONMENT=production and DEBUG=false in .env
  2. Update ALLOWED_ORIGINS to production domains
  3. Update STRIPE_SUCCESS_URL and STRIPE_CANCEL_URL to production URLs
  4. Configure reverse proxy (nginx) with SSL/TLS
  5. Use Docker secrets for sensitive values
  6. Set up monitoring and log aggregation

Proxy Headers

When behind a reverse proxy (nginx, Cloudflare, AWS ALB), the --proxy-headers and --forwarded-allow-ips="*" flags ensure FastAPI correctly detects HTTPS and client IPs. Your nginx config should pass forwarded headers:
location / {
    proxy_pass http://127.0.0.1:8000;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $host;
}

Production Deployment Guide

Learn about production deployment best practices