Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(docker): make container startup robust under wrapped execution#197

Open
mattradford wants to merge 1 commit into
I-am-PUID-0:devfrom
mattradford:dev
Open

fix(docker): make container startup robust under wrapped execution#197
mattradford wants to merge 1 commit into
I-am-PUID-0:devfrom
mattradford:dev

Conversation

@mattradford
Copy link
Copy Markdown

@mattradford mattradford commented Apr 23, 2026

Fix container startup fragility under wrapped runtime execution

Summary

Fix container startup fragility by removing runtime Python virtual environment activation and switching to an exec-form Python ENTRYPOINT and HEALTHCHECK. Runtime Python resolution is now handled deterministically via PATH, making startup reliable under CI/CD runners, container wrappers, and orchestration layers.

This:

  • aligns the image with Docker and OCI best practices and ensures deterministic startup across environments.
  • allows Tailscale to be enabled on Unraid.

Why

The previous container startup relied on shell-based runtime logic:

  • /bin/bash -c
  • . /venv/bin/activate

This pattern is fragile because containers are not guaranteed to be started directly by Docker in all environments. CI/CD systems, process supervisors, and orchestration layers may wrap or re-exec the container under /bin/sh, change PID 1 behavior, or alter signal handling.

Under these conditions, shell-dependent ENTRYPOINT logic can fail even though the image builds successfully. This PR removes that failure mode by:

  • Treating the Python virtual environment as a build-time concern
  • Selecting the runtime interpreter via PATH
  • Using exec-form commands exclusively at runtime

Scope

  • Backend API
  • Setup / install flow
  • Config / schema
  • Service orchestration
  • Embedded UI / proxying
  • Docs
  • Other

Testing

What was tested

Testing focused on container runtime behavior rather than application logic:

  • Built the image from a clean environment using the updated Dockerfile
  • Executed the container using exec-form ENTRYPOINT only
  • Verified:
    • The application starts successfully
    • The Python interpreter resolves to /venv/bin/python
    • The HEALTHCHECK executes and reports healthy
    • SIGTERM/SIGINT signals propagate correctly to the Python process

The image was exercised under both direct Docker execution and wrapped execution (representative of CI/CD and supervised runtimes). Startup behavior was consistent in all cases.

Why automated tests were not added

This change affects container startup semantics, not application logic. The failure mode occurs before application code runs and depends on how the container process is launched or wrapped.

Unit or integration tests would not meaningfully validate this behavior. Manual runtime verification is the appropriate validation method for this class of change.

  • Not run (explain below)
  • Manual testing completed
  • Automated tests updated or added

Related Issues

  • Startup failures caused by shell-dependent ENTRYPOINT logic under wrapped execution
  • General container fragility when relying on runtime activate / source

Checklist

  • PR targets dev (unless release automation or exceptional maintainer change)
  • PR title follows Conventional Commits
  • Changes are focused to one logical improvement
  • Documentation updated where behavior changed
  • No secrets or local-only artifacts committed

Notes

  • Builder stages continue to use virtual environment activation at build time only; this is safe and unchanged
  • No application behavior or configuration is altered beyond startup mechanics
  • Improves compatibility with CI/CD runners, supervised containers, and orchestration platforms
  • Follows best practices:
    • Exec-form ENTRYPOINT
    • No runtime shell dependency
    • Deterministic interpreter selection via PATH

Summary by CodeRabbit

  • Chores
    • Streamlined container runtime initialization for improved startup efficiency.
    • Enhanced container health check mechanism.
    • Optimized container build process.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

📝 Walkthrough

Walkthrough

The Dockerfile's final-stage container initialization is refactored to rely on PATH environment variable configuration instead of shell-based virtual environment activation. HEALTHCHECK and ENTRYPOINT commands are converted from shell-based to exec-form commands. A trailing whitespace in a RUN command is removed.

Changes

Cohort / File(s) Summary
Dockerfile virtual environment initialization
Dockerfile
Changed venv activation from shell source-based (bash -c . /venv/bin/activate) to PATH environment variable (ENV PATH="/venv/bin:$PATH"). HEALTHCHECK and ENTRYPOINT updated to exec-form commands executing /healthcheck.pyand/main.py` directly. Trailing whitespace removed in systemstats-builder stage RUN command.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A rabbit hops down the path so clear,
No activation scripts to shed a tear,
The venv now sits right at the start,
Direct and swift—a DevOps art!
Healthchecks and entrypoints now shine bright,
The container flows smoother—what a sight! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: making container startup robust by switching from shell-based to exec-form ENTRYPOINT and PATH-based venv initialization.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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.

@mattradford mattradford changed the title fix(docker): Dockerfile healthcheck and entrypoint commands fix(docker): make container startup robust under wrapped execution Apr 23, 2026
@mattradford
Copy link
Copy Markdown
Author

@coderabbitai review

@mattradford mattradford marked this pull request as ready for review April 23, 2026 19:40
@I-am-PUID-0 I-am-PUID-0 self-assigned this Apr 23, 2026
@I-am-PUID-0
Copy link
Copy Markdown
Owner

GitKraken automatically performed 2 actions

Create your own automations at gitkraken.dev/automations

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

2 participants