Skip to content

Updated DockerFile BaseImage To => [amazoncorretto:17-alpine]#6

Open
kshitij9896 wants to merge 1 commit into
LondheShubham153:masterfrom
kshitij9896:devkshitij
Open

Updated DockerFile BaseImage To => [amazoncorretto:17-alpine]#6
kshitij9896 wants to merge 1 commit into
LondheShubham153:masterfrom
kshitij9896:devkshitij

Conversation

@kshitij9896

@kshitij9896 kshitij9896 commented Jun 10, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • Chores
    • Updated the Java runtime environment used in application deployments for improved reliability and support.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR updates the Docker base image from OpenJDK 17 Alpine to Amazon Corretto 17 Alpine. All other build and runtime steps remain unchanged. The container will now use Amazon's Java distribution instead of the OpenJDK distribution.

Changes

Docker Java Runtime Update

Layer / File(s) Summary
Java base image update
Dockerfile
The Dockerfile base image definition was updated from openjdk:17-jdk-alpine to amazoncorretto:17-alpine to switch the underlying Java runtime distribution.

🎯 1 (Trivial) | ⏱️ ~3 minutes

A rabbit hops with glee, so spry and free,
From OpenJDK to Corretto, Java's pedigree!
Alpine stays small, the Docker build stands tall, 🐰🔧
One line changed true, now the image'll do!

🚥 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 directly and accurately describes the main change: updating the Dockerfile's base image from openjdk to amazoncorretto:17-alpine, which matches the summary.
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.

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Dockerfile (1)

1-25: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add a non-root USER to improve container security.

The static analysis tool correctly identified that the container runs as root user (DS-0002). Running containers as root increases the attack surface and violates security best practices. If the application is compromised, an attacker would have root privileges within the container.

🔒 Proposed fix to add a non-root user
 # Use the official  amazoncorretto:17-alpine image as the base image
 FROM amazoncorretto:17-alpine

 
 # Set metadata
 LABEL maintainer="trainwithshubham@gmail.com"
 LABEL version="1.0"
 LABEL description="A Java Quotes application"
 
 # Set the working directory inside the container
 WORKDIR /app
 
+# Create a non-root user to run the application
+RUN addgroup -S appgroup && adduser -S appuser -G appgroup
+
 # Copy the source code into the container
 COPY src/Main.java /app/Main.java
 
 COPY quotes.txt quotes.txt
 
 # Compile the Java code
 RUN javac Main.java
 
+# Change ownership of the application files
+RUN chown -R appuser:appgroup /app
+
+# Switch to non-root user
+USER appuser
+
 # Expose port 8000 for the HTTP server
 EXPOSE 8000
 
 # Run the Java application when the container starts
 CMD ["java", "Main"]
🤖 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 `@Dockerfile` around lines 1 - 25, Add a non-root user and switch to it before
running the app: create a group and non-root user (e.g., appuser) in the
Dockerfile after setting WORKDIR and copying files, change ownership of /app
(the WORKDIR and copied files created by COPY) to that user, and then add a USER
appuser line before the CMD so javac RUN steps that need root happen earlier (or
move compilation into a build stage) and the final runtime (CMD ["java","Main"])
runs as the non-root user.

Source: Linters/SAST tools

🤖 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.

Outside diff comments:
In `@Dockerfile`:
- Around line 1-25: Add a non-root user and switch to it before running the app:
create a group and non-root user (e.g., appuser) in the Dockerfile after setting
WORKDIR and copying files, change ownership of /app (the WORKDIR and copied
files created by COPY) to that user, and then add a USER appuser line before the
CMD so javac RUN steps that need root happen earlier (or move compilation into a
build stage) and the final runtime (CMD ["java","Main"]) runs as the non-root
user.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4fafcfed-d74a-4191-b713-7295a93bb796

📥 Commits

Reviewing files that changed from the base of the PR and between c184ddb and 8e9f3ec.

📒 Files selected for processing (1)
  • Dockerfile

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