Dockerfile 30 KB

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