Compare commits

...

2 Commits

Author SHA1 Message Date
8af61f97b0
Added /config endpoint and link in 404 page
The update includes the addition of a new '/config' endpoint in index.php, which returns the application's configuration as a JSON response. A corresponding link to this new endpoint has also been added to the 404 error page.
2024-06-13 17:43:32 +02:00
f75be1fcaf
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.
2024-06-13 17:42:18 +02:00
3 changed files with 17 additions and 0 deletions

View File

@ -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

View File

@ -6,6 +6,18 @@ 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"] == '/config') {
header('Content-Type: application/json');
require_once getenv('CONFIG_FILE');
echo json_encode($config);
} 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);

View File

@ -8,5 +8,7 @@
<body>
<h1>404 Uri {{ path }} not found</h1>
<p><a href="/metrics">/metrics</a></p>
<p><a href="/config">/config</a></p>
<p><a href="/version">/version</a></p>
</body>
</html>