Skip to content

Commit 52f9801

Browse files
tyler-daneclaude
andauthored
feat(self-host): improve on-premises deployment for homelabbers (#1737)
* feat(self-host): improve on-premises deployment for homelabbers - Publish images to Docker Hub (switchbacktech/compass-{backend,web,mongo}) with semver tags (X.Y.Z, X.Y, latest) via new publish-images.yml workflow - Switch docker-compose.yml from local builds to Hub image references; keep commented-out build blocks for users who need custom builds - Add compass_backend_logs and compass_mongo_configdb named volumes so all writable paths are on volumes; add read_only: true + tmpfs on backend and web - Run backend and web containers as non-root compass user (uid 1001); no extra Linux capabilities required - Simplify install.sh from 947 to ~270 lines: replace git/archive download with curl for docker-compose.yml and compass helper; no --build on startup - Update compass helper: COMPOSE_FILE now at $INSTALL_DIR/docker-compose.yml, update command uses docker compose pull instead of git fetch + build - Rename COMPASS_REF to COMPASS_VERSION throughout; add secret generation hints to .env.example - Add docs/Self-Hosting/environment-variables.md: full env var reference derived from backend and web Zod schemas - Document health endpoint in Self-Hosting README Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs: removed advanced-manual doc * docs(self-host): restructure env vars and monitoring docs - Convert environment-variables.md to markdown tables - Remove intro copy/secret-generation lines from environment-variables.md - Extract health endpoint into standalone monitoring.md - Remove env vars and health endpoint links from README, add monitoring link Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor(self-host): derive project name from install directory Remove COMPOSE_PROJECT_NAME env var. Docker Compose project name is now derived from basename of the install directory in both install.sh and the compass helper, so --project-name stays consistent without requiring an explicit env var. Users who need a second install use a different directory. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore(self-host): remove .env.example, point to backend example file The installer auto-generates .env so a separate template adds no value. Update self-host/README.md and environment-variables.md to reference packages/backend/.env.local.example instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(self-host): clean up compose comment style and env vars doc reference * docs: remove outdated deploy.md * docs: add CI-CD section, move cli commands doc into it Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs(ci-cd): simplify publish-images docs and remove outdated build-args section --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 950103e commit 52f9801

17 files changed

Lines changed: 462 additions & 691 deletions
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Publish Docker images
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Check out repository
17+
uses: actions/checkout@v6
18+
19+
- name: Derive semver tags from git tag
20+
id: version
21+
run: |
22+
TAG="${GITHUB_REF_NAME}" # e.g. v1.2.3
23+
VERSION="${TAG#v}" # 1.2.3
24+
MINOR="${VERSION%.*}" # 1.2
25+
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
26+
echo "minor=${MINOR}" >> "$GITHUB_OUTPUT"
27+
28+
- name: Log in to Docker Hub
29+
uses: docker/login-action@v3
30+
with:
31+
username: ${{ secrets.DOCKERHUB_USERNAME }}
32+
password: ${{ secrets.DOCKERHUB_TOKEN }}
33+
34+
- name: Set up Docker Buildx
35+
uses: docker/setup-buildx-action@v3
36+
37+
- name: Build and push compass-backend
38+
uses: docker/build-push-action@v6
39+
with:
40+
context: .
41+
file: self-host/Dockerfile.backend
42+
push: true
43+
tags: |
44+
switchbacktech/compass-backend:${{ steps.version.outputs.version }}
45+
switchbacktech/compass-backend:${{ steps.version.outputs.minor }}
46+
switchbacktech/compass-backend:latest
47+
48+
- name: Build and push compass-mongo
49+
uses: docker/build-push-action@v6
50+
with:
51+
context: .
52+
file: self-host/Dockerfile.mongo
53+
push: true
54+
tags: |
55+
switchbacktech/compass-mongo:${{ steps.version.outputs.version }}
56+
switchbacktech/compass-mongo:${{ steps.version.outputs.minor }}
57+
switchbacktech/compass-mongo:latest
58+
59+
- name: Build and push compass-web
60+
uses: docker/build-push-action@v6
61+
with:
62+
context: .
63+
file: self-host/Dockerfile.web
64+
push: true
65+
# BASEURL and GOOGLE_CLIENT_ID are baked into the web bundle at build time.
66+
# The published image ships with localhost defaults, which work for local installs.
67+
# Users who need a custom API domain or real Google credentials must rebuild
68+
# the web image locally using the build: blocks in docker-compose.yml.
69+
build-args: |
70+
BASEURL=http://localhost:3000/api
71+
GOOGLE_CLIENT_ID=compass-self-host-placeholder.apps.googleusercontent.com
72+
COMPASS_BUILD_REF=${{ steps.version.outputs.version }}
73+
tags: |
74+
switchbacktech/compass-web:${{ steps.version.outputs.version }}
75+
switchbacktech/compass-web:${{ steps.version.outputs.minor }}
76+
switchbacktech/compass-web:latest

docs/CI-CD/README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# CI/CD
2+
3+
Compass uses GitHub Actions for continuous integration and Docker Hub for distributing self-host images.
4+
5+
## Workflows
6+
7+
| Workflow | Trigger | Purpose |
8+
|---|---|---|
9+
| Test | Push / PR to `main` | Runs lint, type-check, and unit tests |
10+
| CodeQL | Push / PR to `main` | Static security analysis |
11+
| Publish Docker images | Push a `v*.*.*` tag | Builds and publishes self-host images to Docker Hub |
12+
| Sync docs to compass-docs | Push to `main` touching `docs/**` | Mirrors this `docs/` directory to docs.compasscalendar.com |
13+
14+
---
15+
16+
## Publish Docker Images
17+
18+
Source: [`.github/workflows/publish-images.yml`](../../.github/workflows/publish-images.yml)
19+
20+
### How it works
21+
22+
1. A maintainer pushes a git tag matching `v[0-9]+.[0-9]+.[0-9]+` (e.g. `v1.2.3`).
23+
2. The workflow strips the `v` prefix and derives two tag aliases:
24+
- `1.2.3` — exact patch version
25+
- `1.2` — floating minor alias
26+
3. It builds and pushes three images to Docker Hub:
27+
- `switchbacktech/compass-backend`
28+
- `switchbacktech/compass-mongo`
29+
- `switchbacktech/compass-web`
30+
4. Each image gets all three tags: `1.2.3`, `1.2`, and `latest`.
31+
32+
### Manually publishing a release
33+
34+
Although tags are created automatically as part of the release flow, you can also create them manually to publish images from a local branch.
35+
36+
```sh
37+
git tag v1.2.3
38+
git push origin v1.2.3
39+
```
40+
41+
Watch progress in the [Actions tab](https://github.com/SwitchbackTech/compass/actions). After the workflow completes, all three images appear on Docker Hub under the `switchbacktech` org.
42+
43+
### Removing a test tag
44+
45+
```sh
46+
git push origin --delete v1.2.3
47+
git tag -d v1.2.3
48+
```
49+
50+
### Required secrets
51+
52+
Two secrets must be set in **GitHub → Settings → Secrets and variables → Actions**:
53+
54+
| Secret | Value |
55+
|---|---|
56+
| `DOCKERHUB_USERNAME` | Docker Hub username for the `switchbacktech` org |
57+
| `DOCKERHUB_TOKEN` | Docker Hub personal access token (Read & Write) |
File renamed without changes.

docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ Markdown files in this `docs/` directory are automatically mirrored to [docs.com
4040
- [Self-Hosting](./self-hosting/README.md)
4141
- [Testing Playbook](./development/testing-playbook.md)
4242
- [Types And Validation](./development/types-and-validation.md)
43-
- [CLI And Maintenance Commands](./development/cli-and-maintenance-commands.md)
44-
- [Deploy](./development/deploy.md)
43+
- [CI/CD](./ci-cd/README.md)
44+
- [CLI And Maintenance Commands](./ci-cd/cli-and-maintenance-commands.md)
4545

4646
## Feature Deep Dives
4747

docs/development/deploy.md

Lines changed: 0 additions & 56 deletions
This file was deleted.

docs/development/troubleshoot.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ bun run cli delete -u <email>
7373

7474
The delete flow removes both Compass data and SuperTokens auth state. The browser cleanup screen only clears local browser storage after the server-side purge is complete.
7575

76-
See [CLI And Maintenance Commands](./cli-and-maintenance-commands.md) for the current delete flow.
76+
See [CLI And Maintenance Commands](../ci-cd/cli-and-maintenance-commands.md) for the current delete flow.
7777

7878
### Invalid domain name
7979

docs/self-hosting/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ flowchart TD
3636
- Backups and restore: [Back up and restore your data](./backups-and-restore.md)
3737
- Google Calendar: [Add Google Calendar](./google-calendar.md)
3838
- Manual Bun setup: [Run Compass without the installer](./advanced-manual.md)
39+
- Monitoring: [Monitoring](./monitoring.md)
3940

4041
## What you still need to handle yourself
4142

docs/self-hosting/advanced-manual.md

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)