Skip to content

Commit 18fc733

Browse files
committed
minor fixes
1 parent 401f307 commit 18fc733

9 files changed

Lines changed: 164 additions & 40 deletions

File tree

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ PORT=8080
33
# Host port mapping for docker-compose (optional)
44
HOCUSPOCUS_PORT=8080
55

6+
# Published Docker image used by docker-compose (pin to a release if desired)
7+
FOCUS_COMPASS_IMAGE=ghcr.io/focus-compass/focus-compass-sync-server:latest
8+
69
# Optional: strong random token.
710
# If omitted, the server starts in setup mode and the first visit to '/' can
811
# generate a token that will be persisted to ./data/auth.json.
@@ -39,4 +42,4 @@ YJS_GC=true
3942

4043
# Optional: GitHub repo used for update checks in the admin UI.
4144
# Format: owner/repo
42-
UPDATE_REPO=focus-compass/server
45+
UPDATE_REPO=focus-compass/focus-compass-sync-server
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Publish Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "v*"
9+
workflow_dispatch:
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
jobs:
16+
docker:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
22+
steps:
23+
- name: Check out repository
24+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
28+
29+
- name: Log in to GitHub Container Registry
30+
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
31+
with:
32+
registry: ${{ env.REGISTRY }}
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Extract Docker metadata
37+
id: meta
38+
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
39+
with:
40+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
41+
tags: |
42+
type=raw,value=edge,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
43+
type=sha,format=short,prefix=sha-,enable=${{ github.ref_type == 'branch' }}
44+
type=ref,event=tag
45+
type=semver,pattern={{version}},value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
46+
type=semver,pattern={{major}}.{{minor}},value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
47+
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
48+
labels: |
49+
org.opencontainers.image.title=Focus Compass Sync Server
50+
org.opencontainers.image.description=Real-time collaboration server based on Hocuspocus/Yjs with SQLite persistence
51+
52+
- name: Build and push Docker image
53+
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
54+
with:
55+
context: .
56+
push: true
57+
tags: ${{ steps.meta.outputs.tags }}
58+
labels: ${{ steps.meta.outputs.labels }}
59+
cache-from: type=gha
60+
cache-to: type=gha,mode=max

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Notes:
2222
- npm is the expected package manager (`package-lock.json` is present).
2323

2424
Docker:
25-
- Start: `docker compose up -d --build` (logs: `docker compose logs -f`)
25+
- Start: `docker compose up -d` (logs: `docker compose logs -f`)
2626
- Stop: `docker compose down` (wipe volume: `docker compose down -v`, destructive)
2727

2828
Smoke checks:

Dockerfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ FROM node:24-alpine
1616

1717
WORKDIR /app
1818
ENV NODE_ENV=production
19+
LABEL org.opencontainers.image.source="https://github.com/focus-compass/focus-compass-sync-server"
20+
LABEL org.opencontainers.image.description="Real-time collaboration server based on Hocuspocus/Yjs with SQLite persistence"
1921

2022
COPY --from=deps --chown=node:node /app/node_modules ./node_modules
2123
COPY --chown=node:node package*.json ./
2224
COPY --chown=node:node src ./src
2325

24-
# Create data directory
25-
RUN mkdir -p /app/data && chown -R node:node /app
26-
27-
USER node
26+
RUN mkdir -p /app/data
2827

2928
EXPOSE 8080
3029

README.md

Lines changed: 86 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,30 +37,76 @@ Hocuspocus is a WebSocket backend based on CRDT (Conflict-free Replicated Data T
3737
# 1. Copy example env file (optional)
3838
cp .env.example .env
3939

40-
# 2. Start server
41-
docker-compose up -d
40+
# 2. Recommended for production: pin a release image in .env
41+
# FOCUS_COMPASS_IMAGE=ghcr.io/focus-compass/focus-compass-sync-server:0.0.1
4242

43-
# 3. View logs
44-
docker-compose logs -f
43+
# 3. Start server
44+
docker compose up -d
4545

46-
# 4. Check status
46+
# 4. View logs
47+
docker compose logs -f
48+
49+
# 5. Check status
4750
docker ps
4851

4952
# Stop server
50-
docker-compose down
53+
docker compose down
5154

5255
# Full cleanup (including data)
53-
docker-compose down -v
56+
docker compose down -v
5457
```
5558

56-
### Run Locally
59+
This compose file already uses the published GHCR image by default. `latest` is fine for trying the project quickly, but for production deployments you should pin `FOCUS_COMPASS_IMAGE` to a concrete release tag.
60+
61+
If you prefer not to use Compose, you can run the same image directly:
62+
63+
### Run Published Docker Image Directly
64+
65+
Published image URL:
66+
67+
```text
68+
ghcr.io/focus-compass/focus-compass-sync-server
69+
```
70+
71+
Try the latest published release:
72+
73+
```bash
74+
docker run -d \
75+
--name focus-compass-sync-server \
76+
-p 8080:8080 \
77+
-v focus-compass-data:/app/data \
78+
-e HOCUSPOCUS_TOKEN=your-secret-token \
79+
ghcr.io/focus-compass/focus-compass-sync-server:latest
80+
```
81+
82+
Production example with a pinned release:
5783

5884
```bash
59-
# Install dependencies
60-
npm install
85+
docker run -d \
86+
--name focus-compass-sync-server \
87+
-p 8080:8080 \
88+
-v focus-compass-data:/app/data \
89+
-e HOCUSPOCUS_TOKEN=your-secret-token \
90+
ghcr.io/focus-compass/focus-compass-sync-server:0.0.1
91+
```
6192

62-
# Start server
63-
npm start
93+
Compose example using the published image:
94+
95+
```yaml
96+
services:
97+
focus-compass:
98+
image: ghcr.io/focus-compass/focus-compass-sync-server:latest
99+
restart: unless-stopped
100+
ports:
101+
- "8080:8080"
102+
environment:
103+
PORT: 8080
104+
HOCUSPOCUS_TOKEN: your-secret-token
105+
volumes:
106+
- focus-compass-data:/app/data
107+
108+
volumes:
109+
focus-compass-data:
64110
```
65111
66112
The server will be available at `ws://localhost:8080`.
@@ -173,6 +219,34 @@ Server outputs logs like:
173219
2. **Add Redis** - For scaling to multiple instances.
174220
3. **Configure Auth** - Protect access to documents.
175221
4. **Backup** - Regularly backup the SQLite database.
222+
5. **Pin Docker versions** - Use a fixed image tag (`:0.0.1`) for production instead of `:latest`.
223+
224+
Resource limits are intentionally not encoded in the default compose file, because support differs across runtimes and Compose implementations. Set CPU/memory limits in the platform that actually runs the container.
225+
226+
## Docker Publishing
227+
228+
This repository includes a GitHub Actions workflow at `.github/workflows/publish-docker.yml` that publishes images to GHCR.
229+
230+
Main branch pushes publish mutable development tags:
231+
232+
- `ghcr.io/focus-compass/focus-compass-sync-server:edge`
233+
- `ghcr.io/focus-compass/focus-compass-sync-server:sha-<commit>`
234+
235+
Version tag pushes such as `v0.0.1` publish release tags:
236+
237+
- `ghcr.io/focus-compass/focus-compass-sync-server:v0.0.1`
238+
- `ghcr.io/focus-compass/focus-compass-sync-server:0.0.1`
239+
- `ghcr.io/focus-compass/focus-compass-sync-server:0.0`
240+
- `ghcr.io/focus-compass/focus-compass-sync-server:latest`
241+
242+
Release flow:
243+
244+
```bash
245+
git tag v0.0.1
246+
git push origin v0.0.1
247+
```
248+
249+
After the first publish, check the package visibility in GHCR. GitHub's container registry defaults new packages to private until you explicitly make them public.
176250

177251
## MCP (Model Context Protocol)
178252

docker-compose.yml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
version: '3.8'
2-
31
services:
42
hocuspocus-sync:
5-
# Build image from current directory using Dockerfile
6-
build: .
3+
# Published Docker image (override in .env if you want to pin a version)
4+
image: ${FOCUS_COMPASS_IMAGE:-ghcr.io/focus-compass/focus-compass-sync-server:latest}
75

86
# Container name for convenience
97
container_name: hocuspocus_server
@@ -23,9 +21,9 @@ services:
2321
NODE_OPTIONS: "--max-old-space-size=768"
2422
PORT: 8080
2523
# Optional (see .env.example). If omitted, the server starts in setup mode.
26-
HOCUSPOCUS_TOKEN: ${HOCUSPOCUS_TOKEN}
24+
HOCUSPOCUS_TOKEN: ${HOCUSPOCUS_TOKEN:-}
2725
# Optional. If omitted, MCP is disabled until enabled from the admin UI.
28-
MCP_TOKEN: ${MCP_TOKEN}
26+
MCP_TOKEN: ${MCP_TOKEN:-}
2927
DB_PATH: ${DB_PATH:-./data/db.sqlite}
3028
IMAGES_DIR: ${IMAGES_DIR:-./data/images}
3129
BACKUP_DIR: ${BACKUP_DIR:-./data/backups}
@@ -51,16 +49,6 @@ services:
5149
retries: 3
5250
start_period: 40s
5351

54-
# Resource limits to prevent excessive consumption
55-
deploy:
56-
resources:
57-
limits:
58-
cpus: '1.0'
59-
memory: 1G
60-
reservations:
61-
cpus: '0.25'
62-
memory: 256M
63-
6452
# Logging configuration
6553
logging:
6654
driver: "json-file"

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"repository": {
1717
"type": "git",
18-
"url": "git+https://github.com/focus-compass/server.git"
18+
"url": "git+https://github.com/focus-compass/focus-compass-sync-server.git"
1919
},
2020
"keywords": [
2121
"hocuspocus",
@@ -29,9 +29,9 @@
2929
"author": "Focus Masters",
3030
"license": "Apache-2.0",
3131
"bugs": {
32-
"url": "https://github.com/focus-compass/server/issues"
32+
"url": "https://github.com/focus-compass/focus-compass-sync-server/issues"
3333
},
34-
"homepage": "https://github.com/focus-compass/server#readme",
34+
"homepage": "https://github.com/focus-compass/focus-compass-sync-server#readme",
3535
"dependencies": {
3636
"@hocuspocus/extension-logger": "^3.4.0",
3737
"@hocuspocus/extension-sqlite": "^3.4.0",

src/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,7 +2361,7 @@ <h2>Backups</h2>
23612361
<span>Telegram</span>
23622362
</a>
23632363

2364-
<a href="https://github.com/focus-compass/server" target="_blank" rel="noopener noreferrer" title="GitHub">
2364+
<a href="https://github.com/focus-compass/focus-compass-sync-server" target="_blank" rel="noopener noreferrer" title="GitHub">
23652365
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" image-rendering="optimizeQuality" fill-rule="evenodd" clip-rule="evenodd" viewBox="0 0 640 640" aria-hidden="true">
23662366
<path d="M319.988 7.973C143.293 7.973 0 151.242 0 327.96c0 141.392 91.678 261.298 218.826 303.63 16.004 2.964 21.886-6.957 21.886-15.414 0-7.63-.319-32.835-.449-59.552-89.032 19.359-107.8-37.772-107.8-37.772-14.552-36.993-35.529-46.831-35.529-46.831-29.032-19.879 2.209-19.442 2.209-19.442 32.126 2.245 49.04 32.954 49.04 32.954 28.56 48.922 74.883 34.76 93.131 26.598 2.882-20.681 11.15-34.807 20.315-42.803-71.08-8.067-145.797-35.516-145.797-158.14 0-34.926 12.52-63.485 32.965-85.88-3.33-8.078-14.291-40.606 3.083-84.674 0 0 26.87-8.61 88.029 32.8 25.512-7.075 52.878-10.642 80.056-10.76 27.2.118 54.614 3.673 80.162 10.76 61.076-41.386 87.922-32.8 87.922-32.8 17.398 44.08 6.485 76.631 3.154 84.675 20.516 22.394 32.93 50.953 32.93 85.879 0 122.907-74.883 149.93-146.117 157.856 11.481 9.921 21.733 29.398 21.733 59.233 0 42.792-.366 77.28-.366 87.804 0 8.516 5.764 18.473 21.992 15.354 127.076-42.354 218.637-162.274 218.637-303.582 0-176.695-143.269-319.988-320-319.988l-.023.107z"/>
23672367
</svg>
@@ -2779,7 +2779,7 @@ <h2>Backups</h2>
27792779
return status;
27802780
}
27812781

2782-
const DEFAULT_UPDATE_REPO = "focus-compass/server";
2782+
const DEFAULT_UPDATE_REPO = "focus-compass/focus-compass-sync-server";
27832783

27842784
function normalizeUpdateRepo(raw) {
27852785
let s = String(raw || "").trim();

src/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const appVersion = (String(process.env.APP_VERSION ?? "").trim() || packageVersi
3939

4040
const updateRepo =
4141
String(process.env.UPDATE_REPO ?? process.env.GITHUB_UPDATE_REPO ?? "").trim() ||
42-
"focus-compass/server";
42+
"focus-compass/focus-compass-sync-server";
4343

4444
const DB_PATH = process.env.DB_PATH ?? "./data/db.sqlite";
4545
const IMAGES_DIR = process.env.IMAGES_DIR ?? "./data/images";

0 commit comments

Comments
 (0)