Docker Compose is the recommended way to self-host AFFiNE.
Install Docker with Docker Compose v2. You should be able to run:
Keep this directory in a stable location. The official Compose file stores PostgreSQL data under ./data/postgres, uploaded files under ./data/storage, and application configuration under ./config.
You can also copy the file from docker-compose.yml.
config/config.jsonOpen config/config.json and set server.externalUrl to the URL that users will open. For a local installation, the default is:
For a public deployment, use the final HTTPS URL, for example https://affine.example.com. See Configuration for more options.
New installations do not need a
.envfile. Runtime settings belong inconfig/config.json; the Compose file already contains the internal service wiring and uses relative data directories.
The one-time migration container should finish successfully, while AFFiNE, PostgreSQL, and Redis remain running. To inspect startup problems:
Open http://localhost:3010, or the URL configured in server.externalUrl, and create the initial administrator account.

Read After Installation before exposing the instance publicly, and Upgrade before changing the image version. Back up both ./data and ./config; do not delete or relocate either directory after the instance contains data unless you are following the backup and restore guide.