Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 0 additions & 72 deletions .env

This file was deleted.

85 changes: 85 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Notesnook Sync Server Configuration
# Copy this file to .env and fill in your values

# ===== REQUIRED CONFIGURATION =====

# Instance name for your Notesnook server
# Used in client apps for identification purposes
# Example: notesnook-instance-sg
INSTANCE_NAME=My Notesnook Server

# Secret key for API authentication (generate a strong random string)
# Must be a randomly generated token (preferably >32 characters)
# Generate with: openssl rand -base64 32
NOTESNOOK_API_SECRET=your-super-secret-api-key-here

# Whether to disable new user registrations (true/false)
# Use this to prevent new account creation if exposed to Internet
DISABLE_SIGNUPS=false

# SMTP Email Configuration (required for user notifications)
# Username for SMTP connection (usually your email address)
SMTP_USERNAME=your-email@example.com
# Password for SMTP connection
SMTP_PASSWORD=your-email-password
# SMTP host (e.g., smtp.gmail.com)
SMTP_HOST=smtp.example.com
# SMTP port (e.g., 465 for SSL, 587 for TLS)
SMTP_PORT=587

# ===== PUBLIC URLS =====
# These should be the publicly accessible URLs for your services
# Replace "your-domain.com" with your actual domain
# NOTE: URLs should have no trailing slashes

# Authentication server public URL
# Used for generating email confirmation & password reset URLs
# Example: https://auth.streetwriters.co
AUTH_SERVER_PUBLIC_URL=https://your-domain.com:8264

# Main Notesnook app public URL
# Used by backend for creating redirect URLs (after email confirmation, etc.)
# Example: https://app.notesnook.com
NOTESNOOK_APP_PUBLIC_URL=https://your-domain.com:5264

# Monograph publishing service public URL
# Public URL for the monograph frontend
# Example: https://monogr.ph
MONOGRAPH_PUBLIC_URL=https://your-domain.com:6264

# File attachments server public URL (MinIO S3)
# Used by Notesnook clients for uploading/downloading attachments
# Example: https://attachments.notesnook.com
ATTACHMENTS_SERVER_PUBLIC_URL=https://your-domain.com:9000

# ===== OPTIONAL CONFIGURATION =====

# MinIO S3 Storage Credentials (defaults provided)
# Custom username for MinIO root account (must be >3 characters)
MINIO_ROOT_USER=minioadmin
# Custom password for MinIO root account (must be >8 characters)
MINIO_ROOT_PASSWORD=minioadmin

# ===== TWILIO SMS CONFIGURATION (Optional) =====
# Required for sending SMS with 2FA codes
# Get these from your Twilio Console: https://console.twilio.com/

# Twilio account SID
TWILIO_ACCOUNT_SID=your-twilio-account-sid
# Twilio auth token
TWILIO_AUTH_TOKEN=your-twilio-auth-token
# Twilio service SID (e.g., VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
TWILIO_SERVICE_SID=your-twilio-service-sid

# ===== CORS CONFIGURATION (Optional) =====
# Allowed origins for CORS (comma-separated, leave empty to allow all)
# Example: https://app.notesnook.com,http://localhost:3000
NOTESNOOK_CORS_ORIGINS=

# ===== ADDITIONAL SMTP OPTIONS (Optional) =====
# Custom sender email address
# SMTP_FROM=noreply@your-domain.com
# Enable secure connection
# SMTP_SECURE=true
# Enable TLS
# SMTP_TLS=true
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ _Pvt_Extensions
.paket/paket.exe
paket-files/

# FAKE - F# Make
# FAKE - F# Makes
.fake/

# JetBrains Rider
Expand All @@ -263,5 +263,7 @@ __pycache__/
keys/
dist/
keystore/
.env.local
.env
.env.*
!.env.example
Notesnook.API/sync/
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,11 @@ docker compose up

This takes care of setting up everything including MongoDB, Minio etc.

## TODO Self-hosting

**Note: Self-hosting the Notesnook Sync Server is now possible, but without support. Documentation will be provided at a later date. We are working to enable full on-premise self-hosting, so stay tuned!**

- [x] Open source the Sync server
- [x] Open source the Identity server
- [x] Open source the SSE Messaging infrastructure
- [x] Fully Dockerize all services
- [x] Use self-hosted Minio for S3 storage
- [x] Publish on DockerHub
- [x] Add settings to change server URLs in Notesnook client apps (starting from v3.0.18)
- [ ] Write self hosting docs
For detailed self-hosting instructions, see the [self-hosting documentation](docs/self-hosting.md).

## Self-hosting

Self-hosting the Notesnook Sync Server is now possible using Docker. For complete setup instructions, see the [self-hosting documentation](docs/self-hosting.md).

## License

Expand Down
165 changes: 165 additions & 0 deletions docs/self-hosting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# Self-hosting the Notesnook Sync Server

The Notesnook Sync Server can be easily self-hosted using Docker. This guide will walk you through the setup process.

## Prerequisites

- [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/)
- A domain name or public IP address for external access
- SMTP email server credentials

## Quick Start

### 1. Download the docker-compose.yml file

```bash
wget https://raw.githubusercontent.com/streetwriters/notesnook-sync-server/master/docker-compose.yml
```

### 2. Create your environment configuration

```bash
# Download the example environment file
wget https://raw.githubusercontent.com/streetwriters/notesnook-sync-server/master/.env.example

# Copy it to create your configuration
cp .env.example .env

# Edit the .env file with your settings
nano .env # or use your preferred editor
```

### 3. Configure the required environment variables

Edit the `.env` file and configure the following required variables:

- `INSTANCE_NAME` - Your server instance name
- `NOTESNOOK_API_SECRET` - Generate a strong random secret
- `DISABLE_SIGNUPS` - Set to `true` to disable new registrations
- `SMTP_*` - Your email server settings for notifications
- Update all `*_PUBLIC_URL` variables with your domain/IP

### 4. Start the services

```bash
docker compose up -d
```

## Service Ports

The following ports will be exposed:

- **5264** - Main Notesnook sync server
- **8264** - Identity/authentication server
- **7264** - SSE (Server-Sent Events) server
- **6264** - Monograph publishing server
- **9000** - MinIO S3 storage (for file attachments)

## Verification

### Check service health

Check that all services are healthy:

```bash
docker compose ps
```

### Access health endpoints

You can verify that all services are running correctly by accessing their health endpoints:

- Sync Server: `http://localhost:5264/health`
- Identity Server: `http://localhost:8264/health`
- SSE Server: `http://localhost:7264/health`
- Monograph Server: `http://localhost:6264/api/health`

## Volume Configuration

By default, the Docker Compose setup uses named Docker volumes for persistent data storage. However, you may want to bind these volumes to specific directories on your host system for easier backup and management.

### Default Volumes

The setup creates two Docker volumes:
- `dbdata` - MongoDB database files
- `s3data` - MinIO S3 storage for file attachments

### Binding Volumes to Host Directories

To bind volumes to specific host directories, modify your `docker-compose.yml` file:

```yaml
volumes:
dbdata:
driver: local
driver_opts:
type: none
o: bind
device: /path/to/your/mongodb/data
s3data:
driver: local
driver_opts:
type: none
o: bind
device: /path/to/your/s3/data
```

Or use the simpler bind mount syntax by modifying the services directly:

```yaml
services:
notesnook-db:
# ... other configuration
volumes:
- /path/to/your/mongodb/data:/data/db

notesnook-s3:
# ... other configuration
volumes:
- /path/to/your/s3/data:/data/s3
```

### Recommended Directory Structure

We recommend creating a dedicated directory structure for your Notesnook data:

```bash
mkdir -p /opt/notesnook/{mongodb,s3}
chown -R 999:999 /opt/notesnook/mongodb # MongoDB user
chown -R 1000:1000 /opt/notesnook/s3 # MinIO user
```

Then use these paths in your volume configuration:
- MongoDB data: `/opt/notesnook/mongodb`
- S3 data: `/opt/notesnook/s3`

### Backup Considerations

When using bind mounts, you can easily backup your data by creating snapshots or backups of these directories:

```bash
# Example backup script
tar -czf notesnook-backup-$(date +%Y%m%d).tar.gz -C /opt notesnook/
```

## What's included

This setup takes care of everything including:
- MongoDB database
- MinIO S3 storage for file attachments
- All required Notesnook services (API, Identity, Messenger, Monograph)

## Self-hosting Status

**Note: Self-hosting the Notesnook Sync Server is now possible, but without support. We are working to enable full on-premise self-hosting, so stay tuned!**

### Progress Checklist

- [x] Open source the Sync server
- [x] Open source the Identity server
- [x] Open source the SSE Messaging infrastructure
- [x] Fully Dockerize all services
- [x] Use self-hosted Minio for S3 storage
- [x] Publish on DockerHub
- [x] Add settings to change server URLs in Notesnook client apps (starting from v3.0.18)
- [ ] Write comprehensive self-hosting documentation