Dockerfile 30 KB

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