From 44c676c62b8dc29b3b5c6804a6bbb290d75c8ded Mon Sep 17 00:00:00 2001 From: Citali Date: Sun, 29 Jun 2025 02:08:03 +0200 Subject: [PATCH] Add dockerfile --- Dockerfile | 40 ++++++++++++++++++++++++++++++++++++++++ next.config.ts | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..600f0f1 --- /dev/null +++ b/Dockerfile @@ -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 \ No newline at end of file diff --git a/next.config.ts b/next.config.ts index e9ffa30..68a6c64 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,7 +1,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { - /* config options here */ + output: "standalone", }; export default nextConfig;