Dockerfile 38 KB

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