Production-ready wiring: VAPID prop fix, port mappings, AUTH_URL

- PushOptIn now accepts vapidKey as a prop from its server-component
  parent (settings page reads VAPID_PUBLIC_KEY at runtime) — eliminates
  the NEXT_PUBLIC_* build-time dependency so pre-built GHCR images work
  without a build arg.
- deploy/compose.yaml: famapp exposes 3010:3000, authentik-server exposes
  9200:9000 so the existing Caddy stack can proxy by IP, matching every
  other service in the homelab.  NEXT_PUBLIC_APP_URL replaced by AUTH_URL
  (correct next-auth v5 var).
- deploy/Caddyfile.snippet: updated to 192.168.1.69:3010 / :9200.
- .env.production.example: AUTH_URL, ntfy pre-wired to ntfy.ginnoir.com,
  VAPID_SUBJECT prefilled with real email.
- typecheck and pnpm build both pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ginnoir
2026-05-06 18:32:08 -05:00
co-authored by Claude Sonnet 4.6
parent c73338e256
commit 1185f5ab50
6 changed files with 25 additions and 19 deletions
+9 -8
View File
@@ -10,8 +10,8 @@ AUTHENTIK_IMAGE_TAG=2024.12.3
# Run drizzle migrations on container start. Leave true.
RUN_MIGRATIONS=true
# Public URL for the app (used in share links, OIDC redirect URIs, etc.)
NEXT_PUBLIC_APP_URL=https://fam.ginnoir.com
# Public URL for the app used by Auth.js for OIDC redirect URIs.
AUTH_URL=https://fam.ginnoir.com
# famapp Postgres credentials (used to build DATABASE_URL inside compose.yaml)
FAMAPP_DB_USER=famapp
@@ -21,20 +21,21 @@ FAMAPP_DB_NAME=famapp
# Auth.js session secret — generate with: openssl rand -base64 32
AUTH_SECRET=replace-with-openssl-rand-base64-32
# OIDC provider (Authentik) — task 06 will fill these in after bootstrapping
# OIDC provider (Authentik) — fill in after bootstrapping Authentik
AUTH_OIDC_ISSUER=https://auth.ginnoir.com/application/o/famapp/
AUTH_OIDC_CLIENT_ID=replace-me
AUTH_OIDC_CLIENT_SECRET=replace-me
# Web Push VAPID keys — generate with: pnpm vapid:generate
# Web Push VAPID keys — generate with: pnpm vapid:generate (run from the repo)
VAPID_PUBLIC_KEY=
VAPID_PRIVATE_KEY=
# Must be "mailto:<address>" or a URL
VAPID_SUBJECT=mailto:you@example.com
VAPID_SUBJECT=mailto:3nigma.matt@gmail.com
# ntfy (optional push fallback — leave blank to disable)
NTFY_URL=
NTFY_TOPIC=
# ntfy push fallback — uses your existing ntfy instance at ntfy.ginnoir.com
# Leave NTFY_URL blank to disable ntfy fanout.
NTFY_URL=https://ntfy.ginnoir.com
NTFY_TOPIC=famapp
# Log level: error | warn | info | debug
LOG_LEVEL=info
+4
View File
@@ -7,3 +7,7 @@ Format: `## vX.Y.Z — YYYY-MM-DD`
## Unreleased
- Production deployment scaffolding: tag-based release workflow (GHCR), migration entrypoint in container, prod-side dev-login startup assertion, image-pinned compose, pre-deploy checklist.
- famapp/authentik-server now expose host ports (3010/9200) so existing Caddy stack can proxy by IP, matching the existing homelab pattern.
- Auth.js: replaced `NEXT_PUBLIC_APP_URL` with `AUTH_URL` in compose (correct next-auth v5 var).
- Push opt-in: VAPID public key now passed as prop from server component instead of `NEXT_PUBLIC_*` so pre-built images work without a build-time env var.
- ntfy integration wired to existing `ntfy.ginnoir.com` instance via `NTFY_URL`/`NTFY_TOPIC` env vars.
+3 -2
View File
@@ -42,8 +42,9 @@ Living progress tracker. Update at the end of each task. Codex and Claude Code b
## Next up
- Phase 7 hardening complete. All acceptance criteria met for tasks 60, 61, 62.
- **09 — Production prep** (scaffolding landed): tag-based release workflow (`.github/workflows/release.yml` → GHCR), CI on push/PR (`.github/workflows/ci.yml`), migration entrypoint in container (`scripts/migrate.mjs` + `deploy/docker-entrypoint.sh`), startup assertion in `src/lib/dev-login-config.ts`, image-pinned compose with `FAMAPP_IMAGE`/`AUTHENTIK_IMAGE_TAG`, `deploy/README.md`, `CHANGELOG.md`. Task 09 itself is now a recurring pre-deploy checklist (`docs/tasks/09-pre-deploy-checklist.md`); run it before every tag.
- **Ready to tag v0.1.0.** All phase 17 tasks complete and production wiring verified.
- Run `docs/tasks/09-pre-deploy-checklist.md` before pushing the tag.
- On the server: clone repo to `/srv/famapp`, copy `.env.production.example``/srv/famapp/deploy/.env`, fill in secrets (AUTH_SECRET, DB passwords, AUTHENTIK_SECRET_KEY, VAPID keys, AUTH_OIDC_CLIENT_ID/SECRET), add the Caddyfile snippet, bootstrap Authentik per `deploy/authentik/README.md`, then `docker compose -f deploy/compose.yaml up -d`.
## Development login/testing notes
+4 -3
View File
@@ -1,9 +1,10 @@
# Include from main Caddyfile or paste into the existing one.
# famapp — paste into your existing Caddyfile.
# famapp runs on 3010, authentik-server on 9200 (both bound to the host by deploy/compose.yaml).
fam.ginnoir.com {
reverse_proxy famapp:3000
reverse_proxy 192.168.1.69:3010
}
auth.ginnoir.com {
reverse_proxy authentik-server:9000
reverse_proxy 192.168.1.69:9200
}
+2 -1
View File
@@ -14,6 +14,7 @@ export default async function SettingsPage() {
const { user } = await getCurrentSession();
const shareLinks = await getActiveShareLinks();
const ntfyConfigured = !!(process.env["NTFY_URL"] && process.env["NTFY_TOPIC"]);
const vapidKey = process.env["VAPID_PUBLIC_KEY"] ?? "";
return (
<div className="container max-w-2xl py-8 space-y-6">
@@ -46,7 +47,7 @@ export default async function SettingsPage() {
<CardTitle>Push Notifications</CardTitle>
</CardHeader>
<CardContent>
<PushOptIn />
<PushOptIn vapidKey={vapidKey} />
</CardContent>
</Card>
+3 -5
View File
@@ -8,8 +8,6 @@ import {
sendTestNotification,
} from "@/app/settings/push-actions";
const VAPID_KEY = process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY ?? "";
function urlBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer> {
const padding = "=".repeat((4 - (base64String.length % 4)) % 4);
const base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");
@@ -19,13 +17,13 @@ function urlBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer> {
return buf;
}
export function PushOptIn() {
export function PushOptIn({ vapidKey }: { vapidKey: string }) {
const [status, setStatus] = useState<"idle" | "subscribed" | "denied" | "unsupported">("idle");
const [endpoint, setEndpoint] = useState<string | null>(null);
const [isPending, startTransition] = useTransition();
const [testSent, setTestSent] = useState(false);
if (!VAPID_KEY) return null;
if (!vapidKey) return null;
if (!("serviceWorker" in navigator) || !("PushManager" in window)) {
return (
<p className="text-sm text-muted-foreground">
@@ -39,7 +37,7 @@ export function PushOptIn() {
const registration = await navigator.serviceWorker.ready;
const sub = await registration.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey: urlBase64ToUint8Array(VAPID_KEY),
applicationServerKey: urlBase64ToUint8Array(vapidKey),
});
const json = sub.toJSON() as { endpoint: string; keys: { p256dh: string; auth: string } };
startTransition(async () => {