docker.recipes

AFFiNE Workspace

intermediate

Next-gen knowledge base combining docs, whiteboards, and databases.

Overview

AFFiNE is an open-source, next-generation knowledge management platform that combines the functionality of Notion, Miro, and Airtable into a single unified workspace. Built with a local-first approach, AFFiNE allows users to create and organize documents, whiteboards, and databases while maintaining complete control over their data. The platform features block-based editing, real-time collaboration, and the ability to seamlessly switch between different content types within the same workspace. This Docker deployment sets up a complete AFFiNE workspace environment using three essential services: the main AFFiNE GraphQL server for the application logic and user interface, a PostgreSQL database for persistent data storage and complex relational queries, and Redis for high-performance caching and session management. The AFFiNE container serves the web interface on port 3010 and handles all workspace operations, while PostgreSQL manages structured data integrity and Redis provides fast access to frequently used information and real-time features. This configuration is ideal for teams and organizations seeking a self-hosted alternative to proprietary productivity suites, developers wanting full control over their knowledge base infrastructure, and privacy-conscious users who prefer to keep their intellectual property on their own servers. The combination of AFFiNE's versatile editing capabilities with PostgreSQL's robust data management and Redis's performance optimization creates a powerful foundation for collaborative knowledge work.

Key Features

  • Block-based editor supporting rich text, tables, databases, and whiteboard elements in unified documents
  • Real-time collaborative editing with conflict resolution and live cursor tracking
  • Dual-mode interface allowing seamless switching between page and whiteboard views
  • Local-first architecture with automatic synchronization and offline capability
  • Advanced database views with filtering, sorting, and multiple display formats (table, kanban, calendar)
  • Template system for creating reusable document and workspace structures
  • Full-text search across all content types including text, database entries, and whiteboard objects
  • Version history and change tracking for all workspace content

Common Use Cases

  • 1Team knowledge bases combining technical documentation with visual brainstorming boards
  • 2Project management workflows using database views for task tracking and whiteboards for planning
  • 3Educational content creation with interactive lessons combining text, diagrams, and structured data
  • 4Personal productivity systems integrating note-taking, task management, and creative thinking
  • 5Software development teams managing requirements, architecture diagrams, and project documentation
  • 6Research organizations organizing literature reviews, data collection, and collaborative analysis
  • 7Small business operations managing processes, customer information, and strategic planning

Prerequisites

  • Docker and Docker Compose installed with minimum 2GB RAM available for all services
  • Port 3010 available for AFFiNE web interface access
  • At least 5GB free disk space for PostgreSQL data, Redis cache, and AFFiNE configuration storage
  • DB_PASSWORD environment variable configured for PostgreSQL authentication
  • Basic understanding of workspace and collaboration tool concepts
  • Web browser with JavaScript enabled for accessing the AFFiNE interface

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 affine:
3 image: ghcr.io/toeverything/affine-graphql:stable
4 container_name: affine
5 environment:
6 - NODE_ENV=production
7 - AFFINE_CONFIG_PATH=/root/.affine/config
8 - REDIS_SERVER_HOST=redis
9 - DATABASE_URL=postgres://affine:${DB_PASSWORD}@db:5432/affine
10 - NODE_OPTIONS="--import=./scripts/register.js"
11 - AFFINE_SERVER_HOST=0.0.0.0
12 - AFFINE_SERVER_PORT=3010
13 volumes:
14 - affine-config:/root/.affine/config
15 - affine-data:/root/.affine/storage
16 ports:
17 - "3010:3010"
18 depends_on:
19 - db
20 - redis
21 networks:
22 - affine-network
23 restart: unless-stopped
24
25 db:
26 image: postgres:15-alpine
27 container_name: affine-db
28 environment:
29 - POSTGRES_USER=affine
30 - POSTGRES_PASSWORD=${DB_PASSWORD}
31 - POSTGRES_DB=affine
32 volumes:
33 - postgres-data:/var/lib/postgresql/data
34 networks:
35 - affine-network
36 restart: unless-stopped
37
38 redis:
39 image: redis:7-alpine
40 container_name: affine-redis
41 volumes:
42 - redis-data:/data
43 networks:
44 - affine-network
45 restart: unless-stopped
46
47volumes:
48 affine-config:
49 affine-data:
50 postgres-data:
51 redis-data:
52
53networks:
54 affine-network:
55 driver: bridge

.env Template

.env
1# AFFiNE
2DB_PASSWORD=secure_affine_password

Usage Notes

  1. 1Web UI at http://localhost:3010
  2. 2Combines docs, whiteboards, databases
  3. 3Local-first with sync support
  4. 4Notion/Miro alternative
  5. 5Block-based editing

Individual Services(3 services)

Copy individual services to mix and match with your existing compose files.

affine
affine:
  image: ghcr.io/toeverything/affine-graphql:stable
  container_name: affine
  environment:
    - NODE_ENV=production
    - AFFINE_CONFIG_PATH=/root/.affine/config
    - REDIS_SERVER_HOST=redis
    - DATABASE_URL=postgres://affine:${DB_PASSWORD}@db:5432/affine
    - NODE_OPTIONS="--import=./scripts/register.js"
    - AFFINE_SERVER_HOST=0.0.0.0
    - AFFINE_SERVER_PORT=3010
  volumes:
    - affine-config:/root/.affine/config
    - affine-data:/root/.affine/storage
  ports:
    - "3010:3010"
  depends_on:
    - db
    - redis
  networks:
    - affine-network
  restart: unless-stopped
db
db:
  image: postgres:15-alpine
  container_name: affine-db
  environment:
    - POSTGRES_USER=affine
    - POSTGRES_PASSWORD=${DB_PASSWORD}
    - POSTGRES_DB=affine
  volumes:
    - postgres-data:/var/lib/postgresql/data
  networks:
    - affine-network
  restart: unless-stopped
redis
redis:
  image: redis:7-alpine
  container_name: affine-redis
  volumes:
    - redis-data:/data
  networks:
    - affine-network
  restart: unless-stopped

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 affine:
5 image: ghcr.io/toeverything/affine-graphql:stable
6 container_name: affine
7 environment:
8 - NODE_ENV=production
9 - AFFINE_CONFIG_PATH=/root/.affine/config
10 - REDIS_SERVER_HOST=redis
11 - DATABASE_URL=postgres://affine:${DB_PASSWORD}@db:5432/affine
12 - NODE_OPTIONS="--import=./scripts/register.js"
13 - AFFINE_SERVER_HOST=0.0.0.0
14 - AFFINE_SERVER_PORT=3010
15 volumes:
16 - affine-config:/root/.affine/config
17 - affine-data:/root/.affine/storage
18 ports:
19 - "3010:3010"
20 depends_on:
21 - db
22 - redis
23 networks:
24 - affine-network
25 restart: unless-stopped
26
27 db:
28 image: postgres:15-alpine
29 container_name: affine-db
30 environment:
31 - POSTGRES_USER=affine
32 - POSTGRES_PASSWORD=${DB_PASSWORD}
33 - POSTGRES_DB=affine
34 volumes:
35 - postgres-data:/var/lib/postgresql/data
36 networks:
37 - affine-network
38 restart: unless-stopped
39
40 redis:
41 image: redis:7-alpine
42 container_name: affine-redis
43 volumes:
44 - redis-data:/data
45 networks:
46 - affine-network
47 restart: unless-stopped
48
49volumes:
50 affine-config:
51 affine-data:
52 postgres-data:
53 redis-data:
54
55networks:
56 affine-network:
57 driver: bridge
58EOF
59
60# 2. Create the .env file
61cat > .env << 'EOF'
62# AFFiNE
63DB_PASSWORD=secure_affine_password
64EOF
65
66# 3. Start the services
67docker compose up -d
68
69# 4. View logs
70docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/affine-workspace/run | bash

Troubleshooting

  • AFFiNE interface shows connection errors: Verify Redis and PostgreSQL containers are running and check DATABASE_URL environment variable format
  • Slow page loading and editing performance: Increase Redis memory allocation or check for Redis memory pressure warnings
  • Database connection failures on startup: Ensure DB_PASSWORD environment variable matches between affine and db services
  • Real-time collaboration features not working: Check Redis container logs for connection issues and verify REDIS_SERVER_HOST configuration
  • Workspace data not persisting after container restart: Verify affine-data and postgres-data volumes are properly mounted and accessible
  • Port 3010 access denied or connection refused: Check if port is already in use and verify AFFINE_SERVER_HOST is set to 0.0.0.0

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space