33 lines
684 B
Plaintext
33 lines
684 B
Plaintext
# Dockerfile
|
|
# ------------
|
|
# Create a production-ready Docker container to host the React app.
|
|
|
|
# Use an official Node.js runtime as a parent image
|
|
FROM node:18 as build
|
|
|
|
# Set the working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package.json and package-lock.json
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm install
|
|
|
|
# Copy the app's source code
|
|
COPY . .
|
|
|
|
# Build the app for production
|
|
RUN npm run build
|
|
|
|
# Use a lightweight web server to serve the built app
|
|
FROM nginx:alpine
|
|
|
|
# Copy the build files from the previous stage
|
|
COPY --from=build /app/build /usr/share/nginx/html
|
|
|
|
# Expose the port the app runs on
|
|
EXPOSE 80
|
|
|
|
# Start the Nginx server
|
|
CMD ["nginx", "-g", "daemon off;"] |