Skip to main content

Notesnook sync server (local storage)

Notesnook Self-Hosted Installation Guide

Overview

This guide will help you set up a self-hosted instance of Notesnook, a secure note-taking application, using Docker Compose.


Prerequisites

  • Linux server with Docker and Docker Compose installed.
  • Domain name with the ability to create subdomains.
  • Basic understanding of terminal commands.
  • Ports 5264, 6264, 7264, 8264, and 9009 available.

1. Directory Structure Setup

Create the required directories:

# Create data directories
mkdir -p /srv/Files/Notesnook/db
mkdir -p /srv/Files/Notesnook/s3
mkdir -p /srv/Files/Notesnook/setup

2. Configuration Files

2.1. Environment File

Create the .env file:

cd /srv/Files/Notesnook/setup
nano .env

Add the following content (modify the values accordingly):

# Instance Configuration
INSTANCE_NAME=My Notesnook
DISABLE_SIGNUPS=false
NOTESNOOK_API_SECRET=your_secure_api_secret_here

# SMTP Configuration
SMTP_USERNAME=your_email@domain.com
SMTP_PASSWORD=your_smtp_password
SMTP_HOST=smtp.your-server.com
SMTP_PORT=587

# Public URLs (replace domain.com with your domain)
AUTH_SERVER_PUBLIC_URL=https://auth.domain.com
NOTESNOOK_APP_PUBLIC_URL=https://notes.domain.com
MONOGRAPH_PUBLIC_URL=https://mono.domain.com
ATTACHMENTS_SERVER_PUBLIC_URL=https://files.domain.com

# MinIO Configuration
MINIO_ROOT_USER=admin
MINIO_ROOT_PASSWORD=your_secure_password_here

2.2. Docker Compose File

Create the docker-compose.yml file:

nano docker-compose.yml

Paste the following content:

version: '3.8'
services:
  notesnook-db:
    image: mongo:7.0.12
    volumes:
      - /srv/Files/Notesnook/db:/data/db
    ports:
      - "5264:27017"

  notesnook-s3:
    image: minio/minio:RELEASE.2024-07-29T22-14-52Z
    environment:
      - MINIO_ROOT_USER=admin
      - MINIO_ROOT_PASSWORD=your_secure_password_here
    volumes:
      - /srv/Files/Notesnook/s3:/data
    command: server /data
    ports:
      - "9009:9000"

  # Add other services as needed

3. Docker Images Preparation

Pull all required images to avoid timeout issues:

cd /srv/Files/Notesnook/setup
docker pull mongo:7.0.12
docker pull minio/minio:RELEASE.2024-07-29T22-14-52Z
docker pull streetwriters/identity:latest
docker pull streetwriters/notesnook-sync:latest
docker pull streetwriters/sse:latest
docker pull streetwriters/monograph:latest
docker pull vandot/alpine-bash

4. Deployment

Start the services:

cd /srv/Files/Notesnook/setup
docker compose up -d

5. Service Verification

5.1. Check Container Status

docker compose ps

Expected status:

  • Running containers:
    • notesnook-db
    • notesnook-s3
    • identity-server
    • notesnook-server
    • sse-server
    • monograph-server
  • Completed containers (should show Exit 0):
    • validate
    • initiate-rs0
    • setup-s3

5.2. Check Logs

docker compose logs

5.3. Test MinIO Access

Visit: http://your-server:9009


6. Reverse Proxy Configuration

Example Nginx configuration:

# Identity Server
server {
    server_name auth.domain.com;
    location / {
        proxy_pass http://localhost:8264;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

# Notesnook Server
server {
    server_name notes.domain.com;
    location / {
        proxy_pass http://localhost:5264;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

# Monograph Server
server {
    server_name mono.domain.com;
    location / {
        proxy_pass http://localhost:6264;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

# MinIO Server
server {
    server_name files.domain.com;
    location / {
        proxy_pass http://localhost:7264;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

7. Useful Commands

Service Management

# View real-time logs
docker compose logs -f

# View logs for specific service
docker compose logs [service-name]

# Restart specific service
docker compose restart [service-name]

# Stop all services
docker compose down

# Update services
docker compose pull
docker compose up -d

8. Maintenance

8.1. Backup

Regularly backup these directories:

  • /srv/Files/Notesnook/db/ (MongoDB data)
  • /srv/Files/Notesnook/s3/ (MinIO data)
  • /srv/Files/Notesnook/setup/.env (Configuration)

8.2. Updates

To update all services:

cd /srv/Files/Notesnook/setup
docker compose down
docker compose pull
docker compose up -d

9. Troubleshooting

Common Issues:

Service won't start

  • Check logs: docker compose logs [service-name]
  • Verify port availability.
  • Check directory permissions.
  • Verify environment variables.

Database Connection Issues

  • Ensure MongoDB replica set is initialized.
  • Check MongoDB logs: docker compose logs notesnook-db.

Storage Issues

  • Verify MinIO credentials.
  • Check MinIO logs: docker compose logs notesnook-s3.

Email Not Working

  • Verify SMTP settings in .env.
  • Check identity-server logs.

10. Directory Structure

/srv/Files/Notesnook/
├── db/                 # MongoDB data
├── s3/                 # MinIO data
└── setup/              # Configuration files
    ├── .env
    └── docker-compose.yml

Security Notes

  • Change default passwords in .env.
  • Use strong passwords for MinIO and API secret.
  • Keep your .env file secure.
  • Regularly update all services.
  • Enable HTTPS on your reverse proxy.
  • Consider implementing fail2ban.
  • Regularly monitor logs for suspicious activity.

Support

If you encounter issues: