Skip to content

Add Umami web analytics example - #296

Open
tjmgregory wants to merge 4 commits into
unikraft-cloud:mainfrom
tjmgregory:add-umami-example
Open

Add Umami web analytics example#296
tjmgregory wants to merge 4 commits into
unikraft-cloud:mainfrom
tjmgregory:add-umami-example

Conversation

@tjmgregory

Copy link
Copy Markdown

Summary

  • Adds a new umami/ example deploying Umami v3.0.3 open-source web analytics
  • Uses the existing postgres/ example as the database backend
  • FROM scratch final stage following the same pattern as httpserver-node21-nextjs
  • Includes SSL certificates in the image for TLS database connections
  • Documents a workaround for the missing pgcrypto extension (not needed on PG16+ which has gen_random_uuid() built-in)

Files

File Description
umami/Kraftfile Unikraft Cloud config, runs node /app/server.js
umami/Dockerfile Multi-stage build: clones Umami, builds Next.js standalone, strips to scratch
umami/README.md Step-by-step guide: deploy postgres, run migrations, deploy Umami
umami/.dockerignore Excludes .unikraft/ build artifacts

Tested on

  • kraft CLI v0.12.8
  • Metro: fra
  • Memory: 1024 MiB (minimum for the ~320 MB image)
  • PostgreSQL from the postgres/ example

馃 Generated with Claude Code

Deploys Umami v3.0.3 as a Next.js standalone app on a FROM scratch
image, backed by the existing postgres example. Includes a workaround
for the missing pgcrypto extension (not needed on PG16+).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tjmgregory
tjmgregory marked this pull request as draft April 15, 2026 16:12
tjmgregory and others added 3 commits April 15, 2026 18:16
- cd back to ../umami/ after postgres deploy (not examples/umami/)
- Note macOS sed -i '' syntax difference for pgcrypto patch

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Location tracking is one of Umami's key features. Stripping it
saved 54 MB but isn't worth the loss in functionality. Users who
need a smaller image can add the rm line back.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The 386 MB image (with GeoIP data) OOMs at 1024 MiB during initramfs
unpacking. 1536 MiB works reliably. Document the 1024 MiB option for
users who strip GeoIP.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tjmgregory
tjmgregory marked this pull request as ready for review April 15, 2026 16:26
@razvand
razvand requested a lite review from Copilot August 21, 2026 07:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an Umami v3.0.3 analytics example backed by PostgreSQL.

Changes:

  • Builds a scratch-based Umami image.
  • Adds Unikraft runtime configuration.
  • Documents migrations, deployment, upgrades, and cleanup.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Summary
umami/README.md Moderate (3 votes): kraft cloud deploy omits /tls+http. Moderate (3 votes): Upgrade instructions leave migration version hardcoded to v3.0.3. Nit (3 votes): Sequential migration commands resolve the build path incorrectly. Nit (2 votes): APP_SECRET fallback behavior is documented incorrectly. Nit (3 votes): geo retention conflicts with documented image size and memory. Nit (2 votes): Missing entry in the repository root README catalog.
umami/Kraftfile Adds Unikraft runtime and startup configuration.
umami/Dockerfile Builds Umami as a minimal scratch-based image.
umami/.dockerignore Excludes Unikraft build artifacts.
Suppressed comments (4)

umami/Dockerfile:32

  • The final stage never sets a working directory, so the absolute Kraftfile command will start Node with / as its cwd. Umami v3.0.3 resolves the GeoLite database as path.join(process.cwd(), 'geo'), while this image puts it under /app/geo; location lookups will therefore fail. Set the final-stage working directory to /app.
FROM scratch

umami/Kraftfile:7

  • Launching /app/server.js bypasses Umami's start-docker wrapper. In v3.0.3 that wrapper runs update-tracker, which rewrites /api/send in public/script.js when COLLECT_API_ENDPOINT is set; the README advertises this variable, so the served tracker will still post to /api/send. Either include and invoke the wrapper or remove/document this unsupported option.
cmd: ["/usr/bin/node", "/app/server.js"]

umami/README.md:43

  • These default PostgreSQL commands create PGDATA on the instance filesystem and mount no volume, so recreating the database VM loses all Umami analytics data. Please add the postgres example's volume setup to both deployment commands or explicitly label this as an ephemeral demo.
unikraft run --metro=fra -p 5432:5432/tls -m 1536M -e POSTGRES_PASSWORD=<password> -e POSTGRES_DB=umami --scale-to-zero=off <my-org>/postgres:latest

umami/README.md:141

  • Because the Kraftfile starts /app/server.js directly, Umami's normal start-docker sequence (which runs update-tracker.js) is never executed. Setting COLLECT_API_ENDPOINT therefore does not update the shipped public/script.js; only manually sent requests are rewritten, so the documented custom tracker endpoint does not work as described. Add a startup step to update the tracker or remove/qualify this variable.
| `COLLECT_API_ENDPOINT` | No | Custom tracker endpoint path (replaces `/api/send`) |

馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread umami/README.md
Return to the `umami/` example directory and deploy:

```bash title="unikraft"
cd ../umami/
Comment thread umami/README.md
```bash title="kraft"
cd ../umami/
kraft cloud deploy \
-p 443:3000 \
Comment thread umami/README.md

To upgrade to a new Umami release:

1. Update `UMAMI_VERSION` in the `Dockerfile` (e.g., `v3.0.3` to `v3.1.0`)
Comment thread umami/README.md
| Variable | Required | Description |
|----------|----------|-------------|
| `DATABASE_URL` | Yes | PostgreSQL connection string |
| `APP_SECRET` | Recommended | Secret for session encryption. Auto-generated if not set, but won't persist across restarts. |
Comment thread umami/README.md

## Notes

- **Image size**: The `FROM scratch` image is ~386 MB (including GeoIP data for visitor location tracking). Umami requires at least 1536 MiB of memory to unpack the initramfs and run. To reduce the image by ~54 MB (and lower the minimum memory to 1024 MiB), add `rm -rf /app/.next/standalone/geo` to the `Dockerfile` build stage. This disables visitor location tracking.
Comment thread umami/README.md
@@ -0,0 +1,186 @@
# Umami Web Analytics
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.

2 participants