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
This commit is contained in:
Jeroen De Meerleer 2024-06-13 13:42:19 +02:00
parent f367958d69
commit 0f50e874d4
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6

42
dockerfile Normal file
View File

@ -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/<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"]