custom-prometheus-exporter/dockerfile
Jeroen De Meerleer 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

46 lines
1.3 KiB
Plaintext

# Gebruik een officiële PHP-image met Apache
FROM php:8.3-apache
# Stel de werkdirectory in
WORKDIR /var/www/html
# Kopieer de huidige directory inhoud naar /var/www/html in de container
COPY . /var/www/html
# Installeer Composer
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
# Voer composer install uit om de afhankelijkheden te installeren
RUN composer install
# Stel de poort in die de container zal exposeren
EXPOSE 9050
# Wijzig de Apache configuratie om op poort 9050 te luisteren
RUN sed -i 's/Listen 80/Listen 9050/' /etc/apache2/ports.conf
RUN sed -i 's/<VirtualHost *:80>/<VirtualHost *:9050>/' /etc/apache2/sites-available/000-default.conf
# Voeg environment variables toe aan de Apache configuratie
ENV PHP_BINARY=/usr/local/bin/php
ENV CONFIG_FILE=/var/www/html/config.php
# Activeer mod_rewrite
RUN a2enmod rewrite
# Start de Apache server
RUN mkdir -p /var/www/html/twig_cache
RUN chown -R www-data:www-data /var/www/html
USER www-data
# Start de Apache server
CMD ["apache2-foreground"]