maj dockerfile
All checks were successful
Build and Push App / build (push) Successful in 1m54s

This commit is contained in:
2026-04-15 23:54:06 +02:00
parent 57ac75377b
commit 6ec1a3ae84

View File

@@ -1,54 +1,14 @@
# Base image FROM node:20-alpine
FROM node:22-alpine AS base
RUN apk add --no-cache libc6-compat openssl RUN apk add --no-cache libc6-compat openssl
# Install dependencies only when needed
FROM base AS deps
WORKDIR /app WORKDIR /app
# Install dependencies # On copie tout, on installe tout, on build tout au même endroit
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
COPY . . COPY . .
RUN npm install
# Generate Prisma Client RUN npx prisma generate
RUN DATABASE_URL="postgresql://dummy:dummy@localhost:5432/dummy" DEBUG=prisma:* npx prisma generate --schema=prisma/schema.prisma RUN npm run build
# 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
EXPOSE 3000 EXPOSE 3000
ENV PORT=3000 # On lance directement via npm
ENV HOSTNAME="0.0.0.0" CMD ["npm", "start"]
# Run migrations and start the server
CMD ["sh", "-c", "npx prisma db push && node server.js"]