From 6ec1a3ae8423255b6f8eb672ef6f8016fa6da17c Mon Sep 17 00:00:00 2001 From: streaper2 Date: Wed, 15 Apr 2026 23:54:06 +0200 Subject: [PATCH] maj dockerfile --- Dockerfile | 54 +++++++----------------------------------------------- 1 file changed, 7 insertions(+), 47 deletions(-) diff --git a/Dockerfile b/Dockerfile index c32915c..cc3d135 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,54 +1,14 @@ -# Base image -FROM node:22-alpine AS base +FROM node:20-alpine RUN apk add --no-cache libc6-compat openssl - -# Install dependencies only when needed -FROM base AS deps WORKDIR /app -# Install dependencies -COPY package.json package-lock.json ./ -RUN npm ci - -# Rebuild the source code only when needed -FROM base AS builder -WORKDIR /app -COPY --from=deps /app/node_modules ./node_modules +# On copie tout, on installe tout, on build tout au même endroit COPY . . - -# Generate Prisma Client -RUN DATABASE_URL="postgresql://dummy:dummy@localhost:5432/dummy" DEBUG=prisma:* npx prisma generate --schema=prisma/schema.prisma - -# Clear any existing build artifacts and build -RUN rm -rf .next && npm run build - -# Production image, copy all the files and run next -FROM base AS runner -WORKDIR /app - -ENV NODE_ENV=production - -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs - -COPY --from=builder --chown=nextjs:nodejs /app/public ./public -COPY --from=builder --chown=nextjs:nodejs /app/prisma ./prisma -COPY --from=builder --chown=nextjs:nodejs /app/prisma.config.js ./prisma.config.js - -# Set the correct permission for prerender cache -RUN mkdir .next -RUN chown nextjs:nodejs .next - -# Automatically leverage output traces to reduce image size -COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ -COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static - -USER nextjs +RUN npm install +RUN npx prisma generate +RUN npm run build EXPOSE 3000 -ENV PORT=3000 -ENV HOSTNAME="0.0.0.0" - -# Run migrations and start the server -CMD ["sh", "-c", "npx prisma db push && node server.js"] +# On lance directement via npm +CMD ["npm", "start"] \ No newline at end of file