From d10f25eb068c4657635eb38b887a725c8b64f079 Mon Sep 17 00:00:00 2001 From: test2 Date: Sat, 6 Jun 2026 22:43:09 +0300 Subject: [PATCH] Fix git safe.directory for mounted /repo in Docker Co-authored-by: Cursor --- Dockerfile | 3 +++ app/deploy_utils.py | 3 ++- docker-compose.yml | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 159693a..8312cee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,6 +20,9 @@ RUN mkdir -p /app/uploads && adduser --disabled-password --gecos "" appuser \ USER appuser ENV FLASK_APP=wsgi:app +ENV GIT_CONFIG_COUNT=1 +ENV GIT_CONFIG_KEY_0=safe.directory +ENV GIT_CONFIG_VALUE_0=/repo EXPOSE 8000 diff --git a/app/deploy_utils.py b/app/deploy_utils.py index d3443ad..9b91524 100644 --- a/app/deploy_utils.py +++ b/app/deploy_utils.py @@ -26,8 +26,9 @@ def run_git(args, timeout=120): if not _repo_ready(): return False, f"Git-репозиторий не найден: {get_repo_path()}" + repo = get_repo_path() result = subprocess.run( - ["git", "-C", get_repo_path()] + args, + ["git", "-c", f"safe.directory={repo}", "-C", repo] + args, capture_output=True, text=True, timeout=timeout, diff --git a/docker-compose.yml b/docker-compose.yml index 173d9ba..8178c27 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,6 +33,9 @@ services: GIT_REPO_PATH: /repo GIT_REMOTE_URL: ${GIT_REMOTE_URL:-https://git.evilfox.cc/test2/fotohost.git} ALLOW_GIT_DEPLOY: ${ALLOW_GIT_DEPLOY:-false} + GIT_CONFIG_COUNT: "1" + GIT_CONFIG_KEY_0: safe.directory + GIT_CONFIG_VALUE_0: /repo volumes: - uploads_data:/app/uploads - .:/repo