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:
co-authored by
Claude Sonnet 4.6
parent
c73338e256
commit
1185f5ab50
@@ -10,8 +10,8 @@ AUTHENTIK_IMAGE_TAG=2024.12.3
|
|||||||
# Run drizzle migrations on container start. Leave true.
|
# Run drizzle migrations on container start. Leave true.
|
||||||
RUN_MIGRATIONS=true
|
RUN_MIGRATIONS=true
|
||||||
|
|
||||||
# Public URL for the app (used in share links, OIDC redirect URIs, etc.)
|
# Public URL for the app — used by Auth.js for OIDC redirect URIs.
|
||||||
NEXT_PUBLIC_APP_URL=https://fam.ginnoir.com
|
AUTH_URL=https://fam.ginnoir.com
|
||||||
|
|
||||||
# famapp Postgres credentials (used to build DATABASE_URL inside compose.yaml)
|
# famapp Postgres credentials (used to build DATABASE_URL inside compose.yaml)
|
||||||
FAMAPP_DB_USER=famapp
|
FAMAPP_DB_USER=famapp
|
||||||
@@ -21,20 +21,21 @@ FAMAPP_DB_NAME=famapp
|
|||||||
# Auth.js session secret — generate with: openssl rand -base64 32
|
# Auth.js session secret — generate with: openssl rand -base64 32
|
||||||
AUTH_SECRET=replace-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_ISSUER=https://auth.ginnoir.com/application/o/famapp/
|
||||||
AUTH_OIDC_CLIENT_ID=replace-me
|
AUTH_OIDC_CLIENT_ID=replace-me
|
||||||
AUTH_OIDC_CLIENT_SECRET=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_PUBLIC_KEY=
|
||||||
VAPID_PRIVATE_KEY=
|
VAPID_PRIVATE_KEY=
|
||||||
# Must be "mailto:<address>" or a URL
|
# 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 push fallback — uses your existing ntfy instance at ntfy.ginnoir.com
|
||||||
NTFY_URL=
|
# Leave NTFY_URL blank to disable ntfy fanout.
|
||||||
NTFY_TOPIC=
|
NTFY_URL=https://ntfy.ginnoir.com
|
||||||
|
NTFY_TOPIC=famapp
|
||||||
|
|
||||||
# Log level: error | warn | info | debug
|
# Log level: error | warn | info | debug
|
||||||
LOG_LEVEL=info
|
LOG_LEVEL=info
|
||||||
|
|||||||
@@ -7,3 +7,7 @@ Format: `## vX.Y.Z — YYYY-MM-DD`
|
|||||||
## Unreleased
|
## 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.
|
- 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.
|
||||||
|
|||||||
@@ -42,8 +42,9 @@ Living progress tracker. Update at the end of each task. Codex and Claude Code b
|
|||||||
|
|
||||||
## Next up
|
## Next up
|
||||||
|
|
||||||
- Phase 7 hardening complete. All acceptance criteria met for tasks 60, 61, 62.
|
- **Ready to tag v0.1.0.** All phase 1–7 tasks complete and production wiring verified.
|
||||||
- **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.
|
- 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
|
## Development login/testing notes
|
||||||
|
|
||||||
|
|||||||
@@ -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 {
|
fam.ginnoir.com {
|
||||||
reverse_proxy famapp:3000
|
reverse_proxy 192.168.1.69:3010
|
||||||
}
|
}
|
||||||
|
|
||||||
auth.ginnoir.com {
|
auth.ginnoir.com {
|
||||||
reverse_proxy authentik-server:9000
|
reverse_proxy 192.168.1.69:9200
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export default async function SettingsPage() {
|
|||||||
const { user } = await getCurrentSession();
|
const { user } = await getCurrentSession();
|
||||||
const shareLinks = await getActiveShareLinks();
|
const shareLinks = await getActiveShareLinks();
|
||||||
const ntfyConfigured = !!(process.env["NTFY_URL"] && process.env["NTFY_TOPIC"]);
|
const ntfyConfigured = !!(process.env["NTFY_URL"] && process.env["NTFY_TOPIC"]);
|
||||||
|
const vapidKey = process.env["VAPID_PUBLIC_KEY"] ?? "";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container max-w-2xl py-8 space-y-6">
|
<div className="container max-w-2xl py-8 space-y-6">
|
||||||
@@ -46,7 +47,7 @@ export default async function SettingsPage() {
|
|||||||
<CardTitle>Push Notifications</CardTitle>
|
<CardTitle>Push Notifications</CardTitle>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<PushOptIn />
|
<PushOptIn vapidKey={vapidKey} />
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ import {
|
|||||||
sendTestNotification,
|
sendTestNotification,
|
||||||
} from "@/app/settings/push-actions";
|
} from "@/app/settings/push-actions";
|
||||||
|
|
||||||
const VAPID_KEY = process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY ?? "";
|
|
||||||
|
|
||||||
function urlBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer> {
|
function urlBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer> {
|
||||||
const padding = "=".repeat((4 - (base64String.length % 4)) % 4);
|
const padding = "=".repeat((4 - (base64String.length % 4)) % 4);
|
||||||
const base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");
|
const base64 = (base64String + padding).replace(/-/g, "+").replace(/_/g, "/");
|
||||||
@@ -19,13 +17,13 @@ function urlBase64ToUint8Array(base64String: string): Uint8Array<ArrayBuffer> {
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PushOptIn() {
|
export function PushOptIn({ vapidKey }: { vapidKey: string }) {
|
||||||
const [status, setStatus] = useState<"idle" | "subscribed" | "denied" | "unsupported">("idle");
|
const [status, setStatus] = useState<"idle" | "subscribed" | "denied" | "unsupported">("idle");
|
||||||
const [endpoint, setEndpoint] = useState<string | null>(null);
|
const [endpoint, setEndpoint] = useState<string | null>(null);
|
||||||
const [isPending, startTransition] = useTransition();
|
const [isPending, startTransition] = useTransition();
|
||||||
const [testSent, setTestSent] = useState(false);
|
const [testSent, setTestSent] = useState(false);
|
||||||
|
|
||||||
if (!VAPID_KEY) return null;
|
if (!vapidKey) return null;
|
||||||
if (!("serviceWorker" in navigator) || !("PushManager" in window)) {
|
if (!("serviceWorker" in navigator) || !("PushManager" in window)) {
|
||||||
return (
|
return (
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
@@ -39,7 +37,7 @@ export function PushOptIn() {
|
|||||||
const registration = await navigator.serviceWorker.ready;
|
const registration = await navigator.serviceWorker.ready;
|
||||||
const sub = await registration.pushManager.subscribe({
|
const sub = await registration.pushManager.subscribe({
|
||||||
userVisibleOnly: true,
|
userVisibleOnly: true,
|
||||||
applicationServerKey: urlBase64ToUint8Array(VAPID_KEY),
|
applicationServerKey: urlBase64ToUint8Array(vapidKey),
|
||||||
});
|
});
|
||||||
const json = sub.toJSON() as { endpoint: string; keys: { p256dh: string; auth: string } };
|
const json = sub.toJSON() as { endpoint: string; keys: { p256dh: string; auth: string } };
|
||||||
startTransition(async () => {
|
startTransition(async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user