Install AFFiNE with Docker Compose

Docker Compose is the recommended method to self-host AFFiNE. It runs the AFFiNE server together with the services it depends on, including Postgres, Redis, migration jobs, persistent storage, and configuration.

Prerequisites

Before you start, install Docker or another Docker-compatible container service that provides the docker compose command.

Review Requirements first if you are preparing a production host.

Steps

1. Create a folder for persisted data

Create a folder where you can keep the compose file, .env file, database data, uploaded blobs, and configuration together.

mkdir affine
cd affine

2. Get the latest docker-compose.yml

Download the compose file that is tagged with the latest AFFiNE release.

wget -O docker-compose.yml https://github.com/toeverything/affine/releases/latest/download/docker-compose.yml

You can also copy the content from docker-compose.yml and put it in a manually created docker-compose.yml file in the folder from Step 1.

3. Get the .env file

A .env file is required to configure persistent volume locations, database credentials, and other required environment variables.

wget -O .env https://github.com/toeverything/affine/releases/latest/download/default.env.example

You can also copy the content from .env and put it in a manually created .env file in the folder from Step 1.

4. Edit .env before the first start

Update the .env file before starting AFFiNE for the first time. Set persistent locations and a strong database password before Postgres initializes data.

.env
# The folder for Postgres data, usually the folder from step 1 with a /postgres suffix.
DB_DATA_LOCATION=./postgres

# The folder for uploaded blobs, usually the folder from step 1 with a /storage suffix.
UPLOAD_LOCATION=./storage

# The folder for custom configuration, usually the folder from step 1 with a /config suffix.
CONFIG_LOCATION=./config

# Database credentials and database name used to initialize Postgres.
# Generate a strong password, for example with: openssl rand -base64 32
DB_USERNAME=affine
DB_PASSWORD=paste-your-generated-password-here
DB_DATABASE=affine
WARNING

Most values in the .env file should not be changed after your host has initialized and started writing data.

If you need to move the affine folder, change persistent paths, or migrate data later, follow Backup and Restore instead of editing paths casually.

5. Start the containers

docker compose up -d

6. Validate the deployment in a browser

If the deployment starts successfully, visit http://localhost:3010. Use the port you configured in .env if you changed the default port.

7. Continue after installation

After the containers are running, read After Installation to create the first admin account. For production use, also configure Domain and HTTPS, review Backup and Restore, and read Upgrade before changing versions.