website/src/content/docs/self-hosting/docker-compose.mdx
Create a docker-compose.yaml in your project root:
services:
rivet-engine:
image: rivetdev/engine:latest
ports:
- "6420:6420"
volumes:
- rivet-data:/data
environment:
RIVET__FILE_SYSTEM__PATH: "/data"
restart: unless-stopped
volumes:
rivet-data:
docker-compose up -d
Once the engine is running, add your app as a service in the same Compose file.
<Steps> <Step title="Create your server">Follow the quickstart to create a working server with actors.
</Step> <Step title="Create a Dockerfile">Create a Dockerfile in your project root:
FROM node:22-slim
WORKDIR /app
COPY package.json pnpm-lock.yaml ./
RUN corepack enable && pnpm install --frozen-lockfile
COPY . .
RUN pnpm build
CMD ["node", "dist/index.js"]
Update your docker-compose.yaml to include your app alongside the engine:
services:
rivet-engine:
image: rivetdev/engine:latest
ports:
- "6420:6420"
volumes:
- rivet-data:/data
environment:
RIVET__FILE_SYSTEM__PATH: "/data"
restart: unless-stopped
my-app:
build: .
environment:
RIVET_ENDPOINT: "http://default:admin@rivet-engine:6420"
depends_on:
- rivet-engine
restart: unless-stopped
volumes:
rivet-data:
RIVET_ENDPOINT tells your app to connect to the engine as a runner instead of running standalone. The URL uses the format http://namespace:token@host:port. Inside the Docker network, your app reaches the engine at rivet-engine:6420. See Endpoints for all options.
docker-compose up -d
http://localhost:6420.http://my-app:6420/api/rivet), then click Add.Register your runner programmatically via the engine API:
curl -X PUT "http://localhost:6420/runner-configs/default?namespace=default" \
-H "Content-Type: application/json" \
-d '{
"datacenters": {
"default": {
"normal": {}
}
}
}'
Mount a JSON configuration file in your docker-compose.yaml:
services:
rivet-engine:
image: rivetdev/engine:latest
ports:
- "6420:6420"
volumes:
- ./rivet-config.json:/etc/rivet/config.json:ro
- rivet-data:/data
restart: unless-stopped
volumes:
rivet-data:
Create rivet-config.json in the same directory as your docker-compose.yaml. See the Configuration docs for all available options and the full JSON Schema.
{
"postgres": {
"url": "postgresql://rivet:password@postgres:5432/rivet"
}
}
services:
postgres:
image: postgres:15
environment:
POSTGRES_DB: rivet
POSTGRES_USER: rivet
POSTGRES_PASSWORD: rivet_password
volumes:
- postgres-data:/var/lib/postgresql/data
restart: unless-stopped
rivet-engine:
image: rivetdev/engine:latest
ports:
- "6420:6420"
environment:
RIVET__POSTGRES__URL: postgresql://rivet:rivet_password@postgres:5432/rivet
depends_on:
- postgres
restart: unless-stopped
volumes:
postgres-data: