Skip to content

feat: add self-hosting support (Docker, NixOS, remote import)#241

Open
Razboy20 wants to merge 6 commits intoschej-it:mainfrom
Razboy20:feat/self-hosting
Open

feat: add self-hosting support (Docker, NixOS, remote import)#241
Razboy20 wants to merge 6 commits intoschej-it:mainfrom
Razboy20:feat/self-hosting

Conversation

@Razboy20
Copy link
Copy Markdown

@Razboy20 Razboy20 commented Apr 3, 2026

Self-hosting support

Adds first-class support for self-hosting Timeful, with two deployment options documented in DEPLOYMENT.md.

Docker Compose — The primary path. Adds compose.yaml, Dockerfiles for the server and frontend, and a Caddyfile.example for the reverse proxy. The server now handles a missing .env file gracefully (env vars can be passed directly via Docker), and Cloud Tasks initialization no longer panics if unconfigured — it just disables itself with a log message.

NixOS flake — A nix/ directory contains native Nix derivations for the Go server and Vue frontend, plus a NixOS module that wires up a systemd service and a Podman-managed MongoDB instance. Consuming it is a one-liner flake input.

Import from remote instance — Adds a "Import from URL" flow (POST /api/events/import) so users can copy an event from another Timeful instance into their own. Useful when migrating or federating between self-hosted deployments.


Infrastructure

  • compose.yaml — three services: mongo (with healthcheck), frontend (build-only, copies dist to a shared volume), server (waits on both, mounts the dist read-only)
  • server/Dockerfile / frontend/Dockerfile — multi-stage builds; server copies pre-built frontend dist at runtime via Docker volume
  • Caddyfile.example — reverse proxy to :3002 with gzip/zstd, security headers, www redirect
  • server/main.go — CORS middleware commented out (handled by reverse proxy); frontend dist path now auto-detects ./frontend/dist (Docker layout) before falling back to ../frontend/dist (local dev); missing frontend dist is a warning, not a fatal
  • nix/server.nix, nix/frontend.nixbuildGoModule and buildNpmPackage derivations; client IDs passed as build args so they're baked into the frontend bundle
  • nix/module.nix — NixOS module with services.timeful.{enable, domain, envFile, enableCaddy, googleClientId, microsoftClientId} options; optionally configures Caddy virtualHost; MongoDB via virtualisation.oci-containers

Frontend

  • sign_in_utils.js — Google and Microsoft OAuth client IDs moved from hardcoded strings to VUE_APP_GOOGLE_CLIENT_ID / VUE_APP_MICROSOFT_CLIENT_ID env vars (set at build time via Docker build args or .env)
  • TimefulImportDialog.vue — new dialog: paste a remote event URL, calls /api/events/import, emits the new event ID on success
  • Home.vue — wires up the import dialog behind the existing event-creation menu

Config / server

  • server/.env.template — template for required env vars
  • server/routes/events.go — new POST /api/events/import endpoint: validates URL scheme, fetches the remote event and its responses via the public API, clones them locally under the authenticated user
  • server/services/gcloud/tasks.go — graceful no-op when SERVICE_ACCOUNT_KEY_PATH is unset or "?"; initialization failure logs and returns instead of panicking

Razboy20 added 6 commits April 3, 2026 15:29
- Add nix/server.nix: buildGoModule for Go server
- Add nix/frontend.nix: buildNpmPackage for Vue frontend (Node.js 20)
- Add nix/module.nix: NixOS module (systemd service + Podman MongoDB)
- Rewrite flake.nix: packages, devShells, formatter, nixosModules
- Update DEPLOYMENT.md: flake-based NixOS setup docs
- Add flake.lock
- Gitignore nix result symlink
.. as superfluous as it might be
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant