Fix updater git dubious ownership

This commit is contained in:
Peter Smit
2025-01-16 16:35:02 +01:00
parent 09d79f6587
commit a32ebbfac2
2 changed files with 9 additions and 3 deletions

View File

@@ -6,4 +6,4 @@ services:
env_file:
- .env
volumes:
- ${DOCKER_CONFIG_DIR}:/config
- ${DOCKER_CONFIG_DIR}:${DOCKER_CONFIG_DIR}

View File

@@ -9,6 +9,12 @@ if (empty($secret_key)) {
exit();
}
$docker_config_dir = getenv('DOCKER_CONFIG_DIR');
if (empty($docker_config_dir)) {
error_log('FAILED - docker config dir missing from environment');
exit();
}
// check for POST request
if ($_SERVER['REQUEST_METHOD'] != 'POST') {
error_log('FAILED - not POST - ' . $_SERVER['REQUEST_METHOD']);
@@ -60,9 +66,9 @@ if (json_last_error() !== JSON_ERROR_NONE) {
// success, log something without error_log
error_log('SUCCESS - ' . $decoded['ref']);
chdir('/config');
chdir($docker_config_dir);
exec('git pull');
exec('docker compose up -d --quiet-pull > /proc/1/fd/1 2>/proc/1/fd/2 &');
exec('docker compose up -d --quiet-pull > /dev/stdout 2>/dev/stderr &');
// send return code and text message
http_response_code(200);