docs.affine.pro Open in urlscan Pro
2606:4700:20::ac43:4a0d  Public Scan

URL: https://docs.affine.pro/docs/self-host-affine
Submission: On October 23 via api from IE — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

AFFiNE DocsDocs
CTRL K
GitHubGitHub
CTRL K
 * Code Of Conduct
 * Contributing
 * Core Concepts
    * Blocks that assemble your next docs, tasks kanban or whiteboard
    * Elements of AFFiNE
    * Roadmap
    * What AFFiNE is Not

 * Development
    * Architecture
       * Electron Architecture
       * Project Architecture
       * Web Architecture
   
    * Biz Modules
       * Login Module
       * Payment Module
   
    * Dev Guide
       * Commit Guide
       * Component Dev Guide
       * Dev Workflow
       * Electron Dev Guide
       * Node Dev Guide
       * Plugin Dev Guide
       * Release Guide
       * Release Note Template
       * Style Guide
       * Testing Guide
       * Web Dev Guide
   
    * Quick Start

 * Hello/Bonjour/Aloha/你好
 * Self-host AFFiNE
    * Run AFFiNE with Custom Options

System

On This Page

 * Prerequisites
 * 1 / Docker
 * 2 / Git clone the latest AFFiNE repo
 * Sign in and Sync with self-host AFFiNE
 * Storage
 * Setting up your databases
 * Upgrade Your Self-Hosted AFFiNE
 * Why my selfhosted version does not support copy & paste?

Scroll to top



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 the
   compose.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 with image:
   ghcr.io/toeverything/affine-graphql:stable , it is suggested to deploy the
   stable version, but beta and canary are also available.

> Tips: To make your AFFiNE run on a domain/ip other than localhost, please set
> AFFINE_SERVER_HOST and AFFINE_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:

 1. Open the workspace list view, and click Sign up / Sign in Button.



 1. Type the email and password, and click the Sign in button



 1. 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
> thecompose.yamlfile, 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.

Last updated on October 9, 2024
Hello/Bonjour/Aloha/你好Run AFFiNE with Custom Options
System

--------------------------------------------------------------------------------

MIT 2024 © Nextra.