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.

142 lines
4.9 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
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. elif [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \
  22. pecl install xdebug-3.1.6; \
  23. else \
  24. pecl install xdebug-2.9.8; \
  25. fi && \
  26. docker-php-ext-enable xdebug && \
  27. sed -i 's/^zend_extension=/;zend_extension=/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
  28. ;fi
  29. ###########################################################################
  30. # Zip:
  31. ###########################################################################
  32. ARG INSTALL_ZIP=false
  33. RUN if [ ${INSTALL_ZIP} = true ]; then \
  34. apt update && apt install -y libzip-dev \
  35. && docker-php-ext-install zip \
  36. && docker-php-ext-enable zip \
  37. ;fi
  38. ###########################################################################
  39. # BZ2:
  40. ###########################################################################
  41. ARG INSTALL_BZ2=false
  42. RUN if [ ${INSTALL_BZ2} = true ]; then \
  43. apt update && apt install -y libbz2-ocaml-dev \
  44. && docker-php-ext-install bz2 \
  45. && docker-php-ext-enable bz2 \
  46. ;fi
  47. ###########################################################################
  48. # OPCACHE:
  49. ###########################################################################
  50. ARG INSTALL_OPCACHE=false
  51. RUN if [ ${INSTALL_OPCACHE} = true ]; then \
  52. docker-php-ext-install opcache \
  53. && docker-php-ext-enable opcache \
  54. ;fi
  55. ###########################################################################
  56. # INTL:
  57. ###########################################################################
  58. ARG INSTALL_INTL=false
  59. RUN if [ ${INSTALL_INTL} = true ]; then \
  60. apt update && apt install -y libicu-dev \
  61. && docker-php-ext-install intl \
  62. && docker-php-ext-enable intl \
  63. ;fi
  64. ###########################################################################
  65. # PGSQL:
  66. ###########################################################################
  67. ARG INSTALL_PGSQL=false
  68. RUN if [ ${INSTALL_PGSQL} = true ]; then \
  69. apt update && apt install -y libpq-dev \
  70. && docker-php-ext-install pgsql \
  71. && docker-php-ext-install pdo_pgsql \
  72. ;fi
  73. ###########################################################################
  74. # BCMATH:
  75. ###########################################################################
  76. ARG INSTALL_BCMATH=false
  77. RUN if [ ${INSTALL_BCMATH} = true ]; then \
  78. docker-php-ext-install bcmath \
  79. ;fi
  80. ###########################################################################
  81. # Locales:
  82. ###########################################################################
  83. RUN apt --allow-releaseinfo-change update && \
  84. apt install -y locales && \
  85. sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
  86. sed -i 's/# ru_RU.UTF-8 UTF-8/ru_RU.UTF-8 UTF-8/' /etc/locale.gen && \
  87. locale-gen
  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"
  93. ###########################################################################
  94. # php.ini opts:
  95. ###########################################################################
  96. # https://github.com/php/php-src/blob/master/php.ini-development
  97. RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
  98. ###########################################################################
  99. # Tune opts:
  100. ###########################################################################
  101. ARG PHP_OPT_MAX_EXECUTION_TIME=600
  102. RUN sed -i "s/^max_execution_time = .*/max_execution_time = $PHP_OPT_MAX_EXECUTION_TIME/g" "$PHP_INI_DIR/php.ini"
  103. ARG PHP_OPT_MEMORY_LIMIT=256M
  104. RUN sed -i "s/^memory_limit = .*/memory_limit = $PHP_OPT_MEMORY_LIMIT/g" "$PHP_INI_DIR/php.ini"
  105. ARG PHP_OPT_POST_MAX_SIZE=48M
  106. RUN sed -i "s/^post_max_size = .*/post_max_size = $PHP_OPT_UPLOAD_MAX_FILESIZE/g" "$PHP_INI_DIR/php.ini"
  107. ARG PHP_OPT_UPLOAD_MAX_FILESIZE=16M
  108. RUN sed -i "s/^upload_max_filesize = .*/upload_max_filesize = $PHP_OPT_UPLOAD_MAX_FILESIZE/g" "$PHP_INI_DIR/php.ini"