feat: Add Docker support for Coolify deployment
- Add Dockerfile with multi-stage build - Add .dockerignore for optimized builds - Enable standalone output in next.config.mjs - Optimized for production deployment
This commit is contained in:
parent
dd02cde85c
commit
ccc0f34b03
3 changed files with 130 additions and 1 deletions
69
.dockerignore
Normal file
69
.dockerignore
Normal file
|
|
@ -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
|
||||
58
Dockerfile
Normal file
58
Dockerfile
Normal file
|
|
@ -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"]
|
||||
|
|
@ -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,
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue