Self-Hosting AFFiNE.pro on a Docker VPS: The Ultimate Privacy-First Notion and Miro Alternative
Introduction: The Quest for the Unified Workspace
In the modern digital workspace, professionals often find themselves caught between two distinct paradigms of productivity. On one hand, structured, text-heavy data relies on platforms like Notion for documentation, wikis, and database management. On the other hand, brainstorming, visual planning, and collaborative design demand the spatial freedom of canvas-based tools like Miro.
While utilizing both tools is a common practice, it introduces friction. Context-switching between tabs disrupts focus, data becomes siloed, and subscription fees compound rapidly. More importantly, for enterprises handling proprietary data or strict privacy compliance, relying on proprietary cloud providers introduces significant security concerns. Enter AFFiNE.pro—the next-generation, open-source knowledge base designed to bridge this exact gap. By self-hosting AFFiNE on a private Virtual Private Server (VPS) using Docker, organizations can achieve complete data sovereignty without sacrificing the modern UX of top-tier SaaS platforms.
What is AFFiNE.pro and Why Choose It?
AFFiNE.pro positions itself as an all-in-one workspace that refuses to force users to choose between a document and a whiteboard. Built with a privacy-first ethos, it allows teams to visualize, shape, and manage their ideas freely. Unlike traditional applications that treat text documents and whiteboards as separate files, AFFiNE introduces a unique dual-mode philosophy.
Key Features of AFFiNE
- Page Mode vs. Edgeless Mode: With a single click, any document can transition from a clean, structured text editor (Page Mode) into an infinite canvas (Edgeless Mode) where blocks can be arranged, linked, and drawn over visually.
- Privacy-First Architecture: Your data belongs to you. AFFiNE stores data locally by default or securely on your self-hosted server using conflict-free replicated data types (CRDTs) for seamless syncing.
- Modern Block Editor: Move, transform, and style content elements effortlessly, enjoying a user experience that rivals or exceeds Notion's ease of use.
- Open Source and Extensible: Fully auditable code means no vendor lock-in and the flexibility to scale the platform according to business needs.
The Benefits of Self-Hosting on a Docker VPS
Deploying AFFiNE on a dedicated VPS using Docker offers distinct operational advantages over cloud-hosted alternatives:
- Absolute Data Control: Perfect for legal, financial, or healthcare sectors requiring strict compliance with data residency laws.
- Cost Optimization: Avoid per-user monthly SaaS fees. A standard, affordable VPS can host an instance accessible by your entire team.
- Simplified Maintenance: Utilizing Docker containers ensures environment isolation, making updates, backups, and migrations straightforward and reliable.
Prerequisites for the Deployment
Before initiating the installation process, ensure your environment meets the following baseline technical criteria:
- VPS Server: A virtual server running a clean installation of a modern Linux distribution (Ubuntu 22.04 LTS or Debian 12 recommended).
- Hardware Specs: Minimum 2 vCPUs, 4GB RAM, and 20GB of available SSD storage to handle concurrent access smoothly.
- Domain Name: A registered domain or subdomain (e.g.,
affine.yourcompany.com) with A/AAAA records pointed to your VPS IP address. - Software: Docker Engine (v20.10+) and Docker Compose (v2.0+) installed on the host machine.
Step-by-Step Guide: Deploying AFFiNE via Docker Compose
Follow these structured steps to configure and launch your self-hosted AFFiNE instance using an enterprise-grade configuration.
Step 1: System Preparation and Directory Setup
Connect to your VPS via SSH and create a dedicated project directory to maintain clean organizational structure on your host machine:
ssh root@your_vps_ip
mkdir -p /opt/affine
cd /opt/affineStep 2: Designing the Docker Compose Configuration
AFFiNE relies on a self-hosted backend infrastructure, including a relational database (PostgreSQL) and a storage layer (Redis or local block storage). Create a docker-compose.yml file using your preferred text editor:
nano docker-compose.ymlPaste the following optimized configuration. This setup provisions the core AFFiNE container alongside a PostgreSQL database for robust data management:
Note: Ensure you replace placeholder values like YOUR_STRONG_PASSWORD with secure, randomly generated keys before running the container.version: '3.8'
services:
postgres:
image: postgres:15-alpine
container_name: affine_postgres
environment:
POSTGRES_USER: affine
POSTGRES_PASSWORD: YOUR_STRONG_PASSWORD
POSTGRES_DB: affine_db
volumes:
- pg_data:/var/lib/postgresql/data
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U affine -d affine_db"]
interval: 10s
timeout: 5s
retries: 5
affine:
image: ghcr.io/toeverything/affine-graphql:stable
container_name: affine_app
depends_on:
postgres:
condition: service_healthy
ports:
- "3010:3010"
environment:
- NODE_ENV=production
- AFFINE_SERVER_PORT=3010
- DATABASE_URL=postgresql://affine:YOUR_STRONG_PASSWORD@postgres:5432/affine_db
- [email protected]
- AFFINE_ADMIN_PASSWORD=YOUR_ADMIN_PASSWORD
volumes:
- affine_data:/root/.affine
restart: unless-stopped
volumes:
pg_data:
affine_data:Step 3: Launching the Applications
With the file successfully configured, pull the official Docker images and launch the containers in detached mode:
docker compose up -dVerify that all components are operating nominally by inspecting the logs and checking the container status:
docker compose psSecuring Your Instance with an Nginx Reverse Proxy and Let's Encrypt
Running an enterprise workspace requires robust security encryption. Passing unencrypted traffic over standard HTTP exposes sensitive company data. We will utilize Nginx and Certbot to implement SSL/TLS encryption.
1. Install Nginx
Install the Nginx web server on the host machine to handle incoming traffic routing:
sudo apt update
sudo apt install nginx -y2. Configure the Virtual Host
Create a dedicated configuration block for your AFFiNE deployment:
sudo nano /etc/nginx/sites-available/affineInsert the following proxy configuration, directing traffic securely to internal port 3010:
server {
listen 80;
server_name affine.yourdomain.com;
location / {
proxy_pass [http://127.0.0.1:3010](http://127.0.0.1:3010);
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket support for real-time sync
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}Enable the site configuration and restart Nginx to apply changes:
sudo ln -s /etc/nginx/sites-available/affine /etc/nginx/sites-enabled/
sudo systemctl restart nginx3. Obtain an SSL Certificate
Deploy Let's Encrypt automated certificates via Certbot to mandate secure HTTPS communication:
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d affine.yourdomain.comFollow the interactive prompts to finalize the SSL certificate issuance. Certbot will automatically rewrite your Nginx configuration to enforce encrypted connections via HTTPS.
Optimizing AFFiNE for Enterprise Operations
Deploying the software is only the initial step. Maintaining data resilience and robust performance over time requires adhering to operational best practices.
Automated Backup Strategies
Data loss is unacceptable in a production business environment. Implement a daily cron job to dump your PostgreSQL database and back up the persistent volume directories safely. A robust script should compress the database state and export it to an off-site, secure S3-compatible cloud storage bucket.
Updating the Platform Seamlessly
The open-source community actively maintains and enhances AFFiNE. To update your installation to the latest stable release with minimal downtime, execute the following sequence:
cd /opt/affine
docker compose pull
docker compose up -d --remove-orphansConclusion: The Future of Sovereignty in Corporate Knowledge Bases
By shifting away from restrictive SaaS contracts and deploying AFFiNE.pro on a private Docker VPS, your enterprise gains an edge in productivity, agility, and absolute data compliance. You effectively dismantle the walls separating documents from design layouts, providing your teams with a comprehensive canvas tailored for modern business execution. Take ownership of your workflow data today and experience a unified environment completely controlled by your organization.
