Dockerfile 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075
  1. #
  2. #--------------------------------------------------------------------------
  3. # Image Setup
  4. #--------------------------------------------------------------------------
  5. #
  6. # To edit the 'php-fpm' base Image, visit its repository on Github
  7. # https://github.com/Laradock/php-fpm
  8. #
  9. # To change its version, see the available Tags on the Docker Hub:
  10. # https://hub.docker.com/r/laradock/php-fpm/tags/
  11. #
  12. # Note: Base Image name format {image-tag}-{php-version}
  13. #
  14. ARG LARADOCK_PHP_VERSION
  15. ARG BASE_IMAGE_TAG_PREFIX=latest
  16. FROM laradock/php-fpm:${BASE_IMAGE_TAG_PREFIX}-${LARADOCK_PHP_VERSION}
  17. LABEL maintainer="Mahmoud Zalt <mahmoud@zalt.me>"
  18. ARG LARADOCK_PHP_VERSION
  19. # Set Environment Variables
  20. ENV DEBIAN_FRONTEND noninteractive
  21. # If you're in China, or you need to change sources, will be set CHANGE_SOURCE to true in .env.
  22. ARG CHANGE_SOURCE=false
  23. RUN if [ ${CHANGE_SOURCE} = true ]; then \
  24. # Change application source from deb.debian.org to aliyun source
  25. sed -i 's/deb.debian.org/mirrors.aliyun.com/' /etc/apt/sources.list && \
  26. sed -i 's/security.debian.org/mirrors.aliyun.com/' /etc/apt/sources.list && \
  27. sed -i 's/security-cdn.debian.org/mirrors.aliyun.com/' /etc/apt/sources.list \
  28. ;fi
  29. # always run apt update when start and after add new source list, then clean up at end.
  30. RUN set -xe; \
  31. apt-get update -yqq && \
  32. pecl channel-update pecl.php.net && \
  33. apt-get install -yqq \
  34. apt-utils \
  35. #
  36. #--------------------------------------------------------------------------
  37. # Mandatory Software's Installation
  38. #--------------------------------------------------------------------------
  39. #
  40. # Mandatory Software's such as ("mcrypt", "pdo_mysql", "libssl-dev", ....)
  41. # are installed on the base image 'laradock/php-fpm' image. If you want
  42. # to add more Software's or remove existing one, you need to edit the
  43. # base image (https://github.com/Laradock/php-fpm).
  44. #
  45. # next lines are here becase there is no auto build on dockerhub see https://github.com/laradock/laradock/pull/1903#issuecomment-463142846
  46. libzip-dev zip unzip && \
  47. if [ ${LARADOCK_PHP_VERSION} = "7.3" ] || [ ${LARADOCK_PHP_VERSION} = "7.4" ] || [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \
  48. docker-php-ext-configure zip; \
  49. else \
  50. docker-php-ext-configure zip --with-libzip; \
  51. fi && \
  52. # Install the zip extension
  53. docker-php-ext-install zip && \
  54. php -m | grep -q 'zip'
  55. #
  56. #--------------------------------------------------------------------------
  57. # Optional Software's Installation
  58. #--------------------------------------------------------------------------
  59. #
  60. # Optional Software's will only be installed if you set them to `true`
  61. # in the `docker-compose.yml` before the build.
  62. # Example:
  63. # - INSTALL_SOAP=true
  64. #
  65. ###########################################################################
  66. # BZ2:
  67. ###########################################################################
  68. ARG INSTALL_BZ2=false
  69. RUN if [ ${INSTALL_BZ2} = true ]; then \
  70. apt-get -y install libbz2-dev; \
  71. docker-php-ext-install bz2 \
  72. ;fi
  73. ###########################################################################
  74. # GMP (GNU Multiple Precision):
  75. ###########################################################################
  76. ARG INSTALL_GMP=false
  77. RUN if [ ${INSTALL_GMP} = true ]; then \
  78. # Install the GMP extension
  79. apt-get install -y libgmp-dev && \
  80. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  81. ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h \
  82. ;fi && \
  83. docker-php-ext-install gmp \
  84. ;fi
  85. ###########################################################################
  86. # SSH2:
  87. ###########################################################################
  88. ARG INSTALL_SSH2=false
  89. RUN if [ ${INSTALL_SSH2} = true ]; then \
  90. # Install the ssh2 extension
  91. apt-get -y install libssh2-1-dev && \
  92. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  93. pecl install -a ssh2-0.13; \
  94. else \
  95. pecl install -a ssh2-1.2; \
  96. fi && \
  97. docker-php-ext-enable ssh2 \
  98. ;fi
  99. ###########################################################################
  100. # libfaketime:
  101. ###########################################################################
  102. USER root
  103. ARG INSTALL_FAKETIME=false
  104. RUN if [ ${INSTALL_FAKETIME} = true ]; then \
  105. apt-get install -y libfaketime \
  106. ;fi
  107. ###########################################################################
  108. # SOAP:
  109. ###########################################################################
  110. ARG INSTALL_SOAP=false
  111. RUN if [ ${INSTALL_SOAP} = true ]; then \
  112. # Install the soap extension
  113. rm /etc/apt/preferences.d/no-debian-php && \
  114. apt-get -y install libxml2-dev php-soap && \
  115. docker-php-ext-install soap \
  116. ;fi
  117. ###########################################################################
  118. # XSL:
  119. ###########################################################################
  120. ARG INSTALL_XSL=false
  121. RUN if [ ${INSTALL_XSL} = true ]; then \
  122. # Install the xsl extension
  123. apt-get -y install libxslt-dev && \
  124. docker-php-ext-install xsl \
  125. ;fi
  126. ###########################################################################
  127. # pgsql
  128. ###########################################################################
  129. ARG INSTALL_PGSQL=false
  130. RUN if [ ${INSTALL_PGSQL} = true ]; then \
  131. # Install the pgsql extension
  132. docker-php-ext-install pgsql \
  133. ;fi
  134. ###########################################################################
  135. # pgsql client
  136. ###########################################################################
  137. ARG INSTALL_PG_CLIENT=false
  138. ARG INSTALL_POSTGIS=false
  139. RUN if [ ${INSTALL_PG_CLIENT} = true ]; then \
  140. # Create folders if not exists (https://github.com/tianon/docker-brew-debian/issues/65)
  141. mkdir -p /usr/share/man/man1 && \
  142. mkdir -p /usr/share/man/man7 && \
  143. # Install the pgsql client
  144. apt-get install -y postgresql-client && \
  145. if [ ${INSTALL_POSTGIS} = true ]; then \
  146. apt-get install -y postgis; \
  147. fi \
  148. ;fi
  149. ###########################################################################
  150. # xDebug:
  151. ###########################################################################
  152. ARG INSTALL_XDEBUG=false
  153. RUN if [ ${INSTALL_XDEBUG} = true ]; then \
  154. # Install the xdebug extension
  155. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \
  156. pecl install xdebug-3.0.0; \
  157. else \
  158. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  159. pecl install xdebug-2.5.5; \
  160. else \
  161. if [ $(php -r "echo PHP_MINOR_VERSION;") = "0" ]; then \
  162. pecl install xdebug-2.9.0; \
  163. else \
  164. pecl install xdebug-2.9.8; \
  165. fi \
  166. fi \
  167. fi && \
  168. docker-php-ext-enable xdebug \
  169. ;fi
  170. # Copy xdebug configuration for remote debugging
  171. COPY ./xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
  172. RUN if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \
  173. sed -i "s/xdebug.remote_host=/xdebug.client_host=/" /usr/local/etc/php/conf.d/xdebug.ini && \
  174. sed -i "s/xdebug.remote_connect_back=0/xdebug.discover_client_host=false/" /usr/local/etc/php/conf.d/xdebug.ini && \
  175. sed -i "s/xdebug.remote_port=9000/xdebug.client_port=9003/" /usr/local/etc/php/conf.d/xdebug.ini && \
  176. sed -i "s/xdebug.profiler_enable=0/; xdebug.profiler_enable=0/" /usr/local/etc/php/conf.d/xdebug.ini && \
  177. sed -i "s/xdebug.profiler_output_dir=/xdebug.output_dir=/" /usr/local/etc/php/conf.d/xdebug.ini && \
  178. sed -i "s/xdebug.remote_mode=req/; xdebug.remote_mode=req/" /usr/local/etc/php/conf.d/xdebug.ini && \
  179. sed -i "s/xdebug.remote_autostart=0/xdebug.start_with_request=yes/" /usr/local/etc/php/conf.d/xdebug.ini && \
  180. sed -i "s/xdebug.remote_enable=0/xdebug.mode=debug/" /usr/local/etc/php/conf.d/xdebug.ini \
  181. ;else \
  182. sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /usr/local/etc/php/conf.d/xdebug.ini && \
  183. sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /usr/local/etc/php/conf.d/xdebug.ini \
  184. ;fi
  185. RUN sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /usr/local/etc/php/conf.d/xdebug.ini
  186. ###########################################################################
  187. # pcov:
  188. ###########################################################################
  189. USER root
  190. ARG INSTALL_PCOV=false
  191. RUN if [ ${INSTALL_PCOV} = true ]; then \
  192. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ]; then \
  193. if [ $(php -r "echo PHP_MINOR_VERSION;") != "0" ]; then \
  194. pecl install pcov && \
  195. docker-php-ext-enable pcov \
  196. ;fi \
  197. ;fi \
  198. ;fi
  199. ###########################################################################
  200. # Phpdbg:
  201. ###########################################################################
  202. ARG INSTALL_PHPDBG=false
  203. RUN if [ ${INSTALL_PHPDBG} = true ]; then \
  204. # Load the xdebug extension only with phpunit commands
  205. apt-get install -y --force-yes php${LARADOCK_PHP_VERSION}-phpdbg \
  206. ;fi
  207. ###########################################################################
  208. # Blackfire:
  209. ###########################################################################
  210. ARG INSTALL_BLACKFIRE=false
  211. RUN if [ ${INSTALL_XDEBUG} = false -a ${INSTALL_BLACKFIRE} = true ]; then \
  212. version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
  213. && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \
  214. && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp \
  215. && mv /tmp/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \
  216. && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \
  217. ;fi
  218. ###########################################################################
  219. # PHP REDIS EXTENSION
  220. ###########################################################################
  221. ARG INSTALL_PHPREDIS=false
  222. RUN if [ ${INSTALL_PHPREDIS} = true ]; then \
  223. # Install Php Redis Extension
  224. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  225. pecl install -o -f redis-4.3.0; \
  226. else \
  227. pecl install -o -f redis; \
  228. fi \
  229. && rm -rf /tmp/pear \
  230. && docker-php-ext-enable redis \
  231. ;fi
  232. ###########################################################################
  233. # Swoole EXTENSION
  234. ###########################################################################
  235. ARG INSTALL_SWOOLE=false
  236. RUN if [ ${INSTALL_SWOOLE} = true ]; then \
  237. # Install Php Swoole Extension
  238. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  239. pecl install swoole-2.0.10; \
  240. else \
  241. if [ $(php -r "echo PHP_MINOR_VERSION;") = "0" ]; then \
  242. pecl install swoole-2.2.0; \
  243. else \
  244. pecl install swoole; \
  245. fi \
  246. fi && \
  247. docker-php-ext-enable swoole \
  248. && php -m | grep -q 'swoole' \
  249. ;fi
  250. ###########################################################################
  251. # Taint EXTENSION
  252. ###########################################################################
  253. ARG INSTALL_TAINT=false
  254. RUN if [ ${INSTALL_TAINT} = true ]; then \
  255. # Install Php TAINT Extension
  256. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ]; then \
  257. pecl install taint && \
  258. docker-php-ext-enable taint && \
  259. php -m | grep -q 'taint'; \
  260. fi \
  261. ;fi
  262. ###########################################################################
  263. # MongoDB:
  264. ###########################################################################
  265. ARG INSTALL_MONGO=false
  266. RUN if [ ${INSTALL_MONGO} = true ]; then \
  267. # Install the mongodb extension
  268. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  269. pecl install mongo && \
  270. docker-php-ext-enable mongo \
  271. ;else \
  272. pecl install mongodb && \
  273. docker-php-ext-enable mongodb \
  274. ;fi \
  275. ;fi
  276. ###########################################################################
  277. # Xhprof:
  278. ###########################################################################
  279. ARG INSTALL_XHPROF=false
  280. RUN if [ ${INSTALL_XHPROF} = true ]; then \
  281. # Install the php xhprof extension
  282. if [ $(php -r "echo PHP_MAJOR_VERSION;") = 7 ]; then \
  283. curl -L -o /tmp/xhprof.tar.gz "https://github.com/tideways/php-xhprof-extension/archive/v5.0.1.tar.gz"; \
  284. else \
  285. curl -L -o /tmp/xhprof.tar.gz "https://codeload.github.com/phacility/xhprof/tar.gz/master"; \
  286. fi \
  287. && mkdir -p xhprof \
  288. && tar -C xhprof -zxvf /tmp/xhprof.tar.gz --strip 1 \
  289. && ( \
  290. cd xhprof \
  291. && phpize \
  292. && ./configure \
  293. && make \
  294. && make install \
  295. ) \
  296. && rm -r xhprof \
  297. && rm /tmp/xhprof.tar.gz \
  298. ;fi
  299. COPY ./xhprof.ini /usr/local/etc/php/conf.d
  300. RUN if [ ${INSTALL_XHPROF} = false ]; then \
  301. rm /usr/local/etc/php/conf.d/xhprof.ini \
  302. ;fi
  303. ###########################################################################
  304. # AMQP:
  305. ###########################################################################
  306. ARG INSTALL_AMQP=false
  307. RUN if [ ${INSTALL_AMQP} = true ]; then \
  308. # download and install manually, to make sure it's compatible with ampq installed by pecl later
  309. # install cmake first
  310. apt-get -y install cmake && \
  311. curl -L -o /tmp/rabbitmq-c.tar.gz https://github.com/alanxz/rabbitmq-c/archive/master.tar.gz && \
  312. mkdir -p rabbitmq-c && \
  313. tar -C rabbitmq-c -zxvf /tmp/rabbitmq-c.tar.gz --strip 1 && \
  314. cd rabbitmq-c/ && \
  315. mkdir _build && cd _build/ && \
  316. cmake .. && \
  317. cmake --build . --target install && \
  318. # Install the amqp extension
  319. pecl install amqp && \
  320. docker-php-ext-enable amqp && \
  321. # Install the sockets extension
  322. docker-php-ext-install sockets \
  323. ;fi
  324. ###########################################################################
  325. # GEARMAN:
  326. ###########################################################################
  327. ARG INSTALL_GEARMAN=false
  328. RUN if [ ${INSTALL_GEARMAN} = true ]; then \
  329. apt-get -y install libgearman-dev && \
  330. cd /tmp && \
  331. curl -L https://github.com/wcgallego/pecl-gearman/archive/gearman-2.0.5.zip -O && \
  332. unzip gearman-2.0.5.zip && \
  333. mv pecl-gearman-gearman-2.0.5 pecl-gearman && \
  334. cd /tmp/pecl-gearman && \
  335. phpize && \
  336. ./configure && \
  337. make -j$(nproc) && \
  338. make install && \
  339. cd / && \
  340. rm /tmp/gearman-2.0.5.zip && \
  341. rm -r /tmp/pecl-gearman && \
  342. docker-php-ext-enable gearman \
  343. ;fi
  344. ###########################################################################
  345. # pcntl
  346. ###########################################################################
  347. ARG INSTALL_PCNTL=false
  348. RUN if [ ${INSTALL_PCNTL} = true ]; then \
  349. # Installs pcntl, helpful for running Horizon
  350. docker-php-ext-install pcntl \
  351. ;fi
  352. ###########################################################################
  353. # bcmath:
  354. ###########################################################################
  355. ARG INSTALL_BCMATH=false
  356. RUN if [ ${INSTALL_BCMATH} = true ]; then \
  357. # Install the bcmath extension
  358. docker-php-ext-install bcmath \
  359. ;fi
  360. ###########################################################################
  361. # PHP Memcached:
  362. ###########################################################################
  363. ARG INSTALL_MEMCACHED=false
  364. RUN if [ ${INSTALL_MEMCACHED} = true ]; then \
  365. # Install the php memcached extension
  366. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  367. pecl install memcached-2.2.0; \
  368. else \
  369. pecl install memcached-3.1.3; \
  370. fi \
  371. && docker-php-ext-enable memcached \
  372. ;fi
  373. ###########################################################################
  374. # Exif:
  375. ###########################################################################
  376. ARG INSTALL_EXIF=false
  377. RUN if [ ${INSTALL_EXIF} = true ]; then \
  378. # Enable Exif PHP extentions requirements
  379. docker-php-ext-install exif \
  380. ;fi
  381. ###########################################################################
  382. # PHP Aerospike:
  383. ###########################################################################
  384. USER root
  385. ARG INSTALL_AEROSPIKE=false
  386. RUN set -xe; \
  387. if [ ${INSTALL_AEROSPIKE} = true ]; then \
  388. # Fix dependencies for PHPUnit within aerospike extension
  389. apt-get -y install sudo wget && \
  390. # Install the php aerospike extension
  391. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  392. curl -L -o /tmp/aerospike-client-php.tar.gz https://github.com/aerospike/aerospike-client-php5/archive/master.tar.gz; \
  393. else \
  394. curl -L -o /tmp/aerospike-client-php.tar.gz https://github.com/aerospike/aerospike-client-php/archive/master.tar.gz; \
  395. fi \
  396. && mkdir -p /tmp/aerospike-client-php \
  397. && tar -C /tmp/aerospike-client-php -zxvf /tmp/aerospike-client-php.tar.gz --strip 1 \
  398. && \
  399. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  400. ( \
  401. cd /tmp/aerospike-client-php/src/aerospike \
  402. && phpize \
  403. && ./build.sh \
  404. && make install \
  405. ) \
  406. else \
  407. ( \
  408. cd /tmp/aerospike-client-php/src \
  409. && phpize \
  410. && ./build.sh \
  411. && make install \
  412. ) \
  413. fi \
  414. && rm /tmp/aerospike-client-php.tar.gz \
  415. && docker-php-ext-enable aerospike \
  416. ;fi
  417. ###########################################################################
  418. # PHP OCI8:
  419. ###########################################################################
  420. ARG INSTALL_OCI8=false
  421. ARG ORACLE_INSTANT_CLIENT_MIRROR=https://github.com/diogomascarenha/oracle-instantclient/raw/master/
  422. ENV LD_LIBRARY_PATH="/opt/oracle/instantclient_12_1"
  423. ENV OCI_HOME="/opt/oracle/instantclient_12_1"
  424. ENV OCI_LIB_DIR="/opt/oracle/instantclient_12_1"
  425. ENV OCI_INCLUDE_DIR="/opt/oracle/instantclient_12_1/sdk/include"
  426. ENV OCI_VERSION=12
  427. RUN if [ ${INSTALL_OCI8} = true ]; then \
  428. # Install wget
  429. apt-get update && apt-get install --no-install-recommends -y wget \
  430. # Install Oracle Instantclient
  431. && mkdir /opt/oracle \
  432. && cd /opt/oracle \
  433. && wget ${ORACLE_INSTANT_CLIENT_MIRROR}instantclient-basic-linux.x64-12.1.0.2.0.zip \
  434. && wget ${ORACLE_INSTANT_CLIENT_MIRROR}instantclient-sdk-linux.x64-12.1.0.2.0.zip \
  435. && unzip /opt/oracle/instantclient-basic-linux.x64-12.1.0.2.0.zip -d /opt/oracle \
  436. && unzip /opt/oracle/instantclient-sdk-linux.x64-12.1.0.2.0.zip -d /opt/oracle \
  437. && ln -s /opt/oracle/instantclient_12_1/libclntsh.so.12.1 /opt/oracle/instantclient_12_1/libclntsh.so \
  438. && ln -s /opt/oracle/instantclient_12_1/libclntshcore.so.12.1 /opt/oracle/instantclient_12_1/libclntshcore.so \
  439. && ln -s /opt/oracle/instantclient_12_1/libocci.so.12.1 /opt/oracle/instantclient_12_1/libocci.so \
  440. && rm -rf /opt/oracle/*.zip \
  441. # Install PHP extensions deps
  442. && apt-get update \
  443. && apt-get install --no-install-recommends -y \
  444. libaio-dev \
  445. freetds-dev && \
  446. # Install PHP extensions
  447. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  448. echo 'instantclient,/opt/oracle/instantclient_12_1/' | pecl install oci8-2.0.10; \
  449. else \
  450. echo 'instantclient,/opt/oracle/instantclient_12_1/' | pecl install oci8-2.2.0; \
  451. fi \
  452. && docker-php-ext-configure pdo_oci --with-pdo-oci=instantclient,/opt/oracle/instantclient_12_1,12.1 \
  453. && docker-php-ext-configure pdo_dblib --with-libdir=/lib/x86_64-linux-gnu \
  454. && docker-php-ext-install \
  455. pdo_oci \
  456. && docker-php-ext-enable \
  457. oci8 \
  458. ;fi
  459. ###########################################################################
  460. # IonCube Loader:
  461. ###########################################################################
  462. ARG INSTALL_IONCUBE=false
  463. RUN if [ ${INSTALL_IONCUBE} = true ]; then \
  464. # Install the php ioncube loader
  465. curl -L -o /tmp/ioncube_loaders_lin_x86-64.tar.gz https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz \
  466. && tar zxpf /tmp/ioncube_loaders_lin_x86-64.tar.gz -C /tmp \
  467. && mv /tmp/ioncube/ioncube_loader_lin_${LARADOCK_PHP_VERSION}.so $(php -r "echo ini_get('extension_dir');")/ioncube_loader.so \
  468. && printf "zend_extension=ioncube_loader.so\n" > $PHP_INI_DIR/conf.d/0ioncube.ini \
  469. && rm -rf /tmp/ioncube* \
  470. ;fi
  471. ###########################################################################
  472. # Opcache:
  473. ###########################################################################
  474. ARG INSTALL_OPCACHE=false
  475. RUN if [ ${INSTALL_OPCACHE} = true ]; then \
  476. docker-php-ext-install opcache \
  477. ;fi
  478. # Copy opcache configration
  479. COPY ./opcache.ini /usr/local/etc/php/conf.d/opcache.ini
  480. ###########################################################################
  481. # Mysqli Modifications:
  482. ###########################################################################
  483. ARG INSTALL_MYSQLI=false
  484. RUN if [ ${INSTALL_MYSQLI} = true ]; then \
  485. docker-php-ext-install mysqli \
  486. ;fi
  487. ###########################################################################
  488. # Human Language and Character Encoding Support:
  489. ###########################################################################
  490. ARG INSTALL_INTL=false
  491. RUN if [ ${INSTALL_INTL} = true ]; then \
  492. # Install intl and requirements
  493. apt-get install -y zlib1g-dev libicu-dev g++ && \
  494. docker-php-ext-configure intl && \
  495. docker-php-ext-install intl \
  496. ;fi
  497. ###########################################################################
  498. # GHOSTSCRIPT:
  499. ###########################################################################
  500. ARG INSTALL_GHOSTSCRIPT=false
  501. RUN if [ ${INSTALL_GHOSTSCRIPT} = true ]; then \
  502. # Install the ghostscript extension
  503. # for PDF editing
  504. apt-get install -y \
  505. poppler-utils \
  506. ghostscript \
  507. ;fi
  508. ###########################################################################
  509. # LDAP:
  510. ###########################################################################
  511. ARG INSTALL_LDAP=false
  512. RUN if [ ${INSTALL_LDAP} = true ]; then \
  513. apt-get install -y libldap2-dev && \
  514. docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \
  515. docker-php-ext-install ldap \
  516. ;fi
  517. ###########################################################################
  518. # SQL SERVER:
  519. ###########################################################################
  520. ARG INSTALL_MSSQL=false
  521. RUN set -eux; \
  522. if [ ${INSTALL_MSSQL} = true ]; then \
  523. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  524. apt-get -y install freetds-dev libsybdb5 \
  525. && ln -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/libsybdb.so \
  526. && docker-php-ext-install mssql pdo_dblib \
  527. && php -m | grep -q 'mssql' \
  528. && php -m | grep -q 'pdo_dblib' \
  529. ;else \
  530. ###########################################################################
  531. # Ref from https://github.com/Microsoft/msphpsql/wiki/Dockerfile-for-adding-pdo_sqlsrv-and-sqlsrv-to-official-php-image
  532. ###########################################################################
  533. # Add Microsoft repo for Microsoft ODBC Driver 13 for Linux
  534. apt-get install -y apt-transport-https gnupg \
  535. && curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
  536. && curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list \
  537. && apt-get update -yqq \
  538. # Install Dependencies
  539. && ACCEPT_EULA=Y apt-get install -y unixodbc unixodbc-dev libgss3 odbcinst msodbcsql17 locales \
  540. && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
  541. # link local aliases
  542. && ln -sfn /etc/locale.alias /usr/share/locale/locale.alias \
  543. && locale-gen \
  544. # Install pdo_sqlsrv and sqlsrv from PECL. Replace pdo_sqlsrv-4.1.8preview with preferred version.
  545. && if [ $(php -r "echo PHP_MINOR_VERSION;") = "0" ]; then \
  546. pecl install pdo_sqlsrv-5.3.0 sqlsrv-5.3.0 \
  547. ;else \
  548. pecl install pdo_sqlsrv sqlsrv \
  549. ;fi \
  550. && docker-php-ext-enable pdo_sqlsrv sqlsrv \
  551. && php -m | grep -q 'pdo_sqlsrv' \
  552. && php -m | grep -q 'sqlsrv' \
  553. ;fi \
  554. ;fi
  555. ###########################################################################
  556. # Image optimizers:
  557. ###########################################################################
  558. USER root
  559. ARG INSTALL_IMAGE_OPTIMIZERS=false
  560. RUN if [ ${INSTALL_IMAGE_OPTIMIZERS} = true ]; then \
  561. apt-get install -y jpegoptim optipng pngquant gifsicle \
  562. ;fi
  563. ###########################################################################
  564. # ImageMagick:
  565. ###########################################################################
  566. USER root
  567. ARG INSTALL_IMAGEMAGICK=false
  568. ARG IMAGEMAGICK_VERSION=latest
  569. ENV IMAGEMAGICK_VERSION ${IMAGEMAGICK_VERSION}
  570. RUN if [ ${INSTALL_IMAGEMAGICK} = true ]; then \
  571. apt-get update -yqq && apt-get install -y libmagickwand-dev imagemagick && \
  572. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \
  573. apt-get install -y git && \
  574. cd /tmp && \
  575. if [ ${IMAGEMAGICK_VERSION} = "latest" ]; then \
  576. git clone https://github.com/Imagick/imagick; \
  577. else \
  578. git clone --branch ${IMAGEMAGICK_VERSION} https://github.com/Imagick/imagick; \
  579. fi && \
  580. cd imagick && \
  581. phpize && \
  582. ./configure && \
  583. make && \
  584. make install && \
  585. rm -r /tmp/imagick; \
  586. else \
  587. pecl install imagick; \
  588. fi && \
  589. docker-php-ext-enable imagick \
  590. ;fi
  591. ###########################################################################
  592. # SMB:
  593. ###########################################################################
  594. ARG INSTALL_SMB=false
  595. RUN if [ ${INSTALL_SMB} = true ]; then \
  596. apt-get install -y smbclient php-smbclient coreutils \
  597. ;fi
  598. ###########################################################################
  599. # IMAP:
  600. ###########################################################################
  601. ARG INSTALL_IMAP=false
  602. RUN if [ ${INSTALL_IMAP} = true ]; then \
  603. apt-get install -y libc-client-dev libkrb5-dev && \
  604. docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \
  605. docker-php-ext-install imap \
  606. ;fi
  607. ###########################################################################
  608. # Calendar:
  609. ###########################################################################
  610. USER root
  611. ARG INSTALL_CALENDAR=false
  612. RUN if [ ${INSTALL_CALENDAR} = true ]; then \
  613. docker-php-ext-configure calendar && \
  614. docker-php-ext-install calendar \
  615. ;fi
  616. ###########################################################################
  617. # Phalcon:
  618. ###########################################################################
  619. ARG INSTALL_PHALCON=false
  620. ARG LARADOCK_PHALCON_VERSION
  621. ENV LARADOCK_PHALCON_VERSION ${LARADOCK_PHALCON_VERSION}
  622. # Copy phalcon configration
  623. COPY ./phalcon.ini /usr/local/etc/php/conf.d/phalcon.ini.disable
  624. RUN if [ $INSTALL_PHALCON = true ]; then \
  625. apt-get update && apt-get install -y unzip libpcre3-dev gcc make re2c git automake autoconf\
  626. && git clone https://github.com/jbboehr/php-psr.git \
  627. && cd php-psr \
  628. && phpize \
  629. && ./configure \
  630. && make \
  631. && make test \
  632. && make install \
  633. && curl -L -o /tmp/cphalcon.zip https://github.com/phalcon/cphalcon/archive/v${LARADOCK_PHALCON_VERSION}.zip \
  634. && unzip -d /tmp/ /tmp/cphalcon.zip \
  635. && cd /tmp/cphalcon-${LARADOCK_PHALCON_VERSION}/build \
  636. && ./install \
  637. && mv /usr/local/etc/php/conf.d/phalcon.ini.disable /usr/local/etc/php/conf.d/phalcon.ini \
  638. && rm -rf /tmp/cphalcon* \
  639. ;fi
  640. ###########################################################################
  641. # APCU:
  642. ###########################################################################
  643. ARG INSTALL_APCU=false
  644. RUN if [ ${INSTALL_APCU} = true ]; then \
  645. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  646. pecl install -a apcu-4.0.11; \
  647. else \
  648. pecl install apcu; \
  649. fi && \
  650. docker-php-ext-enable apcu \
  651. ;fi
  652. ###########################################################################
  653. # YAML:
  654. ###########################################################################
  655. USER root
  656. ARG INSTALL_YAML=false
  657. RUN if [ ${INSTALL_YAML} = true ]; then \
  658. apt-get install libyaml-dev -y ; \
  659. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  660. pecl install -a yaml-1.3.2; \
  661. else \
  662. pecl install yaml; \
  663. fi && \
  664. docker-php-ext-enable yaml \
  665. ;fi
  666. ###########################################################################
  667. # RDKAFKA:
  668. ###########################################################################
  669. ARG INSTALL_RDKAFKA=false
  670. RUN if [ ${INSTALL_RDKAFKA} = true ]; then \
  671. apt-get install -y librdkafka-dev && \
  672. pecl install rdkafka && \
  673. docker-php-ext-enable rdkafka \
  674. ;fi
  675. ###########################################################################
  676. # GETTEXT:
  677. ###########################################################################
  678. ARG INSTALL_GETTEXT=false
  679. RUN if [ ${INSTALL_GETTEXT} = true ]; then \
  680. apt-get install -y zlib1g-dev libicu-dev g++ libpq-dev libssl-dev gettext && \
  681. docker-php-ext-install gettext \
  682. ;fi
  683. ###########################################################################
  684. # Install additional locales:
  685. ###########################################################################
  686. ARG INSTALL_ADDITIONAL_LOCALES=false
  687. ARG ADDITIONAL_LOCALES
  688. RUN if [ ${INSTALL_ADDITIONAL_LOCALES} = true ]; then \
  689. apt-get install -y locales \
  690. && echo '' >> /usr/share/locale/locale.alias \
  691. && temp="${ADDITIONAL_LOCALES%\"}" \
  692. && temp="${temp#\"}" \
  693. && for i in ${temp}; do sed -i "/$i/s/^#//g" /etc/locale.gen; done \
  694. && locale-gen \
  695. ;fi
  696. ###########################################################################
  697. # MySQL Client:
  698. ###########################################################################
  699. USER root
  700. ARG INSTALL_MYSQL_CLIENT=false
  701. RUN if [ ${INSTALL_MYSQL_CLIENT} = true ]; then \
  702. apt-get -y install default-mysql-client \
  703. ;fi
  704. ###########################################################################
  705. # ping:
  706. ###########################################################################
  707. USER root
  708. ARG INSTALL_PING=false
  709. RUN if [ ${INSTALL_PING} = true ]; then \
  710. apt-get -y install inetutils-ping \
  711. ;fi
  712. ###########################################################################
  713. # sshpass:
  714. ###########################################################################
  715. USER root
  716. ARG INSTALL_SSHPASS=false
  717. RUN if [ ${INSTALL_SSHPASS} = true ]; then \
  718. apt-get -y install sshpass \
  719. ;fi
  720. ###########################################################################
  721. # Docker Client:
  722. ###########################################################################
  723. USER root
  724. ARG INSTALL_DOCKER_CLIENT=false
  725. RUN if [ ${INSTALL_DOCKER_CLIENT} = true ]; then \
  726. curl -sS https://download.docker.com/linux/static/stable/x86_64/docker-20.10.3.tgz -o /tmp/docker.tar.gz && \
  727. tar -xzf /tmp/docker.tar.gz -C /tmp/ && \
  728. cp /tmp/docker/docker* /usr/local/bin && \
  729. chmod +x /usr/local/bin/docker* \
  730. ;fi
  731. ###########################################################################
  732. # FFMPEG:
  733. ###########################################################################
  734. USER root
  735. ARG INSTALL_FFMPEG=false
  736. RUN if [ ${INSTALL_FFMPEG} = true ]; then \
  737. apt-get -y install ffmpeg \
  738. ;fi
  739. ###########################################################################
  740. # BBC Audio Waveform Image Generator:
  741. ###########################################################################
  742. USER root
  743. ARG INSTALL_AUDIOWAVEFORM=false
  744. RUN if [ ${INSTALL_AUDIOWAVEFORM} = true ]; then \
  745. apt-get -y install git wget make cmake gcc g++ libmad0-dev libid3tag0-dev libsndfile1-dev libgd-dev libboost-filesystem-dev libboost-program-options-dev libboost-regex-dev \
  746. && git clone https://github.com/bbc/audiowaveform.git \
  747. && cd audiowaveform \
  748. && wget https://github.com/google/googletest/archive/release-1.10.0.tar.gz \
  749. && tar xzf release-1.10.0.tar.gz \
  750. && ln -s googletest-release-1.10.0/googletest googletest \
  751. && ln -s googletest-release-1.10.0/googlemock googlemock \
  752. && mkdir build \
  753. && cd build \
  754. && cmake .. \
  755. && make \
  756. && make install \
  757. ;fi
  758. #####################################
  759. # wkhtmltopdf:
  760. #####################################
  761. USER root
  762. ARG INSTALL_WKHTMLTOPDF=false
  763. RUN if [ ${INSTALL_WKHTMLTOPDF} = true ]; then \
  764. apt-get install -y \
  765. libxrender1 \
  766. libfontconfig1 \
  767. libx11-dev \
  768. libjpeg62 \
  769. libxtst6 \
  770. fontconfig \
  771. libjpeg62-turbo \
  772. xfonts-base \
  773. xfonts-75dpi \
  774. wget \
  775. && wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.stretch_amd64.deb \
  776. && dpkg -i wkhtmltox_0.12.6-1.stretch_amd64.deb \
  777. && apt -f install \
  778. ;fi
  779. ###########################################################################
  780. # Mailparse extension:
  781. ###########################################################################
  782. ARG INSTALL_MAILPARSE=false
  783. RUN if [ ${INSTALL_MAILPARSE} = true ]; then \
  784. # Install mailparse extension
  785. printf "\n" | pecl install -o -f mailparse \
  786. && rm -rf /tmp/pear \
  787. && docker-php-ext-enable mailparse \
  788. ;fi
  789. ###########################################################################
  790. # CacheTool:
  791. ###########################################################################
  792. ARG INSTALL_CACHETOOL=false
  793. RUN if [ ${INSTALL_CACHETOOL} = true ]; then \
  794. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && [ $(php -r "echo PHP_MINOR_VERSION;") -ge 1 ]; then \
  795. curl -sO http://gordalina.github.io/cachetool/downloads/cachetool.phar; \
  796. else \
  797. curl http://gordalina.github.io/cachetool/downloads/cachetool-3.2.1.phar -o cachetool.phar; \
  798. fi && \
  799. chmod +x cachetool.phar && \
  800. mv cachetool.phar /usr/local/bin/cachetool \
  801. ;fi
  802. ###########################################################################
  803. # XMLRPC:
  804. ###########################################################################
  805. ARG INSTALL_XMLRPC=false
  806. RUN if [ ${INSTALL_XMLRPC} = true ]; then \
  807. docker-php-ext-install xmlrpc \
  808. ;fi
  809. ###########################################################################
  810. # New Relic for PHP:
  811. ###########################################################################
  812. ARG NEW_RELIC=${NEW_RELIC}
  813. ARG NEW_RELIC_KEY=${NEW_RELIC_KEY}
  814. ARG NEW_RELIC_APP_NAME=${NEW_RELIC_APP_NAME}
  815. RUN if [ ${NEW_RELIC} = true ]; then \
  816. curl -L http://download.newrelic.com/php_agent/archive/9.9.0.260/newrelic-php5-9.9.0.260-linux.tar.gz | tar -C /tmp -zx && \
  817. export NR_INSTALL_USE_CP_NOT_LN=1 && \
  818. export NR_INSTALL_SILENT=1 && \
  819. /tmp/newrelic-php5-*/newrelic-install install && \
  820. rm -rf /tmp/newrelic-php5-* /tmp/nrinstall* && \
  821. sed -i \
  822. -e 's/"REPLACE_WITH_REAL_KEY"/"${NEW_RELIC_KEY}"/' \
  823. -e 's/newrelic.appname = "PHP Application"/newrelic.appname = "${NEW_RELIC_APP_NAME}"/' \
  824. -e 's/;newrelic.daemon.app_connect_timeout =.*/newrelic.daemon.app_connect_timeout=15s/' \
  825. -e 's/;newrelic.daemon.start_timeout =.*/newrelic.daemon.start_timeout=5s/' \
  826. /usr/local/etc/php/conf.d/newrelic.ini \
  827. ;fi
  828. ###########################################################################
  829. # Downgrade Openssl:
  830. ###########################################################################
  831. ARG DOWNGRADE_OPENSSL_TLS_AND_SECLEVEL=false
  832. RUN if [ ${DOWNGRADE_OPENSSL_TLS_AND_SECLEVEL} = true ]; then \
  833. sed -i 's,^\(MinProtocol[ ]*=\).*,\1'TLSv1.2',g' /etc/ssl/openssl.cnf \
  834. && \
  835. sed -i 's,^\(CipherString[ ]*=\).*,\1'DEFAULT@SECLEVEL=1',g' /etc/ssl/openssl.cnf\
  836. ;fi
  837. ###########################################################################
  838. # Check PHP version:
  839. ###########################################################################
  840. RUN set -xe; php -v | head -n 1 | grep -q "PHP ${LARADOCK_PHP_VERSION}."
  841. #
  842. #--------------------------------------------------------------------------
  843. # Final Touch
  844. #--------------------------------------------------------------------------
  845. #
  846. COPY ./laravel.ini /usr/local/etc/php/conf.d
  847. COPY ./xlaravel.pool.conf /usr/local/etc/php-fpm.d/
  848. USER root
  849. # Clean up
  850. RUN apt-get clean && \
  851. rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
  852. rm /var/log/lastlog /var/log/faillog
  853. # Configure non-root user.
  854. ARG PUID=1000
  855. ENV PUID ${PUID}
  856. ARG PGID=1000
  857. ENV PGID ${PGID}
  858. RUN groupmod -o -g ${PGID} www-data && \
  859. usermod -o -u ${PUID} -g www-data www-data
  860. # Adding the faketime library to the preload file needs to be done last
  861. # otherwise it will preload it for all commands that follow in this file
  862. RUN if [ ${INSTALL_FAKETIME} = true ]; then \
  863. echo "/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1" > /etc/ld.so.preload \
  864. ;fi
  865. # Configure locale.
  866. ARG LOCALE=POSIX
  867. ENV LC_ALL ${LOCALE}
  868. WORKDIR /var/www
  869. CMD ["php-fpm"]
  870. EXPOSE 9000