Dockerfile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # Use the official PHP image with Apache 7.4
  2. FROM php:7.4-apache
  3. LABEL Maintainer="kerstin Sieren <kerstin@sieren.biz>" \
  4. Description="Lightweight container with Apache & PHP-FPM based on Debian Buster."
  5. # Install required system packages and PHP extensions
  6. RUN apt-get update && apt-get install -y \
  7. libzip-dev \
  8. libfreetype6-dev \
  9. libjpeg62-turbo-dev \
  10. libpng-dev \
  11. libonig-dev \
  12. libxml2-dev \
  13. libssl-dev \
  14. libxslt1-dev \
  15. libicu-dev \
  16. libpq-dev \
  17. wget \
  18. unzip \
  19. git \
  20. mc \
  21. && docker-php-ext-configure gd --with-freetype --with-jpeg \
  22. && docker-php-ext-install -j$(nproc) gd \
  23. && docker-php-ext-install mysqli pdo pdo_mysql mbstring zip xml opcache soap intl xsl
  24. # Install the MongoDB extension
  25. RUN pecl install mongodb \
  26. && docker-php-ext-enable mongodb
  27. # Configure PHP
  28. RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" \
  29. && 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
  30. # Enable Apache modules
  31. RUN a2enmod proxy_fcgi setenvif rewrite ssl
  32. RUN groupadd -r ssl-cert && usermod -a -G ssl-cert www-data
  33. RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
  34. -keyout /etc/ssl/private/apache-selfsigned.key \
  35. -out /etc/ssl/certs/apache-selfsigned.crt \
  36. -subj "/C=US/ST=California/L=San Francisco/O=Localhost/OU=IT Department/CN=localhost"
  37. RUN chown -R root:ssl-cert /etc/ssl \
  38. && chmod -R 640 /etc/ssl/private \
  39. && chmod 640 /etc/ssl/private/apache-selfsigned.key
  40. # Modify the default-ssl.conf file to use the self-signed SSL certificate and
  41. # modify the document root in default-ssl.conf
  42. 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 \
  43. && 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 \
  44. && sed -i 's|DocumentRoot /var/www/html|DocumentRoot /var/www/html/public|g' /etc/apache2/sites-available/default-ssl.conf \
  45. && sed -i 's|<Directory /var/www/html>|<Directory /var/www/html/public>|g' /etc/apache2/sites-available/default-ssl.conf
  46. # Modify the document root in 000-default.conf
  47. RUN sed -i 's|DocumentRoot /var/www/html|DocumentRoot /var/www/html/public|g' /etc/apache2/sites-available/000-default.conf \
  48. && sed -i 's|<Directory /var/www/html>|<Directory /var/www/html/public>|g' /etc/apache2/sites-available/000-default.conf
  49. # Set ServerName directive
  50. RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
  51. # Grant Apache permission to bind to ports 80 and 443
  52. RUN apt-get install -y libcap2-bin \
  53. && setcap 'cap_net_bind_service=+ep' /usr/sbin/apache2
  54. RUN apt-get clean && \
  55. apt-get -y purge \
  56. libxml2-dev libfreetype6-dev \
  57. libjpeg62-turbo-dev \
  58. libmcrypt-dev \
  59. libpng-dev \
  60. libzip-dev \
  61. zlib1g-dev && \
  62. rm -rf /var/lib/apt/lists/* /usr/src/*
  63. # Install Composer
  64. RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
  65. # Expose HTTP and HTTPS ports
  66. EXPOSE 80 443
  67. # Set the working directory
  68. WORKDIR /var/www/html
  69. # Start Apache in the foreground
  70. CMD ["apache2-foreground"]