Self-host AFFiNE
Install the self-host version of AFFiNE
Deploy with Sealos |
---|
Prerequisites
1 / Docker
We provide a quick way to start Docker, so you need to install Docker first. For installation instructions on different versions of Docker, you can try visiting the Docker installation documentation.
You must have docker as well as docker compose
installed and available on your machine.
2 / Git clone the latest AFFiNE repo
git clone https://github.com/toeverything/AFFiNE.git --branch stable
You can also download just the compose.yaml
file directly from the AFFiNE repository at this path: ./.github/deployment/self-host/compose.yaml
.
Quick start
All your need for self-host version of AFFiNE:
docker compose -f ./.github/deployment/self-host/compose.yaml up
As you can see:
-
./.github/deployment/self-host/compose.yaml
: is the path to the compose file within the AFFiNE repository. Should you opt to download only thecompose.yml
, make sure to adjust the file path accordingly to match the location of your downloaded file. -
In your
compose.yaml
, you can choose your target deploy version withimage: ghcr.io/toeverything/affine-graphql:stable
, it is suggested to deploy the stable version, butbeta
andcanary
are also available.
Tips: To make your AFFiNE run on a domain/ip other than
localhost
, please setAFFINE_SERVER_HOST
andAFFINE_SERVER_PORT
, refer to Run AFFiNE with Custom Options
Sign in and Sync with self-host AFFiNE
After your Docker has started, you will see the following message:
To access your AFFiNE on the web, open Chrome and enter the URL: http://localhost:3010
. To ensure data security, sign in to your self-hosted AFFiNE Cloud account by following these steps:
-
Open the workspace list view, and click
Sign up / Sign in
Button.
-
Type the email and password, and click the
Sign in
button
-
Switch to the
Cloud sync
Workspace
Data Persistance
When everything is up and running, you should be able to see three instance related to AFFiNE:
-
Postgre
-
Redis
-
AFFiNE self-host
As you can see, the self-host version of AFFiNE contains everything it takes to self-host the AFFiNE Cloud. Keep in mind that, you must login to your self-hosted AFFiNE Cloud to store your data into the database. Otherwise, your data in the default local-workspace will be stored as cache in the browser and is risky of losing. Make sure that you have turned them into cloud workspaces to enable syncing to postgres.
Connect AFFiNE Client to self-host AFFiNE Cloud isn’t available yet. You can use the web version while we are working on it.
More custom options
For more information about configuring custom domains, email servers, databases, etc. please refer to Run AFFiNE with Custom Options.
Storage
Setting up your databases
By default, a redis as well as postgre instance will be download and composed ready out of the box. If you prefer to use your own redis or postgre instance, you can make sure AFFiNE is properly pointed by the section given below:
environment:
- REDIS_SERVER_HOST=redis
- DATABASE_URL=postgres://affine:affine@postgres:5432/affine
Redis and Postgres is used for your database. Your data will be kept in the path given in the volumn
section within the YAML file. Please keep these directory safe to prevent from losing your data.
volumes:
# custom configurations
- ~/.affine/self-host/config:/root/.affine/config
# blob storage
- ~/.affine/self-host/storage:/root/.affine/storage
Upgrade Your Self-Hosted AFFiNE
Upgrading your self-hosted Affine system is a straightforward process that can be accomplished in a few steps. Follow this guide to ensure a smooth and error-free upgrade process.
Before starting, back up your
compose.yaml
file and all important data to prevent any loss in case the upgrade encounters issues.
Download the New compose.yaml
File
Download the latest compose.yaml
file from here, replacing the existing file on your server.
Important Note: If you have previously modified configurations in the
compose.yaml
file, remember to migrate those changes to the new file. This may include, but is not limited to, environment variables, port numbers, volume configurations, etc.
Pull the New Docker Image
Execute the following command to pull the new Docker image:
docker compose -f compose.yaml pull
This step will download the latest version of the AFFiNE image based on the updated compose.yaml
file.
Restart the Service
use the following command to stop the currently running service (if any) and start the service with the new version:
docker compose -f compose.yaml up
This command stops all related containers based on the compose.yaml
file configuration and restarts them with the latest version.
Upgrade Complete
You have successfully upgraded your self-hosted Affine system.
Q&A
Why my selfhosted version does not support copy & paste?
Unfortunately, due to the restriction of browsers, many features like Clipboard only work under Secure Contexts (i.e. HTTPS or localhost). I would recommend you either setup your own CA, or proxy the server to the localhost.You can set the flag in Chrome to disable the Secure Contexts in the trusted sources. Input the chrome://flags/#unsafely-treat-insecure-origin-as-secure in URL to set.
End
Want more self-hosting options? You can contribute code to the AFFiNE repository.