Quick start
Build the image
- Installs Firefox dependencies (GTK, DBus, ALSA, X11 libs)
- Installs fonts (Liberation, Noto Color Emoji)
- Downloads and installs yt-dlp for fast YouTube transcripts
- Pre-downloads the pinned Camoufox browser binary (~300MB)
- Installs Node.js dependencies
- Copies server code
Build time is ~5 minutes on first run. Subsequent builds are faster due to layer caching.
Run the container
http://localhost:9377.
Test the deployment
browserConnected: false is normal - the browser launches lazily on first request.
Dockerfile overview
The Dockerfile is optimized for production use:- Pinned Camoufox version via build args (update
CAMOUFOX_VERSIONto upgrade) - Pre-baked browser binary eliminates first-run download
- Production npm install skips dev dependencies
- 128MB V8 heap limit keeps memory usage low (override with
MAX_OLD_SPACE_SIZE)
Environment variables
Pass environment variables with-e flags:
Common variables
See the environment variables reference for all options.
Volume mounts
Cookie files
To use cookie import, mount the cookies directory::ro flag makes the mount read-only for security.
Persistent cache (optional)
Camofox caches browser data in/root/.cache/camoufox. This is baked into the image, but you can override it:
Memory limits
Set Docker memory limits to prevent OOM kills:- Idle: 50-100MB
- 1 tab open: 200-300MB
- 5 tabs open: 400-600MB
- 10 tabs open: 800MB-1GB
CPU limits
Limit CPU usage to prevent resource exhaustion on shared hosts:Fly.io deployment
Fly.io is a global edge platform for running Docker containers.Setup
1
Install flyctl
2
Login to Fly.io
3
Create app
In the Choose a name and region. Fly will detect the Dockerfile and create
camofox-browser directory:fly.toml.4
Set secrets
5
Deploy
https://your-app.fly.dev.fly.toml configuration
The includedfly.toml is pre-configured:
- auto_stop_machines: Shuts down when idle (saves costs)
- auto_start_machines: Wakes on incoming request
- min_machines_running = 0: Scales to zero when unused
Scaling on Fly.io
Scale horizontally:Railway deployment
Railway is a platform-as-a-service with GitHub integration.Setup
1
Connect GitHub repo
- Go to railway.app
- Click “New Project” → “Deploy from GitHub repo”
- Select your
camofox-browserfork
2
Configure variables
In the Railway dashboard:
- Go to your service → Variables
- Add:
CAMOFOX_API_KEY=your-secret-keyCAMOFOX_PORT=3000MAX_SESSIONS=20
3
Deploy
Railway auto-detects the Dockerfile and deploys. Access your app at the generated URL.
railway.toml configuration
The includedrailway.toml configures the build:
Custom cloud providers
Google Cloud Run
AWS ECS / Fargate
- Push image to ECR:
- Create task definition with environment variables
- Create service in ECS cluster
Azure Container Instances
Health checks
All platforms should configure health checks: Endpoint:GET /health
Expected response: 200 OK
- Interval: 30 seconds
- Timeout: 10 seconds
- Unhealthy threshold: 3 consecutive failures
Logging
Camofox outputs structured JSON logs to stdout:Troubleshooting
Container fails to start
Symptoms: Container exits immediately Check logs:- Missing dependencies (check Dockerfile)
- Port conflict (change host port:
-p 9378:3000) - Memory limit too low (increase to 512MB minimum)
Browser launch timeout
Symptoms: Requests fail with “Browser launch timeout (30s)” Causes:- Insufficient memory (increase
--memory) - Insufficient CPU (increase
--cpus) - Missing system libraries
Out of memory (OOM)
Symptoms: Container killed by OOM killer Causes:- Too many concurrent sessions
- Memory limit too low