forked from hazem/yslootahrobotics
feat: compile and use seed.js for database seeding in entrypoint script
This commit is contained in:
parent
61f1e0f589
commit
22387dbfe1
10
Dockerfile
10
Dockerfile
@ -15,6 +15,14 @@ ENV NEXT_TELEMETRY_DISABLED=1
|
||||
# Generate Prisma client (reads prisma/schema.prisma + prisma.config.ts)
|
||||
RUN npx prisma generate
|
||||
|
||||
# Compile seed.ts → seed.js (esbuild ships with Next.js)
|
||||
RUN node_modules/.bin/esbuild prisma/seed.ts \
|
||||
--bundle \
|
||||
--platform=node \
|
||||
--format=cjs \
|
||||
--packages=external \
|
||||
--outfile=prisma/seed.js
|
||||
|
||||
# Build Next.js — produces .next/standalone (set in next.config.mjs)
|
||||
RUN npm run build
|
||||
|
||||
@ -41,7 +49,7 @@ COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
||||
# Config, schema, and seed script
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/prisma.config.ts ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/prisma/schema.prisma ./prisma/
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/prisma/seed.ts ./prisma/
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/prisma/seed.js ./prisma/
|
||||
|
||||
# Generated Prisma client (imported by the compiled Next.js server bundle)
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/src/generated ./src/generated
|
||||
|
||||
@ -10,7 +10,7 @@ echo "→ Syncing database schema..."
|
||||
/app/node_modules/.bin/prisma db push
|
||||
|
||||
echo "→ Seeding database (idempotent — skips existing records)..."
|
||||
/app/node_modules/.bin/tsx /app/prisma/seed.ts
|
||||
node /app/prisma/seed.js
|
||||
|
||||
echo "→ Starting Next.js on port ${PORT:-3000}..."
|
||||
exec node /app/server.js
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user