Add dockerfile

This commit is contained in:
2025-06-29 02:08:03 +02:00
parent ac3b19a1f2
commit 44c676c62b
2 changed files with 41 additions and 1 deletions

40
Dockerfile Normal file
View File

@ -0,0 +1,40 @@
# Install dependencies only when needed
FROM node:20-alpine AS deps
WORKDIR /app
# Install global Prisma CLI
RUN npm install -g prisma
# Install dependencies
COPY package.json package-lock.json* ./
RUN npm ci
# Copy only prisma schema to generate client early
COPY prisma ./prisma/
RUN npx prisma generate
# Builder image
FROM node:20-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Build the app
RUN npm run build
# Production image
FROM node:20-alpine AS runner
WORKDIR /app
ENV NODE_ENV production
# Copy necessary files
COPY --from=builder /app/public ./public
COPY --from=builder /app/.next ./.next
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/prisma ./prisma
# Run migrations if needed
# CMD npx prisma migrate deploy && node .next/standalone/server.js
CMD node .next/standalone/server.js

View File

@ -1,7 +1,7 @@
import type { NextConfig } from "next"; import type { NextConfig } from "next";
const nextConfig: NextConfig = { const nextConfig: NextConfig = {
/* config options here */ output: "standalone",
}; };
export default nextConfig; export default nextConfig;