Added git installation and version endpoint
In the Dockerfile, a new command has been added to install git. This allows for more flexibility in managing code versions within the container. In addition, a new endpoint '/version' has been introduced in index.php which returns JSON data about the last commit, its timestamp and the current branch. This provides an easy way to check versioning information directly from the application.
This commit is contained in:
parent
f06c804c24
commit
f75be1fcaf
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -8,5 +8,6 @@
|
||||
<body>
|
||||
<h1>404 Uri {{ path }} not found</h1>
|
||||
<p><a href="/metrics">/metrics</a></p>
|
||||
<p><a href="/version">/version</a></p>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user