name: karakeep
services:
  karakeep:
    image: ghcr.io/karakeep-app/karakeep:${KARAKEEP_VERSION:-0.34.1}
    restart: unless-stopped
    ports:
      - "127.0.0.1:${KARAKEEP_PORT:-3000}:3000"
    environment:
      DATA_DIR: /data
      NEXTAUTH_URL: ${KARAKEEP_URL:-http://localhost:3000}
      NEXTAUTH_SECRET: ${KARAKEEP_AUTH_SECRET:?Set KARAKEEP_AUTH_SECRET}
      AUTH_TRUSTED_ORIGINS: ${KARAKEEP_URL:-http://localhost:3000}
      DISABLE_SIGNUPS: ${KARAKEEP_DISABLE_SIGNUPS:-true}
      MEILI_ADDR: http://meilisearch:7700
      MEILI_MASTER_KEY: ${KARAKEEP_MEILI_KEY:?Set KARAKEEP_MEILI_KEY}
      BROWSER_WEB_URL: http://chrome:9222
      CRAWLER_FULL_PAGE_ARCHIVE: "true"
      TZ: ${TZ:-Etc/UTC}
    volumes:
      - data:/data
    depends_on:
      meilisearch:
        condition: service_healthy
      chrome:
        condition: service_healthy
    healthcheck:
      test: [CMD, node, -e, "fetch('http://127.0.0.1:3000/api/health').then(async r=>{if(!r.ok||(await r.json()).status!=='ok')process.exit(1)}).catch(()=>process.exit(1))"]
      interval: 15s
      timeout: 10s
      retries: 20
      start_period: 90s
    security_opt:
      - no-new-privileges:true
    stop_grace_period: 60s
  chrome:
    image: ghcr.io/karakeep-app/karakeep-chrome:154.0.8037.57-r1
    restart: unless-stopped
    init: true
    command:
      - --disable-gpu
      - --disable-dev-shm-usage
      - --hide-scrollbars
      - --disable-blink-features=AutomationControlled
      - --window-size=1440,900
    healthcheck:
      test: [CMD-SHELL, "wget -qO- http://127.0.0.1:9222/json/version | grep -q webSocketDebuggerUrl"]
      interval: 15s
      timeout: 5s
      retries: 10
    security_opt:
      - no-new-privileges:true
  meilisearch:
    image: getmeili/meilisearch:v1.41.0
    restart: unless-stopped
    environment:
      MEILI_ENV: production
      MEILI_NO_ANALYTICS: "true"
      MEILI_MASTER_KEY: ${KARAKEEP_MEILI_KEY:?Set KARAKEEP_MEILI_KEY}
    volumes:
      - search:/meili_data
    healthcheck:
      test: [CMD-SHELL, "curl --fail --silent http://127.0.0.1:7700/health | grep -Eq '\"status\"[[:space:]]*:[[:space:]]*\"available\"'"]
      interval: 15s
      timeout: 5s
      retries: 10
    security_opt:
      - no-new-privileges:true
    stop_grace_period: 60s
volumes:
  data:
  search:
