migrate: replace pg with Prisma ORM
- Add prisma/schema.prisma with Project/Task models, enums, and relations - Create src/lib/db.ts singleton Prisma client - Refactor all 5 API routes to use Prisma queries - Replace migrate.ts with seed.ts for initial data - Update Dockerfile for Prisma lifecycle (copy generated client) - Update tsconfig.json with @/generated/* path alias - Remove pg and @types/pg dependencies - Add prisma.config.ts for Prisma 6 config - Update .gitignore for generated Prisma client
This commit is contained in:
22
Dockerfile
22
Dockerfile
@@ -12,6 +12,9 @@ RUN npm ci
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Generate Prisma client
|
||||
RUN npx prisma generate
|
||||
|
||||
# Build the Next.js app
|
||||
RUN npm run build
|
||||
|
||||
@@ -24,9 +27,8 @@ ENV NODE_ENV=production
|
||||
ENV HOSTNAME="0.0.0.0"
|
||||
ENV PORT=3000
|
||||
|
||||
# Install postgres client, netcat, and tsx for migrations
|
||||
RUN apk add --no-cache postgresql-client netcat-openbsd && \
|
||||
npm install -g tsx
|
||||
# Install postgres client and netcat
|
||||
RUN apk add --no-cache postgresql-client netcat-openbsd
|
||||
|
||||
# Create a non-root user
|
||||
RUN addgroup --system --gid 1001 nodejs && \
|
||||
@@ -34,14 +36,14 @@ RUN addgroup --system --gid 1001 nodejs && \
|
||||
|
||||
# Copy the built app from builder
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone/ ./
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next
|
||||
COPY --from=builder /app/package.json ./
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/prisma ./prisma
|
||||
# Copy generated Prisma client (includes native query engine binary)
|
||||
COPY --from=builder /app/src/generated ./src/generated
|
||||
|
||||
# Copy migration script (for initial setup)
|
||||
COPY --chown=nextjs:nodejs src/server/db/migrate.ts ./migrate.ts
|
||||
|
||||
# Create startup script
|
||||
# Copy startup script
|
||||
COPY start.sh /app/start.sh
|
||||
RUN chmod +x /app/start.sh
|
||||
|
||||
@@ -49,4 +51,4 @@ USER nextjs
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
CMD ["/app/start.sh"]
|
||||
CMD ["/app/start.sh"]
|
||||
|
||||
Reference in New Issue
Block a user