Files
EmailManager/Dockerfile
2025-12-10 12:11:06 +01:00

44 lines
994 B
Docker

# Stage 1: Build the React Application
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package.json to install dependencies first (better caching)
COPY package.json ./
# Install all dependencies (including devDependencies for the build process)
RUN npm install
# Copy the rest of the application source code
COPY . .
# Build the frontend assets (Vite will output to /app/dist)
RUN npm run build
# Stage 2: Setup the Production Server (Node.js)
FROM node:20-alpine
WORKDIR /app
# Copy package.json again for production dependencies
COPY package.json ./
# Install ONLY production dependencies (skips devDependencies like Vite/Typescript)
RUN npm install --omit=dev
# 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 (defaults)
ENV NODE_ENV=production
ENV PORT=3000
# Expose the port the app runs on
EXPOSE 3000
# Start the Node.js server
CMD ["npm", "start"]