iralex-front/Dockerfile

40 lines
831 B
Docker

# -------------------------------
# Stage 1: Build with Node.js
# -------------------------------
FROM node:14.21.3 AS builder
WORKDIR /app
# Copy package files first for caching
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the project
COPY . .
# Build the project (output goes to /app/dist)
RUN npm run build
# -------------------------------
# Stage 2: Serve with NGINX
# -------------------------------
FROM nginx:alpine
# Remove the default NGINX website
RUN rm -rf /usr/share/nginx/html/*
# Copy the build output from the previous stage
COPY --from=builder /app/dist /usr/share/nginx/html
# (Optional) Use your own NGINX configuration
# COPY nginx.conf /etc/nginx/conf.d/default.conf
# Expose port 80
EXPOSE 80
# Start NGINX in foreground mode
CMD ["nginx", "-g", "daemon off;"]