Saltar a contenido

Firecrawl

Scraper web self-hosted con soporte de JavaScript rendering. Node.js + Redis + RabbitMQ + PostgreSQL. Sin autenticación (USE_DB_AUTHENTICATION=false). RAM ~2-4GB. Sin puerto expuesto al host (solo interno en red ai_shared).

📁 Rutas y configs

Qué Dónde
Compose /opt/docker/firecrawl/compose.yaml
Variables de entorno /opt/docker/firecrawl/.env

Contenedores: firecrawl-api, firecrawl-redis, firecrawl-playwright, firecrawl-rabbitmq, firecrawl-postgres Puerto: 3002 (solo interno, no expuesto al host)

🔗 Integración

Firecrawl se comunica con LibreChat a través de la red compartida ai_shared:

  • URL interna: http://firecrawl-api:3002
  • API Key: self-hosted (dummy, sin autenticación)
  • Red: ai_shared (externa, compartida entre librechat y firecrawl)

Config en .env de LibreChat:

FIRECRAWL_API_KEY=self-hosted
FIRECRAWL_API_URL=http://firecrawl-api:3002

🧱 Stack de servicios

Servicio Imagen Función
firecrawl-api ghcr.io/firecrawl/firecrawl:latest API + worker harness
firecrawl-redis redis:alpine Cola de jobs (BullMQ)
firecrawl-playwright ghcr.io/firecrawl/playwright-service:latest Renderizado JS
firecrawl-rabbitmq rabbitmq:3-management-alpine Mensajería entre workers
firecrawl-postgres ghcr.io/firecrawl/nuq-postgres:latest Metadatos

🛠️ Comandos útiles

# Ver logs
docker logs -f firecrawl-api
docker logs -f firecrawl-playwright
docker logs -f firecrawl-redis

# Reiniciar servicio individual
docker restart firecrawl-api

# Recrear todo el stack
cd /opt/docker/firecrawl && docker compose down && docker compose up -d

# Verificar containers activos
docker compose -f /opt/docker/firecrawl/compose.yaml ps

# Test de salud (desde cualquier container en ai_shared)
docker run --rm --network ai_shared curlimages/curl -s http://firecrawl-api:3002/v1/scrape \
  -H 'Content-Type: application/json' \
  -d '{"url": "https://example.com"}'

# Ver cola de jobs (Bull Queue UI)
# http://firecrawl-api:3002/admin/CHANGEME/queues (solo desde ai_shared)

🧪 Test rápido

# Desde el host, usando un container temporal
docker run --rm --network ai_shared alpine:latest sh -c '
  apk add -q curl
  curl -s -X POST http://firecrawl-api:3002/v1/scrape \
    -H "Content-Type: application/json" \
    -d "{\"url\": \"https://httpbin.org/get\"}"
'

💾 Backups

# Backup de config
sudo tar czf /tmp/firecrawl-config-$(date +%F).tar.gz /opt/docker/firecrawl/{compose.yaml,.env}

Firecrawl no almacena datos persistentes críticos — Redis, RabbitMQ y PostgreSQL tienen datos temporales y pueden reconstruirse.

⚙️ Tareas comunes

Actualizar Firecrawl:

cd /opt/docker/firecrawl
docker compose pull
docker compose up -d

Cambiar recursos (RAM/CPU): Editar el compose.yaml y agregar deploy.resources.limits en cada servicio según necesidad.

Deshabilitar Firecrawl temporalmente:

cd /opt/docker/firecrawl && docker compose down
LibreChat seguirá funcionando, pero el web search dará resultados sin contenido extraído (solo snippets de SearXNG).

🔥 Problemas comunes

Problema Solución
Error: connect ECONNREFUSED redis:6379 Redis no arrancó. Verificar logs de firecrawl-redis
Error: connect ECONNREFUSED rabbitmq:5672 RabbitMQ no está listo. Esperar healthcheck. docker logs firecrawl-rabbitmq
Query was empty o resultados vacíos Playwright no responde. Verificar firecrawl-playwright
LibreChat no encuentra Firecrawl Verificar que ambos estén en ai_shared: docker network inspect ai_shared
Firecrawl consume mucha RAM Limitar en compose.yaml: mem_limit: 2G para firecrawl-api y firecrawl-playwright
scrapers lentos o timeouts Aumentar recursos de firecrawl-api (más CPU/RAM) o reducir MAX_CONCURRENT_JOBS