- 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
55 lines
1.1 KiB
Docker
55 lines
1.1 KiB
Docker
# Build stage
|
|
FROM node:22-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package.json package-lock.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Generate Prisma client
|
|
RUN npx prisma generate
|
|
|
|
# Build the Next.js app
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
FROM node:22-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV HOSTNAME="0.0.0.0"
|
|
ENV PORT=3000
|
|
|
|
# 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 && \
|
|
adduser --system --uid 1001 nextjs
|
|
|
|
# Copy the built app from builder
|
|
COPY --from=builder /app/public ./public
|
|
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 startup script
|
|
COPY start.sh /app/start.sh
|
|
RUN chmod +x /app/start.sh
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
|
|
|
CMD ["/app/start.sh"]
|