From 419ff10dc737425210ce9394a69db3f3e78efa90 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 May 2026 02:31:45 +0000 Subject: [PATCH 1/6] Initial plan From 5f46c4fb0eb0ff52de2c749ddcc074fc1c1a1e91 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 May 2026 02:34:32 +0000 Subject: [PATCH 2/6] fix: support docker startup with non-root users Agent-Logs-Url: https://github.com/mlapaglia/Borgitory/sessions/07e190b9-f50a-4195-8bcf-582b6672d7b4 Co-authored-by: mlapaglia <4184746+mlapaglia@users.noreply.github.com> --- Dockerfile | 3 ++- README.md | 5 +++++ start.sh | 12 ++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 2647a110..787c0db0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -83,7 +83,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ python3-pyfuse3=${PYFUSE3_VERSION} \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ - && mkdir -p /app/data + && mkdir -p /app/data /cache \ + && chmod 0777 /app/data /cache COPY --from=builder /opt/venv /opt/venv diff --git a/README.md b/README.md index 19ce4d78..b6dd02ed 100644 --- a/README.md +++ b/README.md @@ -53,8 +53,11 @@ Borgitory is a comprehensive web-based management interface for BorgBackup repos image: mlapaglia/borgitory:latest ports: - "8000:8000" + # Optional: run as your host user to avoid root-owned files + # user: "${UID}:${GID}" volumes: - ./data:/app/data # database and encryption key location + - ./cache:/cache # borg cache/config/security directories - /path/to/backup/sources:/sources:ro - /path/to/any/backup/repos:/repos:ro cap_add: @@ -68,6 +71,8 @@ Borgitory is a comprehensive web-based management interface for BorgBackup repos docker-compose up -d ``` + When running with a non-root container user, ensure mounted directories are writable by that user. + 2. **Access the web interface** - Open in your browser - Create your first admin account on initial setup diff --git a/start.sh b/start.sh index 4eacf11e..e7acb10b 100644 --- a/start.sh +++ b/start.sh @@ -2,6 +2,18 @@ echo "🚀 Starting Borgitory with HTTP on port 8000" +export HOME="${HOME:-/tmp}" +mkdir -p "${HOME}" + +if [ -z "${BORG_BASE_DIR}" ]; then + if mkdir -p /cache/borg 2>/dev/null; then + export BORG_BASE_DIR="/cache/borg" + else + export BORG_BASE_DIR="/tmp/borg" + mkdir -p "${BORG_BASE_DIR}" + fi +fi + if [ "$BORGITORY_DEBUG" = "true" ]; then echo "🐛 Debug mode: Debugger listening on port 5678" python -m debugpy --listen 0.0.0.0:5678 --wait-for-client -m borgitory.cli serve --host 0.0.0.0 --port 8000 From 2b69f2601a461a422faa4951642319b3664f4b17 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 May 2026 02:37:16 +0000 Subject: [PATCH 3/6] docs: clarify UID/GID note for non-root compose usage Agent-Logs-Url: https://github.com/mlapaglia/Borgitory/sessions/07e190b9-f50a-4195-8bcf-582b6672d7b4 Co-authored-by: mlapaglia <4184746+mlapaglia@users.noreply.github.com> --- Dockerfile | 3 +-- README.md | 3 ++- start.sh | 23 ++++++++++++++++++++--- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 787c0db0..98f2d41e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -83,8 +83,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ python3-pyfuse3=${PYFUSE3_VERSION} \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ - && mkdir -p /app/data /cache \ - && chmod 0777 /app/data /cache + && mkdir -p /app/data /cache COPY --from=builder /opt/venv /opt/venv diff --git a/README.md b/README.md index b6dd02ed..1cb36964 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Borgitory is a comprehensive web-based management interface for BorgBackup repos image: mlapaglia/borgitory:latest ports: - "8000:8000" - # Optional: run as your host user to avoid root-owned files + # Optional: run as your host user to avoid root-owned files (set UID/GID first) # user: "${UID}:${GID}" volumes: - ./data:/app/data # database and encryption key location @@ -72,6 +72,7 @@ Borgitory is a comprehensive web-based management interface for BorgBackup repos ``` When running with a non-root container user, ensure mounted directories are writable by that user. + On Linux you can set these variables with `export UID=$(id -u) GID=$(id -g)` before starting Compose. 2. **Access the web interface** - Open in your browser diff --git a/start.sh b/start.sh index e7acb10b..06919551 100644 --- a/start.sh +++ b/start.sh @@ -1,16 +1,33 @@ #!/bin/bash +ensure_writable_dir() { + mkdir -p "$1" 2>/dev/null && [ -w "$1" ] +} + echo "🚀 Starting Borgitory with HTTP on port 8000" export HOME="${HOME:-/tmp}" -mkdir -p "${HOME}" +if ! ensure_writable_dir "${HOME}"; then + if [ "${HOME}" != "/tmp" ]; then + echo "⚠️ Unable to use HOME=${HOME}, falling back to /tmp" + fi + export HOME="/tmp" + if ! ensure_writable_dir "${HOME}"; then + echo "❌ Unable to create writable HOME directory at /tmp" + exit 1 + fi +fi if [ -z "${BORG_BASE_DIR}" ]; then - if mkdir -p /cache/borg 2>/dev/null; then + if ensure_writable_dir /cache/borg; then export BORG_BASE_DIR="/cache/borg" else + echo "⚠️ Unable to use writable /cache/borg, falling back to /tmp/borg for Borg state" export BORG_BASE_DIR="/tmp/borg" - mkdir -p "${BORG_BASE_DIR}" + if ! ensure_writable_dir "${BORG_BASE_DIR}"; then + echo "❌ Unable to create writable Borg base directory at ${BORG_BASE_DIR}" + exit 1 + fi fi fi From cfae5ba6d32fda459a9dd4a32ead23b328cba58c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 22 May 2026 02:49:18 +0000 Subject: [PATCH 4/6] fix: fail fast on non-writable runtime dirs in start script Agent-Logs-Url: https://github.com/mlapaglia/Borgitory/sessions/513810e4-ad8c-44fe-af8c-9ea05384bebe Co-authored-by: mlapaglia <4184746+mlapaglia@users.noreply.github.com> --- start.sh | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/start.sh b/start.sh index 06919551..b19bd8ce 100644 --- a/start.sh +++ b/start.sh @@ -4,35 +4,29 @@ ensure_writable_dir() { mkdir -p "$1" 2>/dev/null && [ -w "$1" ] } -echo "🚀 Starting Borgitory with HTTP on port 8000" +echo "Starting Borgitory with HTTP on port 8000" + +if [ -z "${HOME}" ]; then + echo "ERROR: HOME is not set. Set HOME to a writable directory for Borg runtime files." + exit 1 +fi -export HOME="${HOME:-/tmp}" if ! ensure_writable_dir "${HOME}"; then - if [ "${HOME}" != "/tmp" ]; then - echo "⚠️ Unable to use HOME=${HOME}, falling back to /tmp" - fi - export HOME="/tmp" - if ! ensure_writable_dir "${HOME}"; then - echo "❌ Unable to create writable HOME directory at /tmp" - exit 1 - fi + echo "ERROR: HOME=${HOME} is not writable. Set HOME to a writable directory." + exit 1 fi if [ -z "${BORG_BASE_DIR}" ]; then - if ensure_writable_dir /cache/borg; then - export BORG_BASE_DIR="/cache/borg" - else - echo "⚠️ Unable to use writable /cache/borg, falling back to /tmp/borg for Borg state" - export BORG_BASE_DIR="/tmp/borg" - if ! ensure_writable_dir "${BORG_BASE_DIR}"; then - echo "❌ Unable to create writable Borg base directory at ${BORG_BASE_DIR}" - exit 1 - fi - fi + export BORG_BASE_DIR="/cache/borg" +fi + +if ! ensure_writable_dir "${BORG_BASE_DIR}"; then + echo "ERROR: BORG_BASE_DIR=${BORG_BASE_DIR} is not writable. Set BORG_BASE_DIR to a writable directory." + exit 1 fi if [ "$BORGITORY_DEBUG" = "true" ]; then - echo "🐛 Debug mode: Debugger listening on port 5678" + echo "Debug mode: Debugger listening on port 5678" python -m debugpy --listen 0.0.0.0:5678 --wait-for-client -m borgitory.cli serve --host 0.0.0.0 --port 8000 else exec borgitory serve --host 0.0.0.0 --port 8000 From 6ff5095db8e17fcdc27794a916e3eba573f29c4c Mon Sep 17 00:00:00 2001 From: Matt LaPaglia Date: Thu, 21 May 2026 22:59:56 -0400 Subject: [PATCH 5/6] Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- README.md | 2 +- start.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1cb36964..be8e9ce7 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Borgitory is a comprehensive web-based management interface for BorgBackup repos ``` When running with a non-root container user, ensure mounted directories are writable by that user. - On Linux you can set these variables with `export UID=$(id -u) GID=$(id -g)` before starting Compose. + On Linux you can set these variables with `export UID; export GID=$(id -g)` before starting Compose. 2. **Access the web interface** - Open in your browser diff --git a/start.sh b/start.sh index b19bd8ce..8c7f40b2 100644 --- a/start.sh +++ b/start.sh @@ -1,7 +1,7 @@ #!/bin/bash ensure_writable_dir() { - mkdir -p "$1" 2>/dev/null && [ -w "$1" ] + mkdir -p "$1" 2>/dev/null && [ -d "$1" ] && [ -w "$1" ] && [ -x "$1" ] } echo "Starting Borgitory with HTTP on port 8000" @@ -27,7 +27,7 @@ fi if [ "$BORGITORY_DEBUG" = "true" ]; then echo "Debug mode: Debugger listening on port 5678" - python -m debugpy --listen 0.0.0.0:5678 --wait-for-client -m borgitory.cli serve --host 0.0.0.0 --port 8000 + exec python -m debugpy --listen 0.0.0.0:5678 --wait-for-client -m borgitory.cli serve --host 0.0.0.0 --port 8000 else exec borgitory serve --host 0.0.0.0 --port 8000 fi \ No newline at end of file From 3ffa4763adaf7cbe57ad44e064260f2beb726863 Mon Sep 17 00:00:00 2001 From: Matt LaPaglia Date: Thu, 21 May 2026 23:00:36 -0400 Subject: [PATCH 6/6] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 98f2d41e..5e9d6a4b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -83,7 +83,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ python3-pyfuse3=${PYFUSE3_VERSION} \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ - && mkdir -p /app/data /cache + && mkdir -p /app/data /cache \ + && chmod 1777 /cache COPY --from=builder /opt/venv /opt/venv