Skip to content

Commit

Permalink
feat: Optimize Dockerfile with Nginx.
Browse files Browse the repository at this point in the history
  • Loading branch information
Suraj-kumar00 committed Oct 8, 2024
1 parent 8614033 commit 67d0919
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Stage 1: Build the application
FROM node:18-alpine AS build

# Setting up the working directory inside the container
WORKDIR /app

# Copy package.json and package-lock.json to the working directory
COPY package.json package-lock.json ./

# Install dependencies
RUN npm install

# Copy the rest of the application code to the working directory
COPY . .

# Build the React application
RUN npm run build

# Stage 2: Serve the application
FROM nginx:alpine

# Copy built 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;"]

0 comments on commit 67d0919

Please sign in to comment.