Files
Regisflow/Dockerfile
T
michaelschal 39cc269d29 Improve application startup process and fix potential database issues
Refactors Dockerfile and entrypoint script for enhanced reliability, debugging, and single database migration.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: dec54137-d5a2-4406-8ad4-5f2f9fb110bf
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/5d315300-98fa-429a-abb0-4fdce6a2e3c9.jpg
2025-07-13 12:02:30 +00:00

85 lines
2.6 KiB
Docker

# Dockerfile multi-stage pour RegisFlow Production
# Stage 1: Build
FROM node:18-alpine AS builder
# Installer les dépendances de build
RUN apk add --no-cache python3 make g++
# Créer le répertoire de build
WORKDIR /build
# Copier les fichiers de dépendances
COPY package*.json ./
# Installer toutes les dépendances (dev + prod)
RUN npm ci --include=dev
# Copier le code source
COPY . .
# Construire l'application
RUN npm run build
# Stage 2: Production
FROM node:18-alpine AS production
# Installer uniquement les dépendances système nécessaires pour production
RUN apk add --no-cache \
dumb-init \
postgresql-client \
wget \
curl \
&& rm -rf /var/cache/apk/*
# Créer un utilisateur non-root avec des permissions limitées
RUN addgroup -g 1001 -S nodejs && \
adduser -S regisflow -u 1001 -G nodejs
# Créer les répertoires avec permissions appropriées
WORKDIR /app
RUN mkdir -p /app/backups /app/logs /app/data && \
chown -R regisflow:nodejs /app
# Copier uniquement les fichiers nécessaires depuis le builder
COPY --from=builder --chown=regisflow:nodejs /build/package*.json ./
COPY --from=builder --chown=regisflow:nodejs /build/dist ./dist
COPY --from=builder --chown=regisflow:nodejs /build/shared ./shared
COPY --from=builder --chown=regisflow:nodejs /build/drizzle.config.ts ./
COPY --from=builder --chown=regisflow:nodejs /build/node_modules ./node_modules
COPY --from=builder --chown=regisflow:nodejs /build/init.sql ./
# Copier les assets client au bon endroit pour serveStatic
COPY --from=builder --chown=regisflow:nodejs /build/dist/public ./public
# Les dépendances sont déjà copiées depuis le builder
# Nettoyer le cache npm uniquement
RUN npm cache clean --force && \
rm -rf /tmp/*
# Copier les scripts de configuration
COPY --chown=regisflow:nodejs docker-entrypoint-simple.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Changer vers l'utilisateur non-root
USER regisflow
# Exposer le port
EXPOSE 5000
# Variables d'environnement de production
ENV NODE_ENV=production
ENV PORT=5000
ENV NODE_OPTIONS="--max-old-space-size=512"
# Labels pour la documentation
LABEL maintainer="RegisFlow Team"
LABEL version="1.0.0"
LABEL description="Application RegisFlow pour la gestion des ventes de feux d'artifice"
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:5000/ || exit 1
# Point d'entrée avec script de démarrage
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["node", "dist/index.js"]