From 0f50e874d432f2a651875d2b1747d54bef027bb7 Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Thu, 13 Jun 2024 13:42:19 +0200 Subject: [PATCH] Added Dockerfile for PHP with Apache This commit introduces a new Dockerfile that sets up a PHP 8.3 environment with Apache. It includes the following significant changes: - Sets the working directory to /var/www/html - Copies current directory contents into the container - Installs Composer and activates mod_rewrite - Installs Process Control extension using curl command - Runs composer install to fetch dependencies - Exposes port 9050 and modifies Apache configuration to listen on this port - Adds environment variables to Apache configuration - Changes ownership of /var/www/html to www-data user - Starts the Apache server using apache2-foreground command --- dockerfile | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 dockerfile diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..4bb7165 --- /dev/null +++ b/dockerfile @@ -0,0 +1,42 @@ +# 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 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///' /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"]