Files
EmailManager/Dockerfile
2025-12-10 12:25:20 +01:00

46 lines
1.0 KiB
Docker

# Stage 1: Build the React Application
# Using standard node:20 (not slim/alpine) to ensure build tools like python/make/g++ are present
FROM node:20 AS builder
WORKDIR /app
# Copy package.json (and lock file if it exists)
COPY package*.json ./
# Install dependencies using legacy-peer-deps to avoid version conflicts
RUN npm install --legacy-peer-deps
# Copy the rest of the application source code
COPY . .
# Build the frontend assets
RUN npm run build
# Stage 2: Setup the Production Server
# Using standard node:20 to ensure native modules (like pg/mysql drivers) install correctly
FROM node:20
WORKDIR /app
# Copy package.json again for production dependencies
COPY package*.json ./
# Install ONLY production dependencies
RUN npm install --omit=dev --legacy-peer-deps
# Copy the built frontend assets from the 'builder' stage
COPY --from=builder /app/dist ./dist
# Copy the server entry point
COPY server.js ./
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3000
# Expose the port
EXPOSE 3000
# Start the Node.js server
CMD ["npm", "start"]