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.

127 lines
4.4 KiB

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