diff --git a/dockerfile b/dockerfile index 4bb7165..371f68b 100644 --- a/dockerfile +++ b/dockerfile @@ -13,6 +13,9 @@ COPY --from=composer:latest /usr/bin/composer /usr/bin/composer # Activeer mod_rewrite RUN a2enmod rewrite +# Installeer git +RUN DEBIAN_FRONTEND=noninteractive apt update && apt install -y git + # Installeer de Process Control extension RUN curl -sSL https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions -o - | sh -s pcntl zip diff --git a/index.php b/index.php index 441d62d..0d7825a 100644 --- a/index.php +++ b/index.php @@ -6,6 +6,14 @@ if($_SERVER["REQUEST_URI"] == '/metrics') { $phpbin = getenv('PHP_BINARY'); $output = shell_exec('CONFIG_FILE="' . $config . '" ' . $phpbin . ' ' . $_SERVER['DOCUMENT_ROOT'] . 'script.php'); echo $output; +} elseif ($_SERVER["REQUEST_URI"] == '/version') { + header('Content-Type: application/json'); + $git = [ + 'lastCommit' => trim(shell_exec('git rev-parse HEAD')), + 'lastCommitTimestamp' => trim(shell_exec('git log -1 --format=%cd')), + 'branch' => trim(shell_exec('git rev-parse --abbrev-ref HEAD')), + ]; + echo json_encode($git); } else { require_once('vendor/autoload.php'); http_response_code(404); diff --git a/templates/404.twig b/templates/404.twig index f0b30e9..76ee3af 100644 --- a/templates/404.twig +++ b/templates/404.twig @@ -8,5 +8,6 @@

404 Uri {{ path }} not found

/metrics

+

/version

\ No newline at end of file