Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions app/prm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# PRM production image. Build from the REPO ROOT (workspace deps live there):
# docker build -f app/prm/Dockerfile -t prm .
# No secrets at build time: all keys (PRM_AUTH_SECRET, PRM_MCP_KEY, ...) are
# injected as runtime env by the deploy layer and never baked into a layer.

FROM node:24-bookworm-slim AS build
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
WORKDIR /workspace
# corepack reads the pinned pnpm version from the root package.json.
COPY package.json ./
RUN corepack enable && corepack install
COPY . .
# Install and build only the PRM and its workspace dependency closure.
RUN pnpm install --frozen-lockfile --filter 'prm...' \
&& pnpm --filter prm build

FROM node:24-bookworm-slim AS runtime
ARG PRM_BUILD_SHA=unknown
ENV NODE_ENV=production \
PRM_DATA_DIR=/data \
PRM_BUILD_SHA=$PRM_BUILD_SHA \
PORT=3000 HOST=0.0.0.0 NITRO_HOST=0.0.0.0
WORKDIR /app
RUN mkdir /data && chown node:node /data
COPY --from=build --chown=node:node /workspace/app/prm/.output ./.output
USER node
# cms.db, uploads/, backups/, prm.json and secrets.env all live here.
VOLUME /data
EXPOSE 3000
HEALTHCHECK --interval=15s --timeout=5s --start-period=30s CMD node -e "fetch('http://127.0.0.1:3000/api/cms/v1/health').then(r=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))"
CMD ["node", ".output/server/index.mjs"]
9 changes: 8 additions & 1 deletion app/prm/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* days ago.
*/
import { defineEventHandler } from '@tanstack/cms-core'
import { systemContext } from '@tanstack/cms-core/server'

const HUMAN_ACTORS = new Set(['human', 'admin', 'editor', 'author'])

Expand Down Expand Up @@ -46,7 +45,11 @@ export const personCreatedEnrichHandler = defineEventHandler({
: {}
const name = String(payload.name ?? personId)
const headline = String(payload.headline ?? '')
// Server-only modules are imported lazily: this file is reachable from the
// client bundle (router.tsx -> cms.config.ts), and a static import of
// @tanstack/cms-core/server pulls node:async_hooks into the browser.
const { runAgent } = await import('@tanstack/cms-api')
const { systemContext } = await import('@tanstack/cms-core/server')
await runAgent(
'enrich',
[
Expand Down Expand Up @@ -75,7 +78,11 @@ export const monthlyStaleRefreshHandler = defineEventHandler({
})
if (stale.length === 0) return
if (!process.env.ANTHROPIC_API_KEY && !process.env.CRM_AUTO_ENRICH) return
// Server-only modules are imported lazily: this file is reachable from the
// client bundle (router.tsx -> cms.config.ts), and a static import of
// @tanstack/cms-core/server pulls node:async_hooks into the browser.
const { runAgent } = await import('@tanstack/cms-api')
const { systemContext } = await import('@tanstack/cms-core/server')
for (const doc of stale.slice(0, 5)) {
const id = String(doc.id ?? '')
await runAgent(
Expand Down
10 changes: 5 additions & 5 deletions app/prm/src/routes/prm-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ function PrmSettingsPage() {

return (
<AppShell active="settings">
<PageHeader
eyebrow="Instance & Household"
title="Settings."
lede="Manage your PRM instance, approval workflow, theme preference, and family or team members."
/>
<PageMain className="gap-6">
<PageHeader
eyebrow="Instance & Household"
title="Settings."
lede="Manage your PRM instance, approval workflow, theme preference, and family or team members."
/>
<Card className="flex flex-col gap-4 p-5 sm:p-6">
<div className="flex flex-wrap items-center justify-between gap-3">
<div>
Expand Down
7 changes: 5 additions & 2 deletions app/prm/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,18 @@ export default defineConfig({
}),
},
}),
nitro(),
// Keep PGlite (the default embedded store) intact so Nitro traces its
// adjacent WASM / data / extension assets into .output. Bundling it
// drops pglite.data and pg_trgm.tar.gz and the store never opens.
nitro({ traceDeps: ['@electric-sql/pglite*'] }),
viteReact(),
],
// Externalize @tanstack/react-store so its CJS use-sync-external-store shim
// resolves the single bundled React copy at runtime instead of being inlined
// into the app chunk (which pulls in a second React and crashes production
// SSR with "Invalid hook call"). Nitro's lib bundler shares the single
// bundled React like every other dep.
ssr: { external: ['@tanstack/react-store'] },
ssr: { external: ['@electric-sql/pglite', '@tanstack/react-store'] },
optimizeDeps: {
include: [
'react',
Expand Down
Loading