Skip to content

feature/healthcheck - #122#123

Open
EdvinSandgren wants to merge 2 commits intomainfrom
feature/healthcheck
Open

feature/healthcheck - #122#123
EdvinSandgren wants to merge 2 commits intomainfrom
feature/healthcheck

Conversation

@EdvinSandgren
Copy link
Copy Markdown

@EdvinSandgren EdvinSandgren commented Mar 15, 2026

Adds a healthcheck to the Dockerfile to check the status of the server.

Summary by CodeRabbit

  • Chores
    • Added a configurable container port and a regular health-check endpoint to improve deployment monitoring and reliability.
    • Included a small runtime tool to enable the health checks.
    • Startup behavior remains unchanged; changes are operational only.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 15, 2026

📝 Walkthrough

Walkthrough

Dockerfile updated to make the exposed port configurable via ARG PORT, set ENV HEALTHCHECK_PORT from that ARG, install curl in the runtime image, and add a HEALTHCHECK that probes http://localhost:${HEALTHCHECK_PORT}/ (interval 30s, timeout 3s, retries 3).

Changes

Cohort / File(s) Summary
Docker Configuration
Dockerfile
Added ARG PORT and expose via $PORT; set ENV HEALTHCHECK_PORT=${PORT}; installed curl (apk --no-cache add curl) and added HEALTHCHECK that curls http://localhost:${HEALTHCHECK_PORT}/ with interval 30s, timeout 3s, retries 3. Entry point semantics unchanged; formatting tweaks applied.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • Issue #122: Implements the Dockerfile HEALTHCHECK with curl and configurable PORT/HEALTHCHECK_PORT—matches this PR's changes.

Poem

I’m a rabbit in a container, noses twitching free, 🐇
I curl the local endpoint to ensure you run with glee.
Every thirty seconds I knock, three seconds to reply,
Retries count to keep us safe — we’ll hop and never die!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feature/healthcheck - #122' is partially related to the changeset. It mentions the healthcheck feature which is indeed a main component of the changes, but the format includes issue reference (#122) and branch naming convention, making it less clear as a standalone PR title.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/healthcheck
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

You can disable sequence diagrams in the walkthrough.

Disable the reviews.sequence_diagrams setting to disable sequence diagrams in the walkthrough.

@EdvinSandgren EdvinSandgren linked an issue Mar 15, 2026 that may be closed by this pull request
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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 the current code and only fix it if needed.

Inline comments:
In `@Dockerfile`:
- Line 10: The HEALTHCHECK currently hardcodes localhost:8080 and will fail if
the app uses a different runtime port; change the Docker HEALTHCHECK to probe a
port from an environment variable (e.g. ${HEALTHCHECK_PORT} or ${SERVER_PORT})
with a sensible default (8080) so the probe follows the app's configured server
port used in App.java and application.yml; update the HEALTHCHECK directive to
use curl -f http://localhost:${HEALTHCHECK_PORT:-8080}/ (or equivalent shell
expansion) and ensure the Dockerfile documents or sets HEALTHCHECK_PORT to match
the application's SERVER_PORT if that env var is used.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5871b178-bc3e-437b-b4ab-444b8ce9657a

📥 Commits

Reviewing files that changed from the base of the PR and between c473d5b and e059fad.

📒 Files selected for processing (1)
  • Dockerfile

Comment thread Dockerfile Outdated
@mikee13d mikee13d self-requested a review March 17, 2026 10:04
Copy link
Copy Markdown

@mikee13d mikee13d left a comment

Choose a reason for hiding this comment

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

Nice work, just make the changes that coderabbit suggested so the healthcheck is more reliable

Updates Dockerfile to implement changes proposed by CodeRabbit, possibly enabling the port to be configured in future for the container rather than being static
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
Dockerfile (1)

9-10: ⚠️ Potential issue | 🟠 Major

PORT is not wired to the Java process, so healthcheck can still false-fail.

Line 17 probes ${HEALTHCHECK_PORT} (derived from ARG PORT), but Line 20 starts the app without --port. In this codebase, the app port comes from CLI/config (src/main/java/org/example/App.java:10-30) and defaults to 8080 (src/main/java/org/example/config/AppConfig.java:28-44).
So an image built with --build-arg PORT=9090 will healthcheck 9090 while the app may still listen on 8080.

Suggested fix
 ARG PORT=8080
-EXPOSE $PORT
+ENV SERVER_PORT=$PORT
+EXPOSE $SERVER_PORT
@@
-ENV HEALTHCHECK_PORT=$PORT
+ENV HEALTHCHECK_PORT=$SERVER_PORT
 HEALTHCHECK --interval=30s --timeout=3s --retries=3 CMD sh -c 'curl -fsS "http://localhost:${HEALTHCHECK_PORT}/" || exit 1'
@@
-ENTRYPOINT ["java", "-classpath", "/app:/app/dependencies/*", "org.example.App"]
+ENTRYPOINT ["sh", "-c", "exec java -classpath /app:/app/dependencies/* org.example.App --port ${SERVER_PORT}"]

Also applies to: 16-17, 20-20

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Dockerfile` around lines 9 - 10, The Dockerfile exposes ARG PORT but never
wires it into the Java process, causing the HEALTHCHECK_PORT probe to mismatch
the actual server port; update the Dockerfile to export the build arg to an
environment variable (e.g., ENV PORT) and use that ENV when launching the Java
app (add the CLI flag the app reads, e.g., pass --port ${PORT} in the java
-jar/CMD invocation) so the runtime port matches HEALTHCHECK_PORT; ensure the
HEALTHCHECK uses the same ${PORT} env and doesn't rely only on ARG, and verify
this aligns with the app's CLI flag parsed in App.java and the default in
AppConfig.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@Dockerfile`:
- Around line 9-10: The Dockerfile exposes ARG PORT but never wires it into the
Java process, causing the HEALTHCHECK_PORT probe to mismatch the actual server
port; update the Dockerfile to export the build arg to an environment variable
(e.g., ENV PORT) and use that ENV when launching the Java app (add the CLI flag
the app reads, e.g., pass --port ${PORT} in the java -jar/CMD invocation) so the
runtime port matches HEALTHCHECK_PORT; ensure the HEALTHCHECK uses the same
${PORT} env and doesn't rely only on ARG, and verify this aligns with the app's
CLI flag parsed in App.java and the default in AppConfig.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 14eb34c5-0527-422a-a5a1-50753892ed03

📥 Commits

Reviewing files that changed from the base of the PR and between e059fad and b2e50c1.

📒 Files selected for processing (1)
  • Dockerfile

Copy link
Copy Markdown

@alicewersen-rgb alicewersen-rgb left a comment

Choose a reason for hiding this comment

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

The healthcheck is hardcoded to port 8080 while the application port is configurable. This could cause incorrect container health status when the port changes. Consider using the configured server port instead.

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.

🩺 Add HEALTHCHECK to Dockerfile

3 participants