feat: initial headless sync server implementation
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
# Obsidian Sync Configuration
|
||||||
|
OBSIDIAN_VAULT_NAME=MyVault
|
||||||
|
OBSIDIAN_SYNC_PASSWORD=your_encryption_password_here
|
||||||
|
OBSIDIAN_DEVICE_NAME=Docker-Sync-Server
|
||||||
|
OBSIDIAN_SYNC_TOKEN=
|
||||||
|
# The path on the host where the vault will be mirrored
|
||||||
|
VAULT_HOST_PATH=./vault
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
FROM node:20-slim
|
||||||
|
|
||||||
|
# Install system dependencies
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
curl \
|
||||||
|
git \
|
||||||
|
ca-certificates \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install Obsidian Headless CLI
|
||||||
|
RUN npm install -g obsidian-headless
|
||||||
|
|
||||||
|
# Create vault directory
|
||||||
|
WORKDIR /vault
|
||||||
|
|
||||||
|
# Copy entrypoint script
|
||||||
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
# Obsidian Sync Server
|
||||||
|
|
||||||
|
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:**
|
||||||
|
```bash
|
||||||
|
git clone https://gitea-wc4w40kskg0c4g400s0wcgsg.coolify-7dou.ja7z.net/hermes/obsidian-sync-server.git
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Launch:**
|
||||||
|
```bash
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **First-Time Login:**
|
||||||
|
The `obsidian-headless` tool requires an initial login to your Obsidian account.
|
||||||
|
```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`.
|
||||||
|
|
||||||
|
## 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 <command>`.
|
||||||
|
|
||||||
|
## Environment Variables
|
||||||
|
| Variable | Description |
|
||||||
|
|----------|-------------|
|
||||||
|
| `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 |
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
obsidian-sync:
|
||||||
|
build: .
|
||||||
|
container_name: obsidian-sync-server
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- ./vault:/vault
|
||||||
|
- ./config:/root/.config/obsidian-headless
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
environment:
|
||||||
|
- TZ=UTC
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Starting Obsidian Headless Sync Server..."
|
||||||
|
|
||||||
|
# Ensure we are in the vault directory
|
||||||
|
cd /vault
|
||||||
|
|
||||||
|
# 1. Initial Login
|
||||||
|
# Note: In a fully automated environment, the user will need to provide
|
||||||
|
# a session token or use 'ob login' interactively once.
|
||||||
|
# For this container, we assume the user has handled login or we use an environment variable.
|
||||||
|
if [ -z "$OBSIDIAN_SYNC_TOKEN" ]; then
|
||||||
|
echo "Warning: OBSIDIAN_SYNC_TOKEN not provided. You may need to run 'docker exec -it <container> ob login' manually once."
|
||||||
|
else
|
||||||
|
# Assuming the CLI supports token-based login or we inject the session
|
||||||
|
echo "Using provided sync token for login..."
|
||||||
|
# ob login --token $OBSIDIAN_SYNC_TOKEN
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 2. Setup Sync for the specified vault
|
||||||
|
echo "Setting up sync for vault: $OBSIDIAN_VAULT_NAME"
|
||||||
|
ob sync-setup --vault "$OBSIDIAN_VAULT_NAME" --password "$OBSIDIAN_SYNC_PASSWORD" --device-name "$OBSIDIAN_DEVICE_NAME" --path /vault
|
||||||
|
|
||||||
|
# 3. Start Continuous Sync
|
||||||
|
echo "Entering continuous sync mode..."
|
||||||
|
exec ob sync --continuous
|
||||||
Reference in New Issue
Block a user