# Use the official PHP image with Apache 7.4 FROM php:7.4-apache LABEL Maintainer="kerstin Sieren " \ Description="Lightweight container with Apache & PHP-FPM based on Debian Buster." # Install required system packages and PHP extensions RUN apt-get update && apt-get install -y \ libzip-dev \ libfreetype6-dev \ libjpeg62-turbo-dev \ libpng-dev \ libonig-dev \ libxml2-dev \ libssl-dev \ libxslt1-dev \ libicu-dev \ libpq-dev \ wget \ unzip \ git \ && docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-install -j$(nproc) gd \ && docker-php-ext-install mysqli pdo pdo_mysql mbstring zip xml opcache soap intl xsl # Install the MongoDB extension RUN pecl install mongodb \ && docker-php-ext-enable mongodb # Configure PHP RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \ && echo 'always_populate_raw_post_data = -1\nmax_execution_time = 240\nmax_input_vars = 1500\nupload_max_filesize = 32M\npost_max_size = 32M' > $PHP_INI_DIR/conf.d/typo3.ini # Enable Apache modules RUN a2enmod proxy_fcgi setenvif rewrite ssl RUN groupadd -r ssl-cert && usermod -a -G ssl-cert www-data RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 \ -keyout /etc/ssl/private/apache-selfsigned.key \ -out /etc/ssl/certs/apache-selfsigned.crt \ -subj "/C=US/ST=California/L=San Francisco/O=Localhost/OU=IT Department/CN=localhost" RUN chown -R root:ssl-cert /etc/ssl \ && chmod -R 640 /etc/ssl/private \ && chmod 640 /etc/ssl/private/apache-selfsigned.key # Modify the default-ssl.conf file to use the self-signed SSL certificate and # modify the document root in default-ssl.conf RUN sed -i 's|SSLCertificateFile\t/etc/ssl/certs/ssl-cert-snakeoil.pem|SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt|g' /etc/apache2/sites-available/default-ssl.conf \ && sed -i 's|SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key|SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key|g' /etc/apache2/sites-available/default-ssl.conf \ && sed -i 's|DocumentRoot /var/www/html|DocumentRoot /var/www/html/public|g' /etc/apache2/sites-available/default-ssl.conf \ && sed -i 's|||g' /etc/apache2/sites-available/default-ssl.conf # Modify the document root in 000-default.conf RUN sed -i 's|DocumentRoot /var/www/html|DocumentRoot /var/www/html/public|g' /etc/apache2/sites-available/000-default.conf \ && sed -i 's|||g' /etc/apache2/sites-available/000-default.conf # Set ServerName directive RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf # Grant Apache permission to bind to ports 80 and 443 RUN apt-get install -y libcap2-bin \ && setcap 'cap_net_bind_service=+ep' /usr/sbin/apache2 RUN apt-get clean && \ apt-get -y purge \ libxml2-dev libfreetype6-dev \ libjpeg62-turbo-dev \ libmcrypt-dev \ libpng-dev \ libzip-dev \ zlib1g-dev && \ rm -rf /var/lib/apt/lists/* /usr/src/* # Install Composer RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer # Expose HTTP and HTTPS ports EXPOSE 80 443 # Set the working directory WORKDIR /var/www/html # Start Apache in the foreground CMD ["apache2-foreground"]