mirror of
https://github.com/R0m1k3/Regisflow.git
synced 2026-10-11 17:29:48 +02:00
Fixes "docker-entrypoint.sh not found" and improves Dockerfile for proper entrypoint execution and adds docker-test-quick.sh. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 4b008663-bd72-492b-b0b6-fa252367e730 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/4b008663-bd72-492b-b0b6-fa252367e730/DWp0Qa4
91 lines
2.8 KiB
Docker
91 lines
2.8 KiB
Docker
# Dockerfile multi-stage pour RegisFlow Production
|
|
# Stage 1: Build
|
|
FROM node:20-alpine AS builder
|
|
|
|
# Installer les dépendances de build
|
|
RUN apk add --no-cache python3 make g++ git
|
|
|
|
# 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 --prefer-offline
|
|
|
|
# Copier le code source complet
|
|
COPY . .
|
|
|
|
# Construire l'application client et serveur
|
|
RUN npm run build
|
|
|
|
# Vérifier que les fichiers de build existent
|
|
RUN ls -la dist/ && test -f dist/index.js
|
|
|
|
# Stage 2: Production
|
|
FROM node:20-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/init.sql ./
|
|
|
|
# Installer uniquement les dépendances de production
|
|
RUN npm ci --omit=dev --prefer-offline
|
|
|
|
# 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 le script d'entrée directement dans /app (accessible)
|
|
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
|
|
RUN chmod +x /app/docker-entrypoint.sh && \
|
|
chown regisflow:nodejs /app/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=768"
|
|
ENV TZ=Europe/Paris
|
|
|
|
# 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 amélioré
|
|
HEALTHCHECK --interval=30s --timeout=15s --start-period=90s --retries=3 \
|
|
CMD wget --no-verbose --tries=1 --spider http://localhost:5000/health || exit 1
|
|
|
|
# Utiliser dumb-init pour gérer les signaux et lancer le script depuis /app
|
|
ENTRYPOINT ["dumb-init", "--", "/app/docker-entrypoint.sh"] |