# Marketing team self-host stack — Ghost + Listmonk + Formbricks
# Curl + run:
#   curl -O https://osalt.dev/stack/marketing-team/compose.yml
#   curl -O https://osalt.dev/stack/marketing-team/.env.example && mv .env.example .env
#   docker compose up -d
# After first 'up', initialise the listmonk schema once:
#   docker compose exec listmonk ./listmonk --install --idempotent --yes
#
# Not in this file (per stack editorial):
#   - Mautic: heavy PHP/MySQL automation suite. See
#     https://github.com/mautic/docker-mautic.
#   - Plausible Analytics: postgres + clickhouse. See
#     https://github.com/plausible/community-edition.

services:
  ghost:
    image: ghost:5.103
    restart: unless-stopped
    ports:
      - "${GHOST_PORT:-2368}:2368"
    environment:
      database__client: sqlite3
      database__connection__filename: /var/lib/ghost/content/data/ghost.db
      database__useNullAsDefault: "true"
      url: ${GHOST_URL:-http://localhost:2368}
      NODE_ENV: production
    volumes:
      - ghost_content:/var/lib/ghost/content

  listmonk-db:
    image: postgres:16-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: ${LISTMONK_DB_USER:-listmonk}
      POSTGRES_PASSWORD: ${LISTMONK_DB_PASSWORD:?set LISTMONK_DB_PASSWORD in .env}
      POSTGRES_DB: ${LISTMONK_DB_NAME:-listmonk}
    volumes:
      - listmonk_db:/var/lib/postgresql/data

  listmonk:
    image: listmonk/listmonk:v3.0.0
    restart: unless-stopped
    depends_on:
      - listmonk-db
    ports:
      - "${LISTMONK_PORT:-9000}:9000"
    environment:
      TZ: ${TZ:-UTC}
      LISTMONK_app__address: 0.0.0.0:9000
      LISTMONK_db__host: listmonk-db
      LISTMONK_db__port: "5432"
      LISTMONK_db__user: ${LISTMONK_DB_USER:-listmonk}
      LISTMONK_db__password: ${LISTMONK_DB_PASSWORD}
      LISTMONK_db__database: ${LISTMONK_DB_NAME:-listmonk}
      LISTMONK_db__ssl_mode: disable

  formbricks-db:
    image: postgres:16-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: ${FORMBRICKS_DB_USER:-formbricks}
      POSTGRES_PASSWORD: ${FORMBRICKS_DB_PASSWORD:?set FORMBRICKS_DB_PASSWORD in .env}
      POSTGRES_DB: ${FORMBRICKS_DB_NAME:-formbricks}
    volumes:
      - formbricks_db:/var/lib/postgresql/data

  formbricks:
    image: ghcr.io/formbricks/formbricks:v3.4.0
    restart: unless-stopped
    depends_on:
      - formbricks-db
    ports:
      - "${FORMBRICKS_PORT:-3002}:3000"
    environment:
      WEBAPP_URL: ${FORMBRICKS_URL:-http://localhost:3002}
      DATABASE_URL: postgres://${FORMBRICKS_DB_USER:-formbricks}:${FORMBRICKS_DB_PASSWORD}@formbricks-db:5432/${FORMBRICKS_DB_NAME:-formbricks}
      NEXTAUTH_URL: ${FORMBRICKS_URL:-http://localhost:3002}
      NEXTAUTH_SECRET: ${FORMBRICKS_NEXTAUTH_SECRET:?set FORMBRICKS_NEXTAUTH_SECRET in .env}
      ENCRYPTION_KEY: ${FORMBRICKS_ENCRYPTION_KEY:?set FORMBRICKS_ENCRYPTION_KEY in .env}
      CRON_SECRET: ${FORMBRICKS_CRON_SECRET:?set FORMBRICKS_CRON_SECRET in .env}
      MAIL_FROM: ${FORMBRICKS_MAIL_FROM:-formbricks@example.com}

volumes:
  ghost_content:
  listmonk_db:
  formbricks_db:
