Files
crawl4ai/deploy/docker/README.md
UncleCode 2f15976b34 feat(docker): enhance Docker deployment setup and configuration
Add comprehensive Docker deployment configuration with:
- New .dockerignore and .llm.env.example files
- Enhanced Dockerfile with multi-stage build and optimizations
- Detailed README with setup instructions and environment configurations
- Improved requirements.txt with Gunicorn
- Better error handling in async_configs.py

BREAKING CHANGE: Docker deployment now requires .llm.env file for API keys
2025-02-01 19:33:27 +08:00

2.6 KiB

Crawl4AI Docker Setup

Quick Start

  1. Build the Docker image:

    docker build -t crawl4ai-server:prod .
    
  2. Run the container:

    docker run -d -p 8000:8000 \
      --env-file .llm.env \
      --name crawl4ai \
      crawl4ai-server:prod
    

Configuration Options

1. Using .llm.env File

Create a .llm.env file with your API keys:

OPENAI_API_KEY=sk-your-key
DEEPSEEK_API_KEY=your-deepseek-key

Run with:

docker run -d -p 8000:8000 \
  --env-file .llm.env \
  crawl4ai-server:prod

2. Direct Environment Variables

Pass keys directly:

docker run -d -p 8000:8000 \
  -e OPENAI_API_KEY="sk-your-key" \
  -e DEEPSEEK_API_KEY="your-deepseek-key" \
  crawl4ai-server:prod

3. Copy Host Environment Variables

Use the --copy-env flag to copy .llm.env from the host:

docker run -d -p 8000:8000 \
  --copy-env \
  crawl4ai-server:prod

4. Advanced: Docker Compose

Create a docker-compose.yml:

version: '3.8'
services:
  crawl4ai:
    image: crawl4ai-server:prod
    ports:
      - "8000:8000"
    env_file:
      - .llm.env
    restart: unless-stopped

Run with:

docker-compose up -d

Supported Environment Variables

Variable Description
OPENAI_API_KEY OpenAI API key
DEEPSEEK_API_KEY DeepSeek API key
ANTHROPIC_API_KEY Anthropic API key
GROQ_API_KEY Groq API key
TOGETHER_API_KEY Together API key
LLAMA_CLOUD_API_KEY Llama Cloud API key
COHERE_API_KEY Cohere API key
MISTRAL_API_KEY Mistral API key
PERPLEXITY_API_KEY Perplexity API key
VERTEXAI_PROJECT_ID Google Vertex AI project ID
VERTEXAI_LOCATION Google Vertex AI location

Healthcheck

The container includes a healthcheck:

curl http://localhost:8000/health

Troubleshooting

  1. Missing Keys: Ensure all required keys are set in .llm.env.
  2. Permissions: Run chmod +x docker-entrypoint.sh if permissions are denied.
  3. Logs: Check logs with:
    docker logs crawl4ai
    

Security Best Practices

  • Never commit .llm.env to version control.
  • Use Docker secrets in production (Swarm/K8s).
  • Rotate keys regularly.