Dockerfile 31 KB

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