Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 75ca85e

Browse files
committedApr 4, 2025·
this is the updated one
1 parent d9b3492 commit 75ca85e

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed
 

Diff for: ‎Dockerfile

+20-15
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
1-
# Stage 1: Build
2-
FROM node:18-alpine as build
1+
# Stage 1: Build React App
2+
FROM node:18-alpine AS build
33

4-
# Set working directory
4+
# Set working directory inside the container
55
WORKDIR /app
66

7-
# Copy package.json and lock files first (for better caching)
7+
# Copy only package files for better layer caching
88
COPY package*.json ./
9-
#COPY .npmrc .npmrc
109

11-
# Optional: clean npm cache (helps with weird issues)
10+
# Optional: clean npm cache
1211
RUN npm cache clean --force
1312

14-
# Manually install ajv v6 and ajv-keywords v3 to avoid breaking changes
13+
# Install ajv v6 and ajv-keywords v3 to avoid breaking changes
1514
RUN npm install ajv@6 ajv-keywords@3 --legacy-peer-deps
1615

17-
# Now copy the rest of the app
18-
COPY . .
19-
20-
# Install remaining dependencies with legacy flag
16+
# Install other dependencies
2117
RUN npm install --legacy-peer-deps
2218

23-
# Build the app
19+
# Copy the rest of the application code
20+
COPY . .
21+
22+
# Build the React application
2423
RUN npm run build
2524

26-
# Stage 2: Serve the build output
25+
# Stage 2: Serve with Nginx
2726
FROM nginx:alpine
2827

29-
# Copy only the frontend build output
30-
COPY --from=build /app/packages/react-scripts/build /usr/share/nginx/html
28+
# Remove default nginx static files
29+
RUN rm -rf /usr/share/nginx/html/*
30+
31+
# Copy build output from previous stage
32+
COPY --from=build /app/build /usr/share/nginx/html
33+
34+
# Copy custom nginx config if you have one (optional)
35+
# COPY nginx.conf /etc/nginx/nginx.conf
3136

3237
# Expose port 80
3338
EXPOSE 80

0 commit comments

Comments
 (0)
Please sign in to comment.