Ctrl K
ComunidadGuías…

docker-compose.yml

Rama main · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
services:
  app:
    image: ${CRAWLSEO_IMAGE:-ghcr.io/crawlseo/crawlseo:latest}
    restart: always
    ports:
      - "3000:3000"
    env_file:
      - path: .env
        required: false
    depends_on:
      db:
        condition: service_healthy
    healthcheck:
      test:
        [
          "CMD",
          "node",
          "-e",
          "fetch('http://localhost:3000/api/health').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))",
        ]
      interval: 30s
      timeout: 10s
      retries: 3
    environment:
      NODE_ENV: production
      DATABASE_URL: postgresql://${POSTGRES_USER:-crawlseo}:${POSTGRES_PASSWORD:-changeme}@db:5432/${POSTGRES_DB:-crawlseo}
      # The worker service below runs crawls, syncs and the schedule; the app
      # only queues them. Without a worker, remove this line (the default,
      # inline, runs jobs in the app).
      WORKER_MODE: "off"

  # Runs queued jobs (crawls, vitals checks, GSC and Bing syncs, alerts) and
  # the schedule, from the same image. Serves no HTTP.
  worker:
    image: ${CRAWLSEO_IMAGE:-ghcr.io/crawlseo/crawlseo:latest}
    restart: always
    command: ["node", "worker.cjs"]
    env_file:
      - path: .env
        required: false
    depends_on:
      # The app runs the database migrations when it starts.
      app:
        condition: service_healthy
    # SIGTERM lets running syncs finish (WORKER_SHUTDOWN_GRACE_SECONDS, 25 s by
    # default) and puts a running crawl back in the queue.
    stop_grace_period: 40s
    healthcheck:
      # The worker touches this file while it reaches the database.
      test:
        [
          "CMD",
          "node",
          "-e",
          "process.exit(Date.now()-require('fs').statSync('/tmp/worker-alive').mtimeMs<60000?0:1)",
        ]
      interval: 30s
      timeout: 10s
      retries: 3
    environment:
      NODE_ENV: production
      DATABASE_URL: postgresql://${POSTGRES_USER:-crawlseo}:${POSTGRES_PASSWORD:-changeme}@db:5432/${POSTGRES_DB:-crawlseo}
      WORKER_MODE: worker

  db:
    image: postgres:16-alpine
    restart: always
    ports:
      # Loopback only. "5432:5432" binds every interface, so on a host with a
      # public IP this publishes Postgres to the internet — with
      # POSTGRES_PASSWORD defaulting to "changeme" a few lines below. The app
      # never uses this mapping; it reaches the database as db:5432 over the
      # compose network. It stays published on loopback so the host-side steps
      # in CONTRIBUTING.md (prisma migrate dev, psql) keep working.
      - "127.0.0.1:5432:5432"
    volumes:
      - db_data:/var/lib/postgresql/data
    environment:
      POSTGRES_DB: ${POSTGRES_DB:-crawlseo}
      POSTGRES_USER: ${POSTGRES_USER:-crawlseo}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-crawlseo}"]
      interval: 10s
      timeout: 5s
      retries: 5

volumes:
  db_data: