-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from MAVRICK-1/dockerize-application
Dockerize Container
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |