Initial commit - Facturation SANTINOVA
This commit is contained in:
74
Dockerfile
Normal file
74
Dockerfile
Normal file
@@ -0,0 +1,74 @@
|
||||
# ============================================================
|
||||
# STAGE 1: Build Frontend
|
||||
# ============================================================
|
||||
FROM node:22-alpine AS frontend-build
|
||||
|
||||
WORKDIR /app/frontend
|
||||
|
||||
# Copy package files
|
||||
COPY frontend/package.json frontend/pnpm-lock.yaml* frontend/yarn.lock* frontend/package-lock.json* ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install --legacy-peer-deps
|
||||
|
||||
# Copy source code
|
||||
COPY frontend/ ./
|
||||
|
||||
# Build
|
||||
RUN npm run build
|
||||
|
||||
# ============================================================
|
||||
# STAGE 2: Build Backend
|
||||
# ============================================================
|
||||
FROM node:22-alpine AS backend-build
|
||||
|
||||
WORKDIR /app/backend
|
||||
|
||||
# Copy package files
|
||||
COPY backend/package.json backend/pnpm-lock.yaml* backend/yarn.lock* backend/package-lock.json* ./
|
||||
|
||||
# Install dependencies
|
||||
RUN npm install --legacy-peer-deps
|
||||
|
||||
# Copy source code
|
||||
COPY backend/ ./
|
||||
|
||||
# Build TypeScript
|
||||
RUN npm run build
|
||||
|
||||
# ============================================================
|
||||
# STAGE 3: Production
|
||||
# ============================================================
|
||||
FROM node:22-alpine AS production
|
||||
|
||||
# Install necessary system packages
|
||||
RUN apk add --no-cache curl
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy backend build and dependencies
|
||||
COPY --from=backend-build /app/backend/dist ./backend/dist
|
||||
COPY --from=backend-build /app/backend/node_modules ./backend/node_modules
|
||||
COPY --from=backend-build /app/backend/package.json ./backend/
|
||||
|
||||
# Copy frontend build
|
||||
COPY --from=frontend-build /app/frontend/dist ./frontend/dist
|
||||
|
||||
# Create uploads directory
|
||||
RUN mkdir -p /app/uploads
|
||||
|
||||
# Set environment variables
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3001
|
||||
ENV UPLOAD_DIR=/app/uploads
|
||||
|
||||
# Expose port
|
||||
EXPOSE 3001
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
|
||||
CMD curl -f http://localhost:3001/api/health || exit 1
|
||||
|
||||
# Start the application
|
||||
WORKDIR /app/backend
|
||||
CMD ["node", "dist/index.js"]
|
||||
Reference in New Issue
Block a user