From 200b9f8c9ea6da946fecb6de7c892bcd533b0174 Mon Sep 17 00:00:00 2001 From: adilallo <39313955+adilallo@users.noreply.github.com> Date: Sat, 23 May 2026 17:38:34 -0600 Subject: [PATCH] Fix seed db --- CloudronManifest.json | 2 +- Dockerfile | 12 +++++++++--- scripts/start.sh | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CloudronManifest.json b/CloudronManifest.json index 1db1ca8..95ac816 100644 --- a/CloudronManifest.json +++ b/CloudronManifest.json @@ -4,7 +4,7 @@ "title": "Community Rule", "author": "MEDLab", "description": "Community governance and rule-building app", - "version": "0.1.2", + "version": "0.1.3", "httpPort": 3000, "healthCheckPath": "/api/health", "memoryLimit": 805306368, diff --git a/Dockerfile b/Dockerfile index 854c29c..3e874c5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,12 @@ RUN apt-get update -y && apt-get install -y openssl && rm -rf /var/lib/apt/lists COPY --from=deps /app/node_modules ./node_modules COPY . . RUN npm run build +# Standalone output omits TS sources the seed imports; bundle seed + JSON paths +# so `node prisma/seed.bundle.cjs` works in the slim runner (no tsx/lib/ tree). +RUN ./node_modules/.bin/esbuild prisma/seed.ts \ + --bundle --platform=node --format=cjs \ + --outfile=prisma/seed.bundle.cjs \ + --external:@prisma/client FROM base AS runner # openssl: Prisma engines. gosu: privilege drop in start.sh after chown. @@ -42,11 +48,11 @@ COPY --from=builder --chown=node:node /app/public ./public COPY --from=builder --chown=node:node /app/.next/standalone ./ COPY --from=builder --chown=node:node /app/.next/static ./.next/static COPY --from=builder --chown=node:node /app/prisma ./prisma +COPY --from=builder --chown=node:node /app/data ./data # Prisma CLI (devDependency) is not in the Next.js standalone trace. Install -# globally in the runner so start.sh can run `prisma migrate deploy` and the -# one-time idempotent `prisma db seed` (upserts by slug). -RUN npm install -g prisma@6.19.3 tsx@4.19.4 +# globally in the runner so start.sh can run `prisma migrate deploy`. +RUN npm install -g prisma@6.19.3 # Cloudron's runtime rootfs is read-only except /tmp, /run, /app/data. # Three marketing routes use ISR (`revalidate`) and write to .next/cache; diff --git a/scripts/start.sh b/scripts/start.sh index 9c5b3e7..2eb664c 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -21,4 +21,4 @@ chown -R node:node /tmp/next-cache # Drop privileges, apply any pending migrations, then exec the server. # Inner `exec` ensures SIGTERM from Cloudron reaches node for clean shutdown. exec gosu node:node sh -c \ - 'prisma migrate deploy && prisma db seed && exec node server.js' + 'prisma migrate deploy && node prisma/seed.bundle.cjs && exec node server.js'