Updated DockerFile BaseImage To => [amazoncorretto:17-alpine]#6
Updated DockerFile BaseImage To => [amazoncorretto:17-alpine]#6kshitij9896 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThis 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. ChangesDocker Java Runtime Update
🎯 1 (Trivial) | ⏱️ ~3 minutes
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 winAdd 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.
Summary by CodeRabbit