Skip to content

Enable non-root Docker runtime for repository creation paths#237

Open
Copilot wants to merge 6 commits into
developfrom
copilot/add-non-root-user-support
Open

Enable non-root Docker runtime for repository creation paths#237
Copilot wants to merge 6 commits into
developfrom
copilot/add-non-root-user-support

Conversation

Copy link
Copy Markdown

Copilot AI commented May 22, 2026

Running Borgitory in Docker as a non-root UID/GID could fail during repo creation because Borg runtime state paths were not guaranteed writable outside root. This change makes container startup resilient to non-root permissions while keeping root behavior unchanged.

  • Entrypoint runtime defaults (non-root-safe)

    • start.sh now requires a writable HOME and fails startup with a descriptive error if HOME is unset or not writable.
    • If BORG_BASE_DIR is unset, startup defaults it to /cache/borg.
    • Startup now fails fast with descriptive errors when BORG_BASE_DIR is not writable.
    • Emoji output was removed from startup/debug/error messages.
  • Image filesystem preparation

    • Docker runtime image now creates /cache alongside /app/data, enabling a predictable mount target for Borg state under non-root users.
  • Compose/docs updates for UID/GID mapping

    • README Docker Compose example now documents optional user: "${UID}:${GID}", adds /cache volume usage, and clarifies setting UID/GID before launch.
# start.sh (effective behavior)
if [ -z "${HOME}" ]; then
  echo "ERROR: HOME is not set..."
  exit 1
fi

if [ -z "${BORG_BASE_DIR}" ]; then
  export BORG_BASE_DIR="/cache/borg"
fi

# fail if not writable

Copilot AI linked an issue May 22, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits May 22, 2026 02:34
Copilot AI changed the title [WIP] Add support for Docker with non-root user Enable non-root Docker runtime for repository creation paths May 22, 2026
Copilot AI requested a review from mlapaglia May 22, 2026 02:37
@mlapaglia
Copy link
Copy Markdown
Owner

@copilot don't fallback to /tmp, just fail to start with a descriptive error message. get rid of the stupid emojis.

Copy link
Copy Markdown
Author

Copilot AI commented May 22, 2026

@copilot don't fallback to /tmp, just fail to start with a descriptive error message. get rid of the stupid emojis.

Updated in commit cfae5ba. start.sh no longer falls back to /tmp; it now fails fast with descriptive errors when HOME or BORG_BASE_DIR are not writable, and I removed emojis from startup/debug/error messages.

@mlapaglia mlapaglia marked this pull request as ready for review May 22, 2026 02:54
Copilot AI review requested due to automatic review settings May 22, 2026 02:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves Borgitory’s Docker startup behavior when running as a non-root UID/GID by ensuring Borg runtime state directories are writable (or failing fast with clear errors), and updating container/docs to support a /cache mount point.

Changes:

  • Add startup checks in start.sh to require writable HOME and BORG_BASE_DIR, defaulting BORG_BASE_DIR to /cache/borg when unset.
  • Create /cache in the runtime image filesystem.
  • Update README Compose example to document optional UID/GID user mapping and a /cache volume.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
start.sh Adds writable-dir checks for HOME and BORG_BASE_DIR, removes emoji from logs.
Dockerfile Creates /cache directory in the runtime image.
README.md Updates Docker Compose example and notes for non-root runs and /cache volume.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread start.sh Outdated
Comment thread start.sh Outdated
Comment thread Dockerfile Outdated
Comment thread README.md Outdated
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.68%. Comparing base (0ee810d) to head (3ffa476).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #237   +/-   ##
========================================
  Coverage    79.68%   79.68%           
========================================
  Files          147      147           
  Lines        13870    13870           
========================================
  Hits         11052    11052           
  Misses        2818     2818           
Flag Coverage Δ
e2e 0.00% <ø> (ø)
integration 45.85% <ø> (ø)
unit 71.17% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

mlapaglia and others added 2 commits May 21, 2026 22:59
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

Docker with non-root user?

4 participants