Skip to content

Update the docker file of the front-end app with nginx light wieght s… - #41

Open
Umar-Devops-cyber wants to merge 1 commit into
LondheShubham153:mainfrom
Umar-Devops-cyber:main
Open

Update the docker file of the front-end app with nginx light wieght s…#41
Umar-Devops-cyber wants to merge 1 commit into
LondheShubham153:mainfrom
Umar-Devops-cyber:main

Conversation

@Umar-Devops-cyber

@Umar-Devops-cyber Umar-Devops-cyber commented Jun 19, 2026

Copy link
Copy Markdown

…erver using multistage build

Summary by CodeRabbit

  • Chores
    • Optimized application build and deployment infrastructure to improve performance and efficiency.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The frontend Dockerfile is converted from a single-stage Node.js 14 image that ran npm start into a multi-stage build: a Node.js 20 Alpine stage compiles the app with npm ci and npm run build, then a separate Nginx stage copies the static output and serves it on port 80.

Changes

Frontend Dockerfile Multi-Stage Build

Layer / File(s) Summary
Build stage and Nginx runtime stage
Application-Code/frontend/Dockerfile
Replaces the single node:14 stage (using npm install + npm start) with a node:20-alpine build stage (npm ci + npm run build) and an Nginx production stage that copies /app/build into the web root, exposes port 80, and runs Nginx in the foreground.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 Hop hop, the old Node server's gone away,
Two stages now make the frontend ship today.
npm ci builds the static art,
Then Nginx serves it, sharp and smart.
Port 80 listens, daemon's off—
This bunny's proud, no reason to scoff! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: updating the Dockerfile to use Nginx with a lightweight, multi-stage build approach for the front-end app.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Warning

⚠️ This pull request shows signs of AI-generated slop (redundant_comments). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Application-Code/frontend/Dockerfile`:
- Around line 27-36: The runtime stage Dockerfile is running Nginx as the root
user by default, creating a security vulnerability. Add a USER directive in the
Dockerfile after the COPY instruction and before the CMD instruction to run
Nginx as a non-root user. Use a non-privileged user that exists in the
nginx:1.27-alpine image, such as the nginx user, to ensure the container runs
with reduced privileges and improved isolation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5ebee14d-324a-4105-bc7e-736babde17e3

📥 Commits

Reviewing files that changed from the base of the PR and between 82f9f75 and e5934ce.

📒 Files selected for processing (1)
  • Application-Code/frontend/Dockerfile

Comment on lines +27 to +36
FROM nginx:1.27-alpine

# Copy built static files from the build stage into Nginx's serving directory
COPY --from=build /app/build /usr/share/nginx/html

# Expose the port Nginx listens on
EXPOSE 80

# Run Nginx in the foreground (required for Docker containers)
CMD ["nginx", "-g", "daemon off;"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Run Nginx as a non-root user in the runtime stage.

Line 27+ currently uses an image/config that runs as root by default, and there is no USER override. This weakens container isolation and matches the DS-0002 finding.

Suggested hardening patch
-FROM nginx:1.27-alpine
+FROM nginxinc/nginx-unprivileged:1.27-alpine

 # Copy built static files from the build stage into Nginx's serving directory
 COPY --from=build /app/build /usr/share/nginx/html

-# Expose the port Nginx listens on
-EXPOSE 80
+# Unprivileged nginx listens on 8080 by default
+EXPOSE 8080

 # Run Nginx in the foreground (required for Docker containers)
 CMD ["nginx", "-g", "daemon off;"]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Application-Code/frontend/Dockerfile` around lines 27 - 36, The runtime stage
Dockerfile is running Nginx as the root user by default, creating a security
vulnerability. Add a USER directive in the Dockerfile after the COPY instruction
and before the CMD instruction to run Nginx as a non-root user. Use a
non-privileged user that exists in the nginx:1.27-alpine image, such as the
nginx user, to ensure the container runs with reduced privileges and improved
isolation.

Source: Linters/SAST tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant