Implementation:AFK surf Open agent Docker Compose Stack
| Knowledge Sources | |
|---|---|
| Domains | Deployment, Docker, Self_Hosting |
| Last Updated | 2026-10-25 00:00 GMT |
Overview
Concrete Docker Compose stack that runs Open-Agent with a pgvector Postgres, a Redis cache, a one-shot app-init migration job, and the long-running app server on port 3010.
Description
'docker-compose.yml defines four services: postgres (pgvector/pgvector:pg16) with a POSTGRES_DB=open_agent database, bind-mounted ./database volume, and a pg_isready healthcheck; redis (redis:7-alpine) with a ./cache volume and a redis-cli ping healthcheck; app-init (the Open-Agent image) which runs yarn predeploy once (SERVER_FLAVOR=script, restart: 'no) to apply migrations/seed; and app (the Open-Agent image) on port 3010, depending on healthy data services and a successful app-init. Both app services bind-mount ./config.json to /app/config.json and read DATABASE_URL and REDIS_SERVER_HOST from the environment. The image tag is ghcr.io/afk-surf/open-agent:${VERSION:-canary}.
Usage
Copy this file into a dedicated deploy directory alongside config.json, edit config.json with secrets, then run docker compose up -d postgres redis followed by docker compose up app-init and docker compose up app (or docker compose up -d to start everything in dependency order).
Code Reference
Source Location
- Repository: Open-Agent
- File: .docker/docker-compose.yml (L1-61); deploy instructions in README.md (L38-55)
Signature
services:
postgres:
image: pgvector/pgvector:pg16
environment: { POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD }
volumes: [./database:/var/lib/postgresql/data]
healthcheck: pg_isready
redis:
image: redis:7-alpine
volumes: [./cache:/data]
healthcheck: redis-cli ping
app-init:
image: ghcr.io/afk-surf/open-agent:${VERSION:-canary}
environment: [SERVER_FLAVOR=script, DATABASE_URL, REDIS_SERVER_HOST]
volumes: [./config.json:/app/config.json]
command: yarn predeploy
depends_on: [postgres healthy, redis healthy]
restart: 'no'
app:
image: ghcr.io/afk-surf/open-agent:${VERSION:-canary}
environment: [NODE_ENV, DATABASE_URL, REDIS_SERVER_HOST]
ports: ['3010:3010']
volumes: [./config.json:/app/config.json]
depends_on: [postgres healthy, redis healthy, app-init completed]
restart: unless-stopped
Import
# Copy into a deploy directory:
cp .docker/docker-compose.yml ./docker-compose.yml
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| config.json | file | Yes | Bind-mounted at /app/config.json (validated against schema.json) |
| VERSION | env | Image tag; defaults to 'canary' | |
| Docker daemon | runtime | Yes | Docker Engine + Compose |
Outputs
| Name | Type | Description |
|---|---|---|
| postgres | container | Healthy pgvector DB on the internal network |
| redis | container | Healthy Redis cache |
| app | container | Open-Agent reachable on host port 3010 |
Usage Examples
Start the Full Stack
# From the deploy directory (with config.json + docker-compose.yml):
docker compose up -d # starts postgres, redis, app-init, app in order
docker compose logs -f app # tail app logs
docker compose down # stop everything (data persists in ./database and ./cache)
Start Step by Step
docker compose up -d postgres redis # data services
docker compose up app-init # run migrations once
docker compose up -d app # launch the app on :3010
Related Pages
Implements Principle
Requires Environment
- Environment:AFK_surf_Open_agent_Docker_Engine
- Environment:AFK_surf_Open_agent_Postgres_Pgvector
- Environment:AFK_surf_Open_agent_Redis