Skip to content

Local Development Setup

This guide walks you through setting up the backend environment on your local machine using Docker.

  1. Create Docker Compose Override File

    Create a file named docker-compose.override.yml in the backend directory and add the following content. This file customizes the setup for local use, for example by mounting local volumes.

    services:
    caddy:
    volumes:
    - ./Caddyfile.local:/etc/caddy/Caddyfile
    - ./caddy_certs:/etc/caddy/certs
    postgres:
    volumes:
    - postgres_data:/var/lib/postgresql/data
    - ./db-init:/docker-entrypoint-initdb.d
    healthcheck:
    test: ["CMD-SHELL", "pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB"]
    plausible_events_db:
    volumes:
    - clickhouse_data:/var/lib/clickhouse
    - ./clickhouse/users.xml:/etc/clickhouse-server/users.d/users.xml:ro
  2. Create Local Caddyfile

    Create a file named Caddyfile.local and copy the contents of Caddyfile into it. In Caddyfile.local, you must disable TLS for local development by commenting out the tls directive:

    # tls /etc/caddy/certs/cert.pem /etc/caddy/certs/key.pem
  3. Create Environment File

    Create a .env file by copying the .env.example. Fill in all the required environment variables.

  4. Launch Services

    Launch Docker Desktop, then run the following command from the backend directory to start all the services in the background:

    Terminal window
    docker-compose up -d

    Once the services are running, you can access them at:

    • Directus: http://localhost:8055
    • Plausible: http://localhost:8000
  5. Export Schema Changes

    Before committing any changes to the Git repository, if you have made any modifications to the Directus schema, you must export them by running the following script:

    Terminal window
    ./snapshots/export.sh