Managing FastAPI Projects with Poetry: A Step-by-Step Guide

Image
This guide will walk you through how to use Poetry to manage dependencies and structure your project in FastAPI . It includes detailed explanations of Poetry's core concepts and commands to help prevent issues that can arise during team collaboration and deployment. 1. What is Poetry? Poetry is a dependency management and packaging tool for Python. It goes beyond simply installing libraries by allowing you to clearly declare the dependencies your project needs and ensuring that all developers on the project have the same library versions. Clarity in Dependency Management : Explicitly manage your project's basic information and required libraries through the pyproject.toml file. Reproducible Builds : By locking all dependency versions in the poetry.lock file, it fundamentally prevents "it works on my machine" problems. Integrated Development Environment : It automatically creates and manages isolated virtual environments for each project and handles mo...

How to install docmost on Synology NAS (DS916+) with Docker

docmost logo

This blog provides a comprehensive guide to installing and configuring Docmost, an open-source collaborative wiki and notion alternative, on a Synology NAS (DS916+ and similar models) environment using Docker.

1. Reverse Proxy Setup for External Access

To access Docmost via an external domain (e.g., docmost.your-domain.i234.me) and to fix the "Real-time editor connection lost" error, a reverse proxy setup is essential.

Step 1. Navigate to Reverse Proxy Settings

  • Go to DSM Control Panel > Login Portal > Advanced tab.
  • Click the Reverse Proxy button and then Create.

Step 2. General Settings

docmost reverse proxy rules general

Step 3. (Crucial) Custom Header Settings

  • After clicking Create, go to the Custom Header tab.
  • Click the Create dropdown menu and select WebSocket.
  • This will automatically add the two necessary headers. This step is key to resolving the real-time editing error.
  • Click Save to complete the setup.
docmost reverse proxy rules custom header

2. Installation Process

Step 1. Enable SSH

  • Go to Control Panel > Terminal & SNMP > Terminal tab, and check 'Enable SSH service'.

Step 2: Create Installation Folder

  • Launch File Station in DSM.
  • Inside the docker shared folder, create a new folder named docmost.
    • The final path will be /volume1/docker/docmost/.

Step 3: Create docker-compose.yml File

  • Inside the docmost folder, create a new file named docker-compose.yml.
  • Since you are now using an external domain, you must update the APP_URL value in your docker-compose.yml file.
  • <YOUR_NAS_IP_ADDRESS>: Change this to your actual Synology NAS internal IP address (e.g., 192.168.0.4).
  • ENTER_A_VERY_LONG_RANDOM_SECRET_KEY_HERE: Replace this with a complex random string of at least 32 characters (e.g., generate one with the `openssl rand -hex 32` command).
  • YOUR_DATABASE_PASSWORD: Enter a password for the database. It is recommended to avoid special characters like @ and $.
  • SAME_PASSWORD_AS_DATABASE_URL_ABOVE: Enter the same database password you used above.
  • (Optional) If using SMTP, enter your correct Naver Mail information and App Password.
# Final docker-compose.yml for Docmost installation (includes SMTP settings)

version: '3.8'
services:
  docmost:
image: docmost/docmost:latest
container_name: docmost
restart: unless-stopped
ports:
  - "3000:3000"
depends_on:
  - db
  - redis
environment:
  # --- Basic Configuration ---
  APP_URL: "https://docmost.your-domain.i234.me"
  APP_SECRET: "ENTER_A_VERY_LONG_RANDOM_SECRET_KEY_HERE"
  DATABASE_URL: "postgresql://docmost:YOUR_DATABASE_PASSWORD@db:5432/docmost?schema=public"
  REDIS_URL: "redis://redis:6379"

  # --- (Optional) SMTP Email Configuration ---
  # Naver Mail Example (delete or comment out these 6 lines if not in use)
  EMAIL_FROM: '"Docmost Notification" <your_id@naver.com>'
  SMTP_HOST: "smtp.naver.com"
  SMTP_PORT: "465"
  SMTP_SECURE: "true"
  SMTP_USER: "your_id@naver.com"
  SMTP_PASSWORD: "ENTER_YOUR_NAVER_APP_PASSWORD_HERE" 

volumes:
  - docmost_data:/app/data/storage
  db:
image: postgres:16-alpine
container_name: docmost-db
restart: unless-stopped
environment:
  POSTGRES_DB: docmost
  POSTGRES_USER: docmost
  POSTGRES_PASSWORD: "SAME_PASSWORD_AS_DATABASE_URL_ABOVE"
volumes:
  - db_data:/var/lib/postgresql/data
  redis:
image: redis:7.2-alpine
container_name: docmost-redis
restart: unless-stopped
volumes:
  - redis_data:/data

volumes:
  docmost_data:
  db_data:
  redis_data:

Step 5: Execute via SSH

  • Open a terminal (PowerShell, PuTTY, etc.) on your PC and connect to your NAS via SSH.
  • This command will download all necessary images and create/run the containers in the background.
$ ssh <YOUR_DSM_ADMIN_ACCOUNT>@<YOUR_NAS_IP_ADDRESS>
$ sudo -i                      # Gain root access.
$ cd /volume1/docker/docmost/
$ docker-compose up -d

3. Useful Commands

  • Check container status:
$ docker-compose ps
  • View real-time logs (useful for diagnosing issues):
$ docker-compose logs -f
  • Stop and completely remove containers:
$ docker-compose down

Comments

Popular posts from this blog

Resolving Key Exchange Failure When Connecting with SecureCRT to OpenSSH

SecureCRT] How to Back Up and Restore SecureCRT Settings on Windows

How to Set Up Vaultwarden (Bitwarden) on Synology NAS (Best Free Alternative to LastPass)