38 lines
775 B
Docker
38 lines
775 B
Docker
# Stage 1: Build the React application
|
|
FROM node:18-alpine AS build
|
|
|
|
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:1.21-alpine
|
|
|
|
# Copy the built application from the build stage
|
|
COPY --from=build /app/build /usr/share/nginx/html
|
|
|
|
# Copy a custom Nginx configuration if needed (optional)
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Copy the entrypoint script
|
|
COPY entrypoint.sh /entrypoint.sh
|
|
|
|
# Make the entrypoint script executable
|
|
RUN chmod +x /entrypoint.sh
|
|
|
|
# Expose port 80
|
|
EXPOSE 80
|
|
|
|
# Set the entrypoint
|
|
ENTRYPOINT ["/entrypoint.sh"]
|