diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..15b215f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,69 @@ +# Dependencies +node_modules +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Build output +.next/ +out/ +dist/ +build/ + +# Environment variables +.env +.env.local +.env.development.local +.env.test.local +.env.production.local +.env*.local + +# Testing +coverage/ +.nyc_output/ + +# Misc +.DS_Store +*.pem +.vscode/ +.idea/ + +# Git +.git +.gitignore + +# Vercel +.vercel + +# Documentation +*.md +!README.md + +# Temporary files +tmp/ +temp/ +*.tmp +*.log + +# Lambda functions (ne pas inclure dans l'image) +lambda-*/ + +# Test files +test-*.sh +test-*.js +test-*.mjs +*.test.js +*.test.ts +__tests__/ + +# CSV et fichiers de données +*.csv +*.pdf +!public/**/*.pdf + +# Sync conflicts +*sync-conflict* + +# Backups +*.bak +*.bak2 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ebc315b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,58 @@ +# Dockerfile pour Espace Paie - Optimisé pour Coolify +FROM node:18-alpine AS base + +# Installer les dépendances système nécessaires +RUN apk add --no-cache libc6-compat + +# === ÉTAPE 1 : Dependencies === +FROM base AS deps +WORKDIR /app + +# Copier les fichiers de dépendances +COPY package.json package-lock.json* ./ +RUN npm ci + +# === ÉTAPE 2 : Build === +FROM base AS builder +WORKDIR /app + +# Copier les dépendances depuis l'étape précédente +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +# Variables d'environnement pour le build +ENV NEXT_TELEMETRY_DISABLED=1 +ENV NODE_ENV=production + +# Build Next.js en mode standalone +RUN npm run build + +# === ÉTAPE 3 : Production === +FROM base AS runner +WORKDIR /app + +ENV NODE_ENV=production +ENV NEXT_TELEMETRY_DISABLED=1 + +# Créer un utilisateur non-root +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +# Copier les fichiers nécessaires +COPY --from=builder /app/public ./public + +# Copier le build standalone +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +# Utiliser l'utilisateur non-root +USER nextjs + +# Exposer le port +EXPOSE 3000 + +ENV PORT=3000 +ENV HOSTNAME="0.0.0.0" + +# Démarrer l'application +CMD ["node", "server.js"] diff --git a/next.config.mjs b/next.config.mjs index bbac025..694fb69 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -1,10 +1,12 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, + // Mode standalone pour Docker/Coolify + output: 'standalone', experimental: { missingSuspenseWithCSRBailout: false }, - // Ignorer les warnings ESLint durant le build pour Vercel + // Ignorer les warnings ESLint durant le build eslint: { ignoreDuringBuilds: true, },