You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
4.4 KiB

4 years ago
  1. FROM php:7.1-fpm
  2. RUN apt-get update && apt-get install -y \
  3. libfreetype6-dev \
  4. libjpeg62-turbo-dev \
  5. libpng-dev \
  6. && docker-php-ext-install -j$(nproc) iconv \
  7. && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
  8. && docker-php-ext-install -j$(nproc) gd \
  9. && docker-php-ext-install mysqli \
  10. && docker-php-ext-enable mysqli
  11. RUN apt-get update && docker-php-ext-install pdo pdo_mysql && docker-php-ext-enable pdo pdo_mysql
  12. ###########################################################################
  13. # xDebug:
  14. ###########################################################################
  15. ARG INSTALL_XDEBUG=false
  16. RUN if [ ${INSTALL_XDEBUG} = true ]; then \
  17. # Install the xdebug extension
  18. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  19. pecl install xdebug-2.5.5; \
  20. else \
  21. pecl install xdebug; \
  22. fi && \
  23. docker-php-ext-enable xdebug && \
  24. sed -i 's/^zend_extension=/;zend_extension=/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
  25. ;fi
  26. # Copy xdebug configuration for remote debugging
  27. COPY ./xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
  28. RUN sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /usr/local/etc/php/conf.d/xdebug.ini && \
  29. sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /usr/local/etc/php/conf.d/xdebug.ini && \
  30. sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /usr/local/etc/php/conf.d/xdebug.ini
  31. ###########################################################################
  32. # Redis and igbinary:
  33. ###########################################################################
  34. ARG INSTALL_REDIS=false
  35. RUN if [ ${INSTALL_REDIS} = true ]; then \
  36. pecl install igbinary \
  37. && pecl install -a redis \
  38. && docker-php-ext-enable igbinary redis \
  39. ;fi
  40. ###########################################################################
  41. # Zip:
  42. ###########################################################################
  43. ARG INSTALL_ZIP=false
  44. RUN if [ ${INSTALL_ZIP} = true ]; then \
  45. apt update && apt install -y libzip-dev \
  46. && docker-php-ext-install zip \
  47. && docker-php-ext-enable zip \
  48. ;fi
  49. ###########################################################################
  50. # Pear Mail and Mail_Mime:
  51. ###########################################################################
  52. ARG INSTALL_PEAR_MAIL=false
  53. RUN if [ ${INSTALL_PEAR_MAIL} = true ]; then \
  54. pear install Mail && pear install Mail_Mime \
  55. ;fi
  56. ###########################################################################
  57. # BZ2 function:
  58. ###########################################################################
  59. ARG INSTALL_BZ2=false
  60. RUN if [ ${INSTALL_BZ2} = true ]; then \
  61. apt update && apt install -y libbz2-ocaml-dev \
  62. && docker-php-ext-install bz2 \
  63. && docker-php-ext-enable bz2 \
  64. ;fi
  65. ###########################################################################
  66. # INTL function:
  67. ###########################################################################
  68. ARG INSTALL_INTL=false
  69. RUN if [ ${INSTALL_INTL} = true ]; then \
  70. apt update && apt install -y libicu-dev \
  71. && docker-php-ext-install intl \
  72. && docker-php-ext-enable intl \
  73. ;fi
  74. ###########################################################################
  75. # php.ini opts:
  76. ###########################################################################
  77. # https://github.com/php/php-src/blob/master/php.ini-development
  78. RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
  79. ARG PHP_OPT_SHORT_OPEN_TAG=Off
  80. RUN sed -i "s/^short_open_tag = .*/short_open_tag = $PHP_OPT_SHORT_OPEN_TAG/g" "$PHP_INI_DIR/php.ini"
  81. ARG PHP_OPT_MAX_EXECUTION_TIME=30
  82. RUN sed -i "s/^max_execution_time = .*/max_execution_time = $PHP_OPT_MAX_EXECUTION_TIME/g" "$PHP_INI_DIR/php.ini"
  83. ARG PHP_OPT_MEMORY_LIMIT=128M
  84. RUN sed -i "s/^memory_limit = .*/memory_limit = $PHP_OPT_MEMORY_LIMIT/g" "$PHP_INI_DIR/php.ini"
  85. ARG PHP_OPT_UPLOAD_MAX_FILESIZE=2M
  86. RUN sed -i "s/^upload_max_filesize = .*/upload_max_filesize = $PHP_OPT_UPLOAD_MAX_FILESIZE/g" "$PHP_INI_DIR/php.ini"
  87. ###########################################################################
  88. # Prepend nginx 502 on showing errors:
  89. # @see https://stackoverflow.com/questions/55260221/laravel-php-7-3-nginx-502-upstream-prematurely-closed-fastcgi-stdout
  90. ###########################################################################
  91. RUN sed -i "s/^log_limit = .*/log_limit = 1024/g" "$PHP_INI_DIR/../php-fpm.d/docker.conf"