Skip to content

Commit

Permalink
Merge pull request #88 from MAVRICK-1/dockerize-application
Browse files Browse the repository at this point in the history
Dockerize Container
  • Loading branch information
Mujtabaa07 authored Jan 2, 2025
2 parents 60d715d + e4617a9 commit c55b90a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Stage 1: Build the React application
FROM node:18 AS builder

# Set working directory inside the container
WORKDIR /app

# Copy package.json and package-lock.json
COPY package.json ./

# Install dependencies
RUN npm install

# Copy all source code
COPY . .

# Build the React app
RUN npm run build

# Stage 2: Serve the application with Nginx
FROM nginx:stable-alpine

# Copy the built files from the previous stage
COPY --from=builder /app/build /usr/share/nginx/html

# Copy the Nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Expose the port
EXPOSE 80

# Start the Nginx server
CMD ["nginx", "-g", "daemon off;"]
15 changes: 15 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
server {
listen 80;

server_name localhost;

root /usr/share/nginx/html;

index index.html;

location / {
try_files $uri /index.html;
}

error_page 404 /index.html;
}

0 comments on commit c55b90a

Please sign in to comment.