Dockerfile 3.3 KB

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