Deploying Typebot with Docker and Caddy: Secure, Scalable, and Self-Hosted

by | May 16, 2025 | Articles | 0 comments

Typebot is a modern open-source platform to build conversational flows and chatbots. If you’re looking to self-host Typebot with automatic HTTPS and custom domains, this guide will show you how to do that using Docker, Caddy, and PostgreSQL.

We’ll set up a stack where everything runs in containers, and Caddy handles automatic HTTPS certificates via Let’s Encrypt.


🧱 Architecture Overview

Here’s the architecture of the deployment:

graph TD
  subgraph Docker Network
    Caddy[Caddy Gen (Reverse Proxy)] --> Builder[Typebot Builder]
    Caddy --> Viewer[Typebot Viewer]
    Builder --> DB[(PostgreSQL Database)]
    Viewer --> DB
  end
  • Caddy Gen: Auto-generates TLS certs and reverse proxy config based on container labels.
  • Typebot Builder: The backend editor where chatbot flows are created.
  • Typebot Viewer: Serves the published bots.
  • PostgreSQL: Stores all application data.

📦 Docker Compose Setup

Create a docker-compose.yml file like below:

version: '3.3'

volumes:
  db-data:

services:
  caddy-gen:
    container_name: caddy-gen
    image: 'wemakeservices/caddy-gen:latest'
    restart: always
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - "${PWD}/.typebot/caddy-certificates:/data/caddy"
    ports:
      - '80:80'
      - '443:443'
    depends_on:
      - typebot-builder
      - typebot-viewer

  typebot-db:
    image: postgres:16
    restart: always
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=typebot
      - POSTGRES_PASSWORD=typebot
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 5s
      retries: 5

  typebot-builder:
    labels:
      virtual.host: 'builder.example.com'
      virtual.port: '3000'
      virtual.tls-email: 'admin@example.com'
    image: baptistearno/typebot-builder:latest
    restart: always
    depends_on:
      typebot-db:
        condition: service_healthy
    extra_hosts:
      - 'host.docker.internal:host-gateway'
    env_file: .env

  typebot-viewer:
    labels:
      virtual.host: 'bot.example.com'
      virtual.port: '3000'
      virtual.tls-email: 'admin@example.com'
    image: baptistearno/typebot-viewer:latest
    depends_on:
      typebot-db:
        condition: service_healthy
    restart: always
    env_file: .env

🔐 HTTPS with Caddy Gen

The wemakeservices/caddy-gen container listens to Docker events and automatically generates:

  • Caddyfile configuration
  • Reverse proxy rules
  • HTTPS certificates using Let’s Encrypt

Just make sure your DNS is properly configured for builder.example.com and bot.example.com to point to your server IP.


⚙️ Environment File (.env)

Make sure you have a .env file in the same directory with values like:

envCopyEditDATABASE_URL=postgresql://postgres:typebot@typebot-db:5432/typebot
NEXTAUTH_SECRET=some-random-secret
NEXTAUTH_URL=https://builder.example.com

🚀 Starting the Stack

Run the containers with:

docker-compose up -d

Access the builder and viewer via:

  • https://builder.example.com → to create flows
  • https://bot.example.com → to serve bots

🧠 Why This Setup Rocks

  • ✅ Auto HTTPS with zero config
  • ✅ Isolated Containers for each component
  • ✅ PostgreSQL persistence with Docker volumes
  • ✅ Custom domains for builder and bots
  • ✅ Quick Restart & Portability

🔚 Final Thoughts

This deployment is a perfect starting point for self-hosting Typebot in a clean, secure, and maintainable way. You can expand this setup further with monitoring, backups, CI/CD pipelines, or even deploy it behind Cloudflare for enhanced protection.

Want to add multi-user support or analytics next? Stay tuned!


Written by

Related Posts

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *