diff --git a/.env.example b/.env.example index ad6acdd..fb3af96 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,16 @@ # Obsidian Sync Configuration + +# 1. Remote Vault Details OBSIDIAN_VAULT_NAME=MyVault OBSIDIAN_SYNC_PASSWORD=your_encryption_password_here OBSIDIAN_DEVICE_NAME=Docker-Sync-Server + +# 2. Local Filesystem Mapping +# IMPORTANT: Use an ABSOLUTE PATH here. +# This is where your notes will be stored on your actual computer/server. +# Example: /home/travis/my-obsidian-vault +VAULT_HOST_PATH=/path/to/your/local/vault + +# 3. Authentication +# Leave blank if you prefer to run 'docker exec -it obsidian-sync-server ob login' OBSIDIAN_SYNC_TOKEN= -# The path on the host where the vault will be mirrored -VAULT_HOST_PATH=./vault diff --git a/README.md b/README.md index 202d2a9..b153292 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,6 @@ A headless Docker container that uses `obsidian-headless` to keep a local vault directory synchronized with Obsidian Sync. -## Architecture -- **Base Image:** Node.js 20 Slim -- **Sync Engine:** `obsidian-headless` (Official CLI) -- **Mode:** Continuous Sync (Watches for changes and pushes/pulls in real-time) - ## Quick Start 1. **Clone the repo:** @@ -15,30 +10,31 @@ A headless Docker container that uses `obsidian-headless` to keep a local vault cd obsidian-sync-server ``` -2. **Configure Environment:** - ```bash - cp .env.example .env - # Edit .env with your vault name, E2EE password, and device name - nano .env - ``` +2. **Configure the Host Path:** + - Copy the example env: `cp .env.example .env` + - Open `.env` and set `VAULT_HOST_PATH` to the **absolute path** of the folder on your computer where you want the notes to live. + - *Correct:* `/home/user/documents/my-vault` + - *Incorrect:* `./vault` (relative paths can be unpredictable in docker-compose) -3. **Launch:** +3. **Set Sync Credentials:** + - Fill in `OBSIDIAN_VAULT_NAME` and `OBSIDIAN_SYNC_PASSWORD` (your E2EE key). + +4. **Launch:** ```bash docker-compose up -d ``` -4. **First-Time Login:** - The `obsidian-headless` tool requires an initial login to your Obsidian account. +5. **First-Time Login:** + Because Obsidian Sync requires a secure login, you must authenticate the container once: ```bash docker exec -it obsidian-sync-server ob login ``` - Follow the on-screen instructions to authenticate. Once logged in, the container will automatically proceed to `sync-setup` and `sync --continuous`. + Follow the instructions to log in. The session will be saved in the `./config` folder, so you won't have to do this again. -## Interaction -Since this is a headless server, you interact with your vault by: -- **Filesystem:** Accessing the `./vault` folder on your host machine. -- **Local Obsidian:** Opening the `./vault` folder in your local Obsidian app. -- **CLI:** Running commands via `docker exec obsidian-sync-server ob `. +## How it Works +The container runs a continuous sync loop. +- **Cloud $\rightarrow$ Host:** Changes in Obsidian Sync are immediately downloaded to your `VAULT_HOST_PATH`. +- **Host $\rightarrow$ Cloud:** Any changes you make to the files in `VAULT_HOST_PATH` (via a local Obsidian app or text editor) are immediately pushed to the cloud. ## Environment Variables | Variable | Description | @@ -46,4 +42,4 @@ Since this is a headless server, you interact with your vault by: | `OBSIDIAN_VAULT_NAME` | The name of the remote vault you want to sync | | `OBSIDIAN_SYNC_PASSWORD` | Your end-to-end encryption password | | `OBSIDIAN_DEVICE_NAME` | The name this device will have in your Sync history | -| `OBSIDIAN_SYNC_TOKEN` | (Optional) A session token to bypass interactive login | +| `VAULT_HOST_PATH` | **Absolute path** to the vault folder on your host machine | diff --git a/docker-compose.yml b/docker-compose.yml index 31ef773..cce8362 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,11 @@ services: container_name: obsidian-sync-server restart: unless-stopped volumes: - - ./vault:/vault + # Map your local host folder to the container's vault folder + # Syntax: - /absolute/path/on/your/host:/vault + - ${VAULT_HOST_PATH}:/vault + + # Persist the sync session and config so you don't have to 'ob login' on every restart - ./config:/root/.config/obsidian-headless env_file: - .env