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.
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.
Create a folder where you can keep the compose file, .env file, database data, uploaded blobs, and configuration together.
Download the compose file that is tagged with the latest AFFiNE release.
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.
A .env file is required to configure persistent volume locations, database credentials, and other required environment variables.
You can also copy the content from .env and put it in a manually created .env file in the folder from Step 1.
Update the .env file before starting AFFiNE for the first time. Set persistent locations and a strong database password before Postgres initializes data.
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.
If the deployment starts successfully, visit http://localhost:3010. Use the port you configured in .env if you changed the default port.
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.