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.

140 lines
4.8 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. RUN apt-get update && apt-get install -y \
  2. libfreetype6-dev \
  3. libjpeg62-turbo-dev \
  4. libpng-dev \
  5. libwebp-dev \
  6. && docker-php-ext-install -j$(nproc) iconv \
  7. && docker-php-ext-install mysqli \
  8. && docker-php-ext-enable mysqli
  9. RUN apt-get update && docker-php-ext-install pdo pdo_mysql \
  10. && docker-php-ext-enable pdo pdo_mysql
  11. ###########################################################################
  12. # xDebug:
  13. ###########################################################################
  14. # Copy xdebug configuration for remote debugging
  15. COPY ./xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
  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-2.9.8; \
  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. ###########################################################################
  28. # Zip:
  29. ###########################################################################
  30. ARG INSTALL_ZIP=false
  31. RUN if [ ${INSTALL_ZIP} = true ]; then \
  32. apt update && apt install -y libzip-dev \
  33. && docker-php-ext-install zip \
  34. && docker-php-ext-enable zip \
  35. ;fi
  36. ###########################################################################
  37. # BZ2:
  38. ###########################################################################
  39. ARG INSTALL_BZ2=false
  40. RUN if [ ${INSTALL_BZ2} = true ]; then \
  41. apt update && apt install -y libbz2-ocaml-dev \
  42. && docker-php-ext-install bz2 \
  43. && docker-php-ext-enable bz2 \
  44. ;fi
  45. ###########################################################################
  46. # OPCACHE:
  47. ###########################################################################
  48. ARG INSTALL_OPCACHE=false
  49. RUN if [ ${INSTALL_OPCACHE} = true ]; then \
  50. docker-php-ext-install opcache \
  51. && docker-php-ext-enable opcache \
  52. ;fi
  53. ###########################################################################
  54. # INTL:
  55. ###########################################################################
  56. ARG INSTALL_INTL=false
  57. RUN if [ ${INSTALL_INTL} = true ]; then \
  58. apt update && apt install -y libicu-dev \
  59. && docker-php-ext-install intl \
  60. && docker-php-ext-enable intl \
  61. ;fi
  62. ###########################################################################
  63. # PGSQL:
  64. ###########################################################################
  65. ARG INSTALL_PGSQL=false
  66. RUN if [ ${INSTALL_PGSQL} = true ]; then \
  67. apt update && apt install -y libpq-dev \
  68. && docker-php-ext-install pgsql \
  69. && docker-php-ext-install pdo_pgsql \
  70. ;fi
  71. ###########################################################################
  72. # BCMATH:
  73. ###########################################################################
  74. ARG INSTALL_BCMATH=false
  75. RUN if [ ${INSTALL_BCMATH} = true ]; then \
  76. docker-php-ext-install bcmath \
  77. ;fi
  78. ###########################################################################
  79. # Locales:
  80. ###########################################################################
  81. RUN apt --allow-releaseinfo-change update && \
  82. apt install -y locales && \
  83. sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
  84. sed -i 's/# ru_RU.UTF-8 UTF-8/ru_RU.UTF-8 UTF-8/' /etc/locale.gen && \
  85. locale-gen
  86. ###########################################################################
  87. # Prepend nginx 502 on showing errors:
  88. # @see https://stackoverflow.com/questions/55260221/laravel-php-7-3-nginx-502-upstream-prematurely-closed-fastcgi-stdout
  89. ###########################################################################
  90. RUN sed -i "s/^log_limit = .*/log_limit = 1024/g" "$PHP_INI_DIR/../php-fpm.d/docker.conf"
  91. ###########################################################################
  92. # php.ini opts:
  93. ###########################################################################
  94. # https://github.com/php/php-src/blob/master/php.ini-development
  95. RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
  96. ###########################################################################
  97. # Tune opts:
  98. ###########################################################################
  99. ARG PHP_OPT_MAX_EXECUTION_TIME=600
  100. RUN sed -i "s/^max_execution_time = .*/max_execution_time = $PHP_OPT_MAX_EXECUTION_TIME/g" "$PHP_INI_DIR/php.ini"
  101. ARG PHP_OPT_MEMORY_LIMIT=256M
  102. RUN sed -i "s/^memory_limit = .*/memory_limit = $PHP_OPT_MEMORY_LIMIT/g" "$PHP_INI_DIR/php.ini"
  103. ARG PHP_OPT_POST_MAX_SIZE=48M
  104. RUN sed -i "s/^post_max_size = .*/post_max_size = $PHP_OPT_UPLOAD_MAX_FILESIZE/g" "$PHP_INI_DIR/php.ini"
  105. ARG PHP_OPT_UPLOAD_MAX_FILESIZE=16M
  106. RUN sed -i "s/^upload_max_filesize = .*/upload_max_filesize = $PHP_OPT_UPLOAD_MAX_FILESIZE/g" "$PHP_INI_DIR/php.ini"