Dockerfile 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117
  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.3.1; \
  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 set -eux; \
  237. if [ ${INSTALL_SWOOLE} = true ]; then \
  238. # Install Php Swoole Extension
  239. if [ $(php -r "echo PHP_VERSION_ID - PHP_RELEASE_VERSION;") = "50600" ]; then \
  240. pecl install swoole-2.0.11; \
  241. elif [ $(php -r "echo PHP_VERSION_ID - PHP_RELEASE_VERSION;") = "70000" ]; then \
  242. pecl install swoole-4.3.5; \
  243. elif [ $(php -r "echo PHP_VERSION_ID - PHP_RELEASE_VERSION;") = "70100" ]; then \
  244. pecl install swoole-4.6.0; \
  245. else \
  246. pecl install swoole; \
  247. fi; \
  248. docker-php-ext-enable swoole; \
  249. php -m | grep -q 'swoole'; \
  250. fi
  251. ###########################################################################
  252. # Taint EXTENSION
  253. ###########################################################################
  254. ARG INSTALL_TAINT=false
  255. RUN if [ ${INSTALL_TAINT} = true ]; then \
  256. # Install Php TAINT Extension
  257. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ]; then \
  258. pecl install taint && \
  259. docker-php-ext-enable taint && \
  260. php -m | grep -q 'taint'; \
  261. fi \
  262. ;fi
  263. ###########################################################################
  264. # MongoDB:
  265. ###########################################################################
  266. ARG INSTALL_MONGO=false
  267. RUN if [ ${INSTALL_MONGO} = true ]; then \
  268. # Install the mongodb extension
  269. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  270. pecl install mongo && \
  271. docker-php-ext-enable mongo \
  272. ;else \
  273. pecl install mongodb && \
  274. docker-php-ext-enable mongodb \
  275. ;fi \
  276. ;fi
  277. ###########################################################################
  278. # Xhprof:
  279. ###########################################################################
  280. ARG INSTALL_XHPROF=false
  281. RUN set -eux; \
  282. if [ ${INSTALL_XHPROF} = true ]; then \
  283. # Install the php xhprof extension
  284. if [ $(php -r "echo PHP_MAJOR_VERSION;") != 5 ]; then \
  285. pecl install xhprof; \
  286. else \
  287. curl -L -o /tmp/xhprof.tar.gz "https://codeload.github.com/phacility/xhprof/tar.gz/master"; \
  288. mkdir -p /tmp/xhprof; \
  289. tar -C /tmp/xhprof -zxvf /tmp/xhprof.tar.gz --strip 1; \
  290. ( \
  291. cd /tmp/xhprof/extension; \
  292. phpize; \
  293. ./configure; \
  294. make; \
  295. make install; \
  296. ); \
  297. rm -r /tmp/xhprof; \
  298. rm /tmp/xhprof.tar.gz; \
  299. fi; \
  300. docker-php-ext-enable xhprof; \
  301. php -m | grep -q 'xhprof'; \
  302. fi
  303. # if [ ${INSTALL_XHPROF_USE_TIDYWAYS} = true ]; then \
  304. # https://github.com/tideways/php-xhprof-extension
  305. # fi
  306. # COPY ./xhprof.ini /usr/local/etc/php/conf.d
  307. # RUN if [ ${INSTALL_XHPROF} = false ]; then \
  308. # rm /usr/local/etc/php/conf.d/xhprof.ini \
  309. # ;fi
  310. ###########################################################################
  311. # AMQP:
  312. ###########################################################################
  313. ARG INSTALL_AMQP=false
  314. RUN if [ ${INSTALL_AMQP} = true ]; then \
  315. # download and install manually, to make sure it's compatible with ampq installed by pecl later
  316. # install cmake first
  317. apt-get -y install cmake && \
  318. curl -L -o /tmp/rabbitmq-c.tar.gz https://github.com/alanxz/rabbitmq-c/archive/master.tar.gz && \
  319. mkdir -p rabbitmq-c && \
  320. tar -C rabbitmq-c -zxvf /tmp/rabbitmq-c.tar.gz --strip 1 && \
  321. cd rabbitmq-c/ && \
  322. mkdir _build && cd _build/ && \
  323. cmake .. && \
  324. cmake --build . --target install && \
  325. # Install the amqp extension
  326. pecl install amqp && \
  327. docker-php-ext-enable amqp && \
  328. # Install the sockets extension
  329. docker-php-ext-install sockets \
  330. ;fi
  331. ###########################################################################
  332. # CASSANDRA:
  333. ###########################################################################
  334. ARG INSTALL_CASSANDRA=false
  335. RUN if [ ${INSTALL_CASSANDRA} = true ]; then \
  336. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \
  337. echo "PHP Driver for Cassandra is not supported for PHP 8.0."; \
  338. else \
  339. apt-get install libgmp-dev -yqq && \
  340. curl https://downloads.datastax.com/cpp-driver/ubuntu/18.04/dependencies/libuv/v1.35.0/libuv1-dev_1.35.0-1_amd64.deb -o libuv1-dev.deb && \
  341. curl https://downloads.datastax.com/cpp-driver/ubuntu/18.04/dependencies/libuv/v1.35.0/libuv1_1.35.0-1_amd64.deb -o libuv1.deb && \
  342. curl https://downloads.datastax.com/cpp-driver/ubuntu/18.04/cassandra/v2.16.0/cassandra-cpp-driver-dev_2.16.0-1_amd64.deb -o cassandra-cpp-driver-dev.deb && \
  343. curl https://downloads.datastax.com/cpp-driver/ubuntu/18.04/cassandra/v2.16.0/cassandra-cpp-driver_2.16.0-1_amd64.deb -o cassandra-cpp-driver.deb && \
  344. dpkg -i libuv1.deb && \
  345. dpkg -i libuv1-dev.deb && \
  346. dpkg -i cassandra-cpp-driver.deb && \
  347. dpkg -i cassandra-cpp-driver-dev.deb && \
  348. rm libuv1.deb libuv1-dev.deb cassandra-cpp-driver-dev.deb cassandra-cpp-driver.deb && \
  349. cd /usr/src && \
  350. git clone https://github.com/datastax/php-driver.git && \
  351. cd /usr/src/php-driver/ext && \
  352. phpize && \
  353. mkdir /usr/src/php-driver/build && \
  354. cd /usr/src/php-driver/build && \
  355. ../ext/configure > /dev/null && \
  356. make clean > /dev/null && \
  357. make > /dev/null 2>&1 && \
  358. make install && \
  359. echo "extension=cassandra.so" >> /etc/php/${LARADOCK_PHP_VERSION}/mods-available/cassandra.ini && \
  360. ln -s /etc/php/${LARADOCK_PHP_VERSION}/mods-available/cassandra.ini /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/30-cassandra.ini; \
  361. fi \
  362. ;fi
  363. ###########################################################################
  364. # GEARMAN:
  365. ###########################################################################
  366. ARG INSTALL_GEARMAN=false
  367. RUN if [ ${INSTALL_GEARMAN} = true ]; then \
  368. apt-get -y install libgearman-dev && \
  369. cd /tmp && \
  370. curl -L https://github.com/wcgallego/pecl-gearman/archive/gearman-2.0.5.zip -O && \
  371. unzip gearman-2.0.5.zip && \
  372. mv pecl-gearman-gearman-2.0.5 pecl-gearman && \
  373. cd /tmp/pecl-gearman && \
  374. phpize && \
  375. ./configure && \
  376. make -j$(nproc) && \
  377. make install && \
  378. cd / && \
  379. rm /tmp/gearman-2.0.5.zip && \
  380. rm -r /tmp/pecl-gearman && \
  381. docker-php-ext-enable gearman \
  382. ;fi
  383. ###########################################################################
  384. # pcntl
  385. ###########################################################################
  386. ARG INSTALL_PCNTL=false
  387. RUN if [ ${INSTALL_PCNTL} = true ]; then \
  388. # Installs pcntl, helpful for running Horizon
  389. docker-php-ext-install pcntl \
  390. ;fi
  391. ###########################################################################
  392. # bcmath:
  393. ###########################################################################
  394. ARG INSTALL_BCMATH=false
  395. RUN if [ ${INSTALL_BCMATH} = true ]; then \
  396. # Install the bcmath extension
  397. docker-php-ext-install bcmath \
  398. ;fi
  399. ###########################################################################
  400. # PHP Memcached:
  401. ###########################################################################
  402. ARG INSTALL_MEMCACHED=false
  403. RUN if [ ${INSTALL_MEMCACHED} = true ]; then \
  404. # Install the php memcached extension
  405. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  406. pecl install memcached-2.2.0; \
  407. else \
  408. pecl install memcached-3.1.3; \
  409. fi \
  410. && docker-php-ext-enable memcached \
  411. ;fi
  412. ###########################################################################
  413. # Exif:
  414. ###########################################################################
  415. ARG INSTALL_EXIF=false
  416. RUN if [ ${INSTALL_EXIF} = true ]; then \
  417. # Enable Exif PHP extentions requirements
  418. docker-php-ext-install exif \
  419. ;fi
  420. ###########################################################################
  421. # PHP Aerospike:
  422. ###########################################################################
  423. USER root
  424. ARG INSTALL_AEROSPIKE=false
  425. RUN set -xe; \
  426. if [ ${INSTALL_AEROSPIKE} = true ]; then \
  427. # Fix dependencies for PHPUnit within aerospike extension
  428. apt-get -y install sudo wget && \
  429. # Install the php aerospike extension
  430. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  431. curl -L -o /tmp/aerospike-client-php.tar.gz https://github.com/aerospike/aerospike-client-php5/archive/master.tar.gz; \
  432. else \
  433. curl -L -o /tmp/aerospike-client-php.tar.gz https://github.com/aerospike/aerospike-client-php/archive/master.tar.gz; \
  434. fi \
  435. && mkdir -p /tmp/aerospike-client-php \
  436. && tar -C /tmp/aerospike-client-php -zxvf /tmp/aerospike-client-php.tar.gz --strip 1 \
  437. && \
  438. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  439. ( \
  440. cd /tmp/aerospike-client-php/src/aerospike \
  441. && phpize \
  442. && ./build.sh \
  443. && make install \
  444. ) \
  445. else \
  446. ( \
  447. cd /tmp/aerospike-client-php/src \
  448. && phpize \
  449. && ./build.sh \
  450. && make install \
  451. ) \
  452. fi \
  453. && rm /tmp/aerospike-client-php.tar.gz \
  454. && docker-php-ext-enable aerospike \
  455. ;fi
  456. ###########################################################################
  457. # PHP OCI8:
  458. ###########################################################################
  459. ARG INSTALL_OCI8=false
  460. ARG ORACLE_INSTANT_CLIENT_MIRROR=https://github.com/diogomascarenha/oracle-instantclient/raw/master/
  461. ENV LD_LIBRARY_PATH="/opt/oracle/instantclient_12_1"
  462. ENV OCI_HOME="/opt/oracle/instantclient_12_1"
  463. ENV OCI_LIB_DIR="/opt/oracle/instantclient_12_1"
  464. ENV OCI_INCLUDE_DIR="/opt/oracle/instantclient_12_1/sdk/include"
  465. ENV OCI_VERSION=12
  466. RUN if [ ${INSTALL_OCI8} = true ]; then \
  467. # Install wget
  468. apt-get update && apt-get install --no-install-recommends -y wget \
  469. # Install Oracle Instantclient
  470. && mkdir /opt/oracle \
  471. && cd /opt/oracle \
  472. && wget ${ORACLE_INSTANT_CLIENT_MIRROR}instantclient-basic-linux.x64-12.1.0.2.0.zip \
  473. && wget ${ORACLE_INSTANT_CLIENT_MIRROR}instantclient-sdk-linux.x64-12.1.0.2.0.zip \
  474. && unzip /opt/oracle/instantclient-basic-linux.x64-12.1.0.2.0.zip -d /opt/oracle \
  475. && unzip /opt/oracle/instantclient-sdk-linux.x64-12.1.0.2.0.zip -d /opt/oracle \
  476. && ln -s /opt/oracle/instantclient_12_1/libclntsh.so.12.1 /opt/oracle/instantclient_12_1/libclntsh.so \
  477. && ln -s /opt/oracle/instantclient_12_1/libclntshcore.so.12.1 /opt/oracle/instantclient_12_1/libclntshcore.so \
  478. && ln -s /opt/oracle/instantclient_12_1/libocci.so.12.1 /opt/oracle/instantclient_12_1/libocci.so \
  479. && rm -rf /opt/oracle/*.zip \
  480. # Install PHP extensions deps
  481. && apt-get update \
  482. && apt-get install --no-install-recommends -y \
  483. libaio-dev \
  484. freetds-dev && \
  485. # Install PHP extensions
  486. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  487. echo 'instantclient,/opt/oracle/instantclient_12_1/' | pecl install oci8-2.0.10; \
  488. else \
  489. echo 'instantclient,/opt/oracle/instantclient_12_1/' | pecl install oci8-2.2.0; \
  490. fi \
  491. && docker-php-ext-configure pdo_oci --with-pdo-oci=instantclient,/opt/oracle/instantclient_12_1,12.1 \
  492. && docker-php-ext-configure pdo_dblib --with-libdir=/lib/x86_64-linux-gnu \
  493. && docker-php-ext-install \
  494. pdo_oci \
  495. && docker-php-ext-enable \
  496. oci8 \
  497. ;fi
  498. ###########################################################################
  499. # IonCube Loader:
  500. ###########################################################################
  501. ARG INSTALL_IONCUBE=false
  502. RUN if [ ${INSTALL_IONCUBE} = true ]; then \
  503. # Install the php ioncube loader
  504. curl -L -o /tmp/ioncube_loaders_lin_x86-64.tar.gz https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz \
  505. && tar zxpf /tmp/ioncube_loaders_lin_x86-64.tar.gz -C /tmp \
  506. && mv /tmp/ioncube/ioncube_loader_lin_${LARADOCK_PHP_VERSION}.so $(php -r "echo ini_get('extension_dir');")/ioncube_loader.so \
  507. && printf "zend_extension=ioncube_loader.so\n" > $PHP_INI_DIR/conf.d/0ioncube.ini \
  508. && rm -rf /tmp/ioncube* \
  509. ;fi
  510. ###########################################################################
  511. # Opcache:
  512. ###########################################################################
  513. ARG INSTALL_OPCACHE=false
  514. RUN if [ ${INSTALL_OPCACHE} = true ]; then \
  515. docker-php-ext-install opcache \
  516. ;fi
  517. # Copy opcache configration
  518. COPY ./opcache.ini /usr/local/etc/php/conf.d/opcache.ini
  519. ###########################################################################
  520. # Mysqli Modifications:
  521. ###########################################################################
  522. ARG INSTALL_MYSQLI=false
  523. RUN if [ ${INSTALL_MYSQLI} = true ]; then \
  524. docker-php-ext-install mysqli \
  525. ;fi
  526. ###########################################################################
  527. # Human Language and Character Encoding Support:
  528. ###########################################################################
  529. ARG INSTALL_INTL=false
  530. RUN if [ ${INSTALL_INTL} = true ]; then \
  531. # Install intl and requirements
  532. apt-get install -y zlib1g-dev libicu-dev g++ && \
  533. docker-php-ext-configure intl && \
  534. docker-php-ext-install intl \
  535. ;fi
  536. ###########################################################################
  537. # GHOSTSCRIPT:
  538. ###########################################################################
  539. ARG INSTALL_GHOSTSCRIPT=false
  540. RUN if [ ${INSTALL_GHOSTSCRIPT} = true ]; then \
  541. # Install the ghostscript extension
  542. # for PDF editing
  543. apt-get install -y \
  544. poppler-utils \
  545. ghostscript \
  546. ;fi
  547. ###########################################################################
  548. # LDAP:
  549. ###########################################################################
  550. ARG INSTALL_LDAP=false
  551. RUN if [ ${INSTALL_LDAP} = true ]; then \
  552. apt-get install -y libldap2-dev && \
  553. docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \
  554. docker-php-ext-install ldap \
  555. ;fi
  556. ###########################################################################
  557. # SQL SERVER:
  558. ###########################################################################
  559. ARG INSTALL_MSSQL=false
  560. RUN set -eux; \
  561. if [ ${INSTALL_MSSQL} = true ]; then \
  562. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  563. apt-get -y install freetds-dev libsybdb5 \
  564. && ln -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/libsybdb.so \
  565. && docker-php-ext-install mssql pdo_dblib \
  566. && php -m | grep -q 'mssql' \
  567. && php -m | grep -q 'pdo_dblib' \
  568. ;else \
  569. ###########################################################################
  570. # Ref from https://github.com/Microsoft/msphpsql/wiki/Dockerfile-for-adding-pdo_sqlsrv-and-sqlsrv-to-official-php-image
  571. ###########################################################################
  572. # Add Microsoft repo for Microsoft ODBC Driver 13 for Linux
  573. apt-get install -y apt-transport-https gnupg \
  574. && curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
  575. && curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list \
  576. && apt-get update -yqq \
  577. # Install Dependencies
  578. && ACCEPT_EULA=Y apt-get install -y unixodbc unixodbc-dev libgss3 odbcinst msodbcsql17 locales \
  579. && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
  580. # link local aliases
  581. && ln -sfn /etc/locale.alias /usr/share/locale/locale.alias \
  582. && locale-gen \
  583. # Install pdo_sqlsrv and sqlsrv from PECL. Replace pdo_sqlsrv-4.1.8preview with preferred version.
  584. && if [ $(php -r "echo PHP_MINOR_VERSION;") = "0" ]; then \
  585. pecl install pdo_sqlsrv-5.3.0 sqlsrv-5.3.0 \
  586. ;else \
  587. pecl install pdo_sqlsrv sqlsrv \
  588. ;fi \
  589. && docker-php-ext-enable pdo_sqlsrv sqlsrv \
  590. && php -m | grep -q 'pdo_sqlsrv' \
  591. && php -m | grep -q 'sqlsrv' \
  592. ;fi \
  593. ;fi
  594. ###########################################################################
  595. # Image optimizers:
  596. ###########################################################################
  597. USER root
  598. ARG INSTALL_IMAGE_OPTIMIZERS=false
  599. RUN if [ ${INSTALL_IMAGE_OPTIMIZERS} = true ]; then \
  600. apt-get install -y jpegoptim optipng pngquant gifsicle \
  601. ;fi
  602. ###########################################################################
  603. # ImageMagick:
  604. ###########################################################################
  605. USER root
  606. ARG INSTALL_IMAGEMAGICK=false
  607. ARG IMAGEMAGICK_VERSION=latest
  608. ENV IMAGEMAGICK_VERSION ${IMAGEMAGICK_VERSION}
  609. RUN if [ ${INSTALL_IMAGEMAGICK} = true ]; then \
  610. apt-get install -y libmagickwand-dev imagemagick && \
  611. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \
  612. apt-get install -y git && \
  613. cd /tmp && \
  614. if [ ${IMAGEMAGICK_VERSION} = "latest" ]; then \
  615. git clone https://github.com/Imagick/imagick; \
  616. else \
  617. git clone --branch ${IMAGEMAGICK_VERSION} https://github.com/Imagick/imagick; \
  618. fi && \
  619. cd imagick && \
  620. phpize && \
  621. ./configure && \
  622. make && \
  623. make install && \
  624. rm -r /tmp/imagick; \
  625. else \
  626. pecl install imagick; \
  627. fi && \
  628. docker-php-ext-enable imagick \
  629. ;fi
  630. ###########################################################################
  631. # SMB:
  632. ###########################################################################
  633. ARG INSTALL_SMB=false
  634. RUN if [ ${INSTALL_SMB} = true ]; then \
  635. apt-get install -y smbclient php-smbclient coreutils \
  636. ;fi
  637. ###########################################################################
  638. # IMAP:
  639. ###########################################################################
  640. ARG INSTALL_IMAP=false
  641. RUN if [ ${INSTALL_IMAP} = true ]; then \
  642. apt-get install -y libc-client-dev libkrb5-dev && \
  643. docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \
  644. docker-php-ext-install imap \
  645. ;fi
  646. ###########################################################################
  647. # Calendar:
  648. ###########################################################################
  649. USER root
  650. ARG INSTALL_CALENDAR=false
  651. RUN if [ ${INSTALL_CALENDAR} = true ]; then \
  652. docker-php-ext-configure calendar && \
  653. docker-php-ext-install calendar \
  654. ;fi
  655. ###########################################################################
  656. # Phalcon:
  657. ###########################################################################
  658. ARG INSTALL_PHALCON=false
  659. ARG LARADOCK_PHALCON_VERSION
  660. ENV LARADOCK_PHALCON_VERSION ${LARADOCK_PHALCON_VERSION}
  661. # Copy phalcon configration
  662. COPY ./phalcon.ini /usr/local/etc/php/conf.d/phalcon.ini.disable
  663. RUN if [ $INSTALL_PHALCON = true ]; then \
  664. apt-get update && apt-get install -y unzip libpcre3-dev gcc make re2c git automake autoconf\
  665. && git clone https://github.com/jbboehr/php-psr.git \
  666. && cd php-psr \
  667. && phpize \
  668. && ./configure \
  669. && make \
  670. && make test \
  671. && make install \
  672. && curl -L -o /tmp/cphalcon.zip https://github.com/phalcon/cphalcon/archive/v${LARADOCK_PHALCON_VERSION}.zip \
  673. && unzip -d /tmp/ /tmp/cphalcon.zip \
  674. && cd /tmp/cphalcon-${LARADOCK_PHALCON_VERSION}/build \
  675. && ./install \
  676. && mv /usr/local/etc/php/conf.d/phalcon.ini.disable /usr/local/etc/php/conf.d/phalcon.ini \
  677. && rm -rf /tmp/cphalcon* \
  678. ;fi
  679. ###########################################################################
  680. # APCU:
  681. ###########################################################################
  682. ARG INSTALL_APCU=false
  683. RUN if [ ${INSTALL_APCU} = true ]; then \
  684. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  685. pecl install -a apcu-4.0.11; \
  686. else \
  687. pecl install apcu; \
  688. fi && \
  689. docker-php-ext-enable apcu \
  690. ;fi
  691. ###########################################################################
  692. # YAML:
  693. ###########################################################################
  694. USER root
  695. ARG INSTALL_YAML=false
  696. RUN if [ ${INSTALL_YAML} = true ]; then \
  697. apt-get install libyaml-dev -y ; \
  698. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  699. pecl install -a yaml-1.3.2; \
  700. else \
  701. pecl install yaml; \
  702. fi && \
  703. docker-php-ext-enable yaml \
  704. ;fi
  705. ###########################################################################
  706. # RDKAFKA:
  707. ###########################################################################
  708. ARG INSTALL_RDKAFKA=false
  709. RUN if [ ${INSTALL_RDKAFKA} = true ]; then \
  710. apt-get install -y librdkafka-dev && \
  711. pecl install rdkafka && \
  712. docker-php-ext-enable rdkafka \
  713. ;fi
  714. ###########################################################################
  715. # GETTEXT:
  716. ###########################################################################
  717. ARG INSTALL_GETTEXT=false
  718. RUN if [ ${INSTALL_GETTEXT} = true ]; then \
  719. apt-get install -y zlib1g-dev libicu-dev g++ libpq-dev libssl-dev gettext && \
  720. docker-php-ext-install gettext \
  721. ;fi
  722. ###########################################################################
  723. # Install additional locales:
  724. ###########################################################################
  725. ARG INSTALL_ADDITIONAL_LOCALES=false
  726. ARG ADDITIONAL_LOCALES
  727. RUN if [ ${INSTALL_ADDITIONAL_LOCALES} = true ]; then \
  728. apt-get install -y locales \
  729. && echo '' >> /usr/share/locale/locale.alias \
  730. && temp="${ADDITIONAL_LOCALES%\"}" \
  731. && temp="${temp#\"}" \
  732. && for i in ${temp}; do sed -i "/$i/s/^#//g" /etc/locale.gen; done \
  733. && locale-gen \
  734. ;fi
  735. ###########################################################################
  736. # MySQL Client:
  737. ###########################################################################
  738. USER root
  739. ARG INSTALL_MYSQL_CLIENT=false
  740. RUN if [ ${INSTALL_MYSQL_CLIENT} = true ]; then \
  741. apt-get -y install default-mysql-client \
  742. ;fi
  743. ###########################################################################
  744. # ping:
  745. ###########################################################################
  746. USER root
  747. ARG INSTALL_PING=false
  748. RUN if [ ${INSTALL_PING} = true ]; then \
  749. apt-get -y install inetutils-ping \
  750. ;fi
  751. ###########################################################################
  752. # sshpass:
  753. ###########################################################################
  754. USER root
  755. ARG INSTALL_SSHPASS=false
  756. RUN if [ ${INSTALL_SSHPASS} = true ]; then \
  757. apt-get -y install sshpass \
  758. ;fi
  759. ###########################################################################
  760. # Docker Client:
  761. ###########################################################################
  762. USER root
  763. ARG INSTALL_DOCKER_CLIENT=false
  764. RUN if [ ${INSTALL_DOCKER_CLIENT} = true ]; then \
  765. curl -sS https://download.docker.com/linux/static/stable/x86_64/docker-20.10.3.tgz -o /tmp/docker.tar.gz && \
  766. tar -xzf /tmp/docker.tar.gz -C /tmp/ && \
  767. cp /tmp/docker/docker* /usr/local/bin && \
  768. chmod +x /usr/local/bin/docker* \
  769. ;fi
  770. ###########################################################################
  771. # FFMPEG:
  772. ###########################################################################
  773. USER root
  774. ARG INSTALL_FFMPEG=false
  775. RUN if [ ${INSTALL_FFMPEG} = true ]; then \
  776. apt-get -y install ffmpeg \
  777. ;fi
  778. ###########################################################################
  779. # BBC Audio Waveform Image Generator:
  780. ###########################################################################
  781. USER root
  782. ARG INSTALL_AUDIOWAVEFORM=false
  783. RUN if [ ${INSTALL_AUDIOWAVEFORM} = true ]; then \
  784. 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 \
  785. && git clone https://github.com/bbc/audiowaveform.git \
  786. && cd audiowaveform \
  787. && wget https://github.com/google/googletest/archive/release-1.10.0.tar.gz \
  788. && tar xzf release-1.10.0.tar.gz \
  789. && ln -s googletest-release-1.10.0/googletest googletest \
  790. && ln -s googletest-release-1.10.0/googlemock googlemock \
  791. && mkdir build \
  792. && cd build \
  793. && cmake .. \
  794. && make \
  795. && make install \
  796. ;fi
  797. #####################################
  798. # wkhtmltopdf:
  799. #####################################
  800. USER root
  801. ARG INSTALL_WKHTMLTOPDF=false
  802. RUN if [ ${INSTALL_WKHTMLTOPDF} = true ]; then \
  803. apt-get install -y \
  804. libxrender1 \
  805. libfontconfig1 \
  806. libx11-dev \
  807. libjpeg62 \
  808. libxtst6 \
  809. fontconfig \
  810. libjpeg62-turbo \
  811. xfonts-base \
  812. xfonts-75dpi \
  813. wget \
  814. && wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.stretch_amd64.deb \
  815. && dpkg -i wkhtmltox_0.12.6-1.stretch_amd64.deb \
  816. && apt -f install \
  817. ;fi
  818. ###########################################################################
  819. # Mailparse extension:
  820. ###########################################################################
  821. ARG INSTALL_MAILPARSE=false
  822. RUN if [ ${INSTALL_MAILPARSE} = true ]; then \
  823. # Install mailparse extension
  824. printf "\n" | pecl install -o -f mailparse \
  825. && rm -rf /tmp/pear \
  826. && docker-php-ext-enable mailparse \
  827. ;fi
  828. ###########################################################################
  829. # CacheTool:
  830. ###########################################################################
  831. ARG INSTALL_CACHETOOL=false
  832. RUN if [ ${INSTALL_CACHETOOL} = true ]; then \
  833. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ] && [ $(php -r "echo PHP_MINOR_VERSION;") -ge 1 ]; then \
  834. curl -sO http://gordalina.github.io/cachetool/downloads/cachetool.phar; \
  835. else \
  836. curl http://gordalina.github.io/cachetool/downloads/cachetool-3.2.1.phar -o cachetool.phar; \
  837. fi && \
  838. chmod +x cachetool.phar && \
  839. mv cachetool.phar /usr/local/bin/cachetool \
  840. ;fi
  841. ###########################################################################
  842. # XMLRPC:
  843. ###########################################################################
  844. ARG INSTALL_XMLRPC=false
  845. RUN if [ ${INSTALL_XMLRPC} = true ]; then \
  846. docker-php-ext-install xmlrpc \
  847. ;fi
  848. ###########################################################################
  849. # New Relic for PHP:
  850. ###########################################################################
  851. ARG NEW_RELIC=${NEW_RELIC}
  852. ARG NEW_RELIC_KEY=${NEW_RELIC_KEY}
  853. ARG NEW_RELIC_APP_NAME=${NEW_RELIC_APP_NAME}
  854. RUN if [ ${NEW_RELIC} = true ]; then \
  855. 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 && \
  856. export NR_INSTALL_USE_CP_NOT_LN=1 && \
  857. export NR_INSTALL_SILENT=1 && \
  858. /tmp/newrelic-php5-*/newrelic-install install && \
  859. rm -rf /tmp/newrelic-php5-* /tmp/nrinstall* && \
  860. sed -i \
  861. -e 's/"REPLACE_WITH_REAL_KEY"/"${NEW_RELIC_KEY}"/' \
  862. -e 's/newrelic.appname = "PHP Application"/newrelic.appname = "${NEW_RELIC_APP_NAME}"/' \
  863. -e 's/;newrelic.daemon.app_connect_timeout =.*/newrelic.daemon.app_connect_timeout=15s/' \
  864. -e 's/;newrelic.daemon.start_timeout =.*/newrelic.daemon.start_timeout=5s/' \
  865. /usr/local/etc/php/conf.d/newrelic.ini \
  866. ;fi
  867. ###########################################################################
  868. # Downgrade Openssl:
  869. ###########################################################################
  870. ARG DOWNGRADE_OPENSSL_TLS_AND_SECLEVEL=false
  871. RUN if [ ${DOWNGRADE_OPENSSL_TLS_AND_SECLEVEL} = true ]; then \
  872. sed -i 's,^\(MinProtocol[ ]*=\).*,\1'TLSv1.2',g' /etc/ssl/openssl.cnf \
  873. && \
  874. sed -i 's,^\(CipherString[ ]*=\).*,\1'DEFAULT@SECLEVEL=1',g' /etc/ssl/openssl.cnf\
  875. ;fi
  876. ###########################################################################
  877. # Check PHP version:
  878. ###########################################################################
  879. RUN set -xe; php -v | head -n 1 | grep -q "PHP ${LARADOCK_PHP_VERSION}."
  880. #
  881. #--------------------------------------------------------------------------
  882. # Final Touch
  883. #--------------------------------------------------------------------------
  884. #
  885. COPY ./laravel.ini /usr/local/etc/php/conf.d
  886. COPY ./xlaravel.pool.conf /usr/local/etc/php-fpm.d/
  887. USER root
  888. # Clean up
  889. RUN apt-get clean && \
  890. rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
  891. rm /var/log/lastlog /var/log/faillog
  892. # Configure non-root user.
  893. ARG PUID=1000
  894. ENV PUID ${PUID}
  895. ARG PGID=1000
  896. ENV PGID ${PGID}
  897. RUN groupmod -o -g ${PGID} www-data && \
  898. usermod -o -u ${PUID} -g www-data www-data
  899. # Adding the faketime library to the preload file needs to be done last
  900. # otherwise it will preload it for all commands that follow in this file
  901. RUN if [ ${INSTALL_FAKETIME} = true ]; then \
  902. echo "/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1" > /etc/ld.so.preload \
  903. ;fi
  904. # Configure locale.
  905. ARG LOCALE=POSIX
  906. ENV LC_ALL ${LOCALE}
  907. WORKDIR /var/www
  908. CMD ["php-fpm"]
  909. EXPOSE 9000