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