35 lines
607 B
Docker
35 lines
607 B
Docker
# Stage 1: Build the React application
|
|
FROM node:20-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package.json and package-lock.json
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm install
|
|
|
|
# Copy the rest of the application source code
|
|
COPY . .
|
|
|
|
# Build the application
|
|
RUN npm run build
|
|
|
|
# Stage 2: Serve the application with Nginx
|
|
FROM nginx:alpine
|
|
|
|
# Set working directory
|
|
WORKDIR /usr/share/nginx/html
|
|
|
|
# Remove default Nginx assets
|
|
RUN rm -rf ./*
|
|
|
|
# Copy built assets from the builder stage
|
|
COPY --from=builder /app/dist .
|
|
|
|
# Expose port 80
|
|
EXPOSE 80
|
|
|
|
# Start Nginx
|
|
CMD ["nginx", "-g", "daemon off;"]
|