-
Notifications
You must be signed in to change notification settings - Fork 29
Dockerize Admin API Application #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughA new multi-stage Dockerfile has been added to build and deploy a Java web application. The first stage uses a Maven image with OpenJDK 17 to compile the application and package it as a WAR file, skipping tests and some plugins for efficiency. The second stage uses a Tomcat 9.0 image with OpenJDK 17, removes default web applications, and deploys the built WAR file as the root web application. The container exposes port 8080 and starts Tomcat upon launch. Changes
Poem
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. πͺ§ TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
π§Ή Nitpick comments (4)
Dockerfile (4)
1-7
: Optimize build layers & ensure tests run in CI.
- Use a
.dockerignore
(e.g., to excludetarget/
,.git/
, IDE files) to minimize the build context.- Separate dependency download into its own layer to leverage caching:
WORKDIR /app -COPY . . -RUN mvn clean package -DskipTests -Dgit.skip=true +COPY pom.xml mvnw* ./ +RUN mvn dependency:go-offline -B +COPY src ./src +RUN mvn clean package -DskipTests -Dgit.skip=true
- Note: skipping tests (
-DskipTests
) speeds up image builds but may mask regressions. Ensure your CI pipeline runs the full test suite.
12-13
: Review removal of default Tomcat applications.Deleting everything under
webapps/*
also removes management and monitoring apps (e.g.,manager
,host-manager
). If you only intend to clear the ROOT context, narrow the command:-RUN rm -rf /usr/local/tomcat/webapps/* +RUN rm -rf /usr/local/tomcat/webapps/ROOT
16-16
: Avoid hardcoding the WAR filename & enhance flexibility.Locking to
adminapi-v3.0.0.war
will break on version bumps. Switch to a wildcard or ARG:- COPY --from=build /app/target/adminapi-v3.0.0.war /usr/local/tomcat/webapps/ROOT.war + ARG WAR_FILE=adminapi-*.war + COPY --from=build /app/target/${WAR_FILE} /usr/local/tomcat/webapps/ROOT.war
18-21
: Enhance container security & observability.
- Run Tomcat as a non-root user (e.g.,
USER tomcat
) to reduce attack surface.- Add a
HEALTHCHECK
so orchestrators can detect unhealthy instances:HEALTHCHECK --interval=30s --timeout=5s \ CMD curl -f http://localhost:8080/ || exit 1
- Optionally declare
VOLUME /usr/local/tomcat/logs
to persist logs outside the container.
Looks fine mostly. Are you able to hit the API and see logs? |
WORKDIR /app | ||
COPY . . | ||
# Skip tests for faster build and skip git plugin issues | ||
RUN mvn clean package -DskipTests -Dgit.skip=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please package this for CI profile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noted.
Oh so, I mean I have researched about it and found So if we don't want the tomcat stack. we can do this: We can build a <packaging>jar</packaging> |
π Description
JIRA ID:
This PR introduces
Docker
support for theAdmin API
application, enabling consistent and containerized builds.This PR resolves issue PSMRI/AMRIT#59
β Type of Change
βΉοΈ Additional Information
Summary by CodeRabbit