Dockerfile 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  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.2-${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. # always run apt update when start and after add new source list, then clean up at end.
  21. RUN apt-get update -yqq && \
  22. apt-get install -y apt-utils && \
  23. pecl channel-update pecl.php.net
  24. #
  25. #--------------------------------------------------------------------------
  26. # Mandatory Software's Installation
  27. #--------------------------------------------------------------------------
  28. #
  29. # Mandatory Software's such as ("mcrypt", "pdo_mysql", "libssl-dev", ....)
  30. # are installed on the base image 'laradock/php-fpm' image. If you want
  31. # to add more Software's or remove existing one, you need to edit the
  32. # base image (https://github.com/Laradock/php-fpm).
  33. #
  34. #
  35. #--------------------------------------------------------------------------
  36. # Optional Software's Installation
  37. #--------------------------------------------------------------------------
  38. #
  39. # Optional Software's will only be installed if you set them to `true`
  40. # in the `docker-compose.yml` before the build.
  41. # Example:
  42. # - INSTALL_ZIP_ARCHIVE=true
  43. #
  44. ###########################################################################
  45. # SOAP:
  46. ###########################################################################
  47. ARG INSTALL_SOAP=false
  48. RUN if [ ${INSTALL_SOAP} = true ]; then \
  49. # Install the soap extension
  50. rm /etc/apt/preferences.d/no-debian-php && \
  51. apt-get -y install libxml2-dev php-soap && \
  52. docker-php-ext-install soap \
  53. ;fi
  54. ###########################################################################
  55. # pgsql
  56. ###########################################################################
  57. ARG INSTALL_PGSQL=false
  58. RUN if [ ${INSTALL_PGSQL} = true ]; then \
  59. # Install the pgsql extension
  60. docker-php-ext-install pgsql \
  61. ;fi
  62. ###########################################################################
  63. # pgsql client
  64. ###########################################################################
  65. ARG INSTALL_PG_CLIENT=false
  66. RUN if [ ${INSTALL_PG_CLIENT} = true ]; then \
  67. # Create folders if not exists (https://github.com/tianon/docker-brew-debian/issues/65)
  68. mkdir -p /usr/share/man/man1 && \
  69. mkdir -p /usr/share/man/man7 && \
  70. # Install the pgsql client
  71. apt-get install -y postgresql-client \
  72. ;fi
  73. ###########################################################################
  74. # xDebug:
  75. ###########################################################################
  76. ARG INSTALL_XDEBUG=false
  77. RUN if [ ${INSTALL_XDEBUG} = true ]; then \
  78. # Install the xdebug extension
  79. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  80. pecl install xdebug-2.5.5; \
  81. else \
  82. pecl install xdebug; \
  83. fi && \
  84. docker-php-ext-enable xdebug \
  85. ;fi
  86. # Copy xdebug configuration for remote debugging
  87. COPY ./xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
  88. RUN sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /usr/local/etc/php/conf.d/xdebug.ini && \
  89. sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /usr/local/etc/php/conf.d/xdebug.ini && \
  90. sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /usr/local/etc/php/conf.d/xdebug.ini
  91. ###########################################################################
  92. # Phpdbg:
  93. ###########################################################################
  94. ARG INSTALL_PHPDBG=false
  95. RUN if [ ${INSTALL_PHPDBG} = true ]; then \
  96. # Load the xdebug extension only with phpunit commands
  97. apt-get install -y --force-yes php${LARADOCK_PHP_VERSION}-phpdbg \
  98. ;fi
  99. ###########################################################################
  100. # Blackfire:
  101. ###########################################################################
  102. ARG INSTALL_BLACKFIRE=false
  103. RUN if [ ${INSTALL_XDEBUG} = false -a ${INSTALL_BLACKFIRE} = true ]; then \
  104. version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
  105. && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \
  106. && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp \
  107. && mv /tmp/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \
  108. && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \
  109. ;fi
  110. ###########################################################################
  111. # PHP REDIS EXTENSION
  112. ###########################################################################
  113. ARG INSTALL_PHPREDIS=false
  114. RUN if [ ${INSTALL_PHPREDIS} = true ]; then \
  115. # Install Php Redis Extension
  116. printf "\n" | pecl install -o -f redis \
  117. && rm -rf /tmp/pear \
  118. && docker-php-ext-enable redis \
  119. ;fi
  120. ###########################################################################
  121. # Swoole EXTENSION
  122. ###########################################################################
  123. ARG INSTALL_SWOOLE=false
  124. RUN if [ ${INSTALL_SWOOLE} = true ]; then \
  125. # Install Php Swoole Extension
  126. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  127. pecl install swoole-2.0.11; \
  128. else \
  129. if [ $(php -r "echo PHP_MINOR_VERSION;") = "0" ]; then \
  130. pecl install swoole-2.2.0; \
  131. else \
  132. pecl install swoole; \
  133. fi \
  134. fi && \
  135. docker-php-ext-enable swoole \
  136. ;fi
  137. ###########################################################################
  138. # MongoDB:
  139. ###########################################################################
  140. ARG INSTALL_MONGO=false
  141. RUN if [ ${INSTALL_MONGO} = true ]; then \
  142. # Install the mongodb extension
  143. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  144. pecl install mongo && \
  145. docker-php-ext-enable mongo \
  146. ;fi && \
  147. pecl install mongodb && \
  148. docker-php-ext-enable mongodb \
  149. ;fi
  150. ###########################################################################
  151. # AMQP:
  152. ###########################################################################
  153. ARG INSTALL_AMQP=false
  154. RUN if [ ${INSTALL_AMQP} = true ]; then \
  155. apt-get install librabbitmq-dev -y && \
  156. # Install the amqp extension
  157. pecl install amqp && \
  158. docker-php-ext-enable amqp \
  159. ;fi
  160. ###########################################################################
  161. # ZipArchive:
  162. ###########################################################################
  163. ARG INSTALL_ZIP_ARCHIVE=false
  164. RUN if [ ${INSTALL_ZIP_ARCHIVE} = true ]; then \
  165. apt-get install libzip-dev -y && \
  166. docker-php-ext-configure zip --with-libzip && \
  167. # Install the zip extension
  168. docker-php-ext-install zip \
  169. ;fi
  170. ###########################################################################
  171. # pcntl
  172. ###########################################################################
  173. ARG INSTALL_PCNTL=false
  174. RUN if [ ${INSTALL_PCNTL} = true ]; then \
  175. # Installs pcntl, helpful for running Horizon
  176. docker-php-ext-install pcntl \
  177. ;fi
  178. ###########################################################################
  179. # bcmath:
  180. ###########################################################################
  181. ARG INSTALL_BCMATH=false
  182. RUN if [ ${INSTALL_BCMATH} = true ]; then \
  183. # Install the bcmath extension
  184. docker-php-ext-install bcmath \
  185. ;fi
  186. ###########################################################################
  187. # GMP (GNU Multiple Precision):
  188. ###########################################################################
  189. ARG INSTALL_GMP=false
  190. RUN if [ ${INSTALL_GMP} = true ]; then \
  191. # Install the GMP extension
  192. apt-get install -y libgmp-dev && \
  193. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  194. ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h \
  195. ;fi && \
  196. docker-php-ext-install gmp \
  197. ;fi
  198. ###########################################################################
  199. # PHP Memcached:
  200. ###########################################################################
  201. ARG INSTALL_MEMCACHED=false
  202. RUN if [ ${INSTALL_MEMCACHED} = true ]; then \
  203. # Install the php memcached extension
  204. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  205. curl -L -o /tmp/memcached.tar.gz "https://github.com/php-memcached-dev/php-memcached/archive/2.2.0.tar.gz"; \
  206. else \
  207. curl -L -o /tmp/memcached.tar.gz "https://github.com/php-memcached-dev/php-memcached/archive/php7.tar.gz"; \
  208. fi \
  209. && mkdir -p memcached \
  210. && tar -C memcached -zxvf /tmp/memcached.tar.gz --strip 1 \
  211. && ( \
  212. cd memcached \
  213. && phpize \
  214. && ./configure \
  215. && make -j$(nproc) \
  216. && make install \
  217. ) \
  218. && rm -r memcached \
  219. && rm /tmp/memcached.tar.gz \
  220. && docker-php-ext-enable memcached \
  221. ;fi
  222. ###########################################################################
  223. # Exif:
  224. ###########################################################################
  225. ARG INSTALL_EXIF=false
  226. RUN if [ ${INSTALL_EXIF} = true ]; then \
  227. # Enable Exif PHP extentions requirements
  228. docker-php-ext-install exif \
  229. ;fi
  230. ###########################################################################
  231. # PHP Aerospike:
  232. ###########################################################################
  233. USER root
  234. ARG INSTALL_AEROSPIKE=false
  235. ARG AEROSPIKE_PHP_REPOSITORY
  236. RUN if [ ${INSTALL_AEROSPIKE} = true ]; then \
  237. # Fix dependencies for PHPUnit within aerospike extension
  238. apt-get -y install sudo wget && \
  239. # Install the php aerospike extension
  240. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  241. curl -L -o /tmp/aerospike-client-php.tar.gz https://github.com/aerospike/aerospike-client-php5/archive/master.tar.gz; \
  242. else \
  243. curl -L -o /tmp/aerospike-client-php.tar.gz ${AEROSPIKE_PHP_REPOSITORY}; \
  244. fi \
  245. && mkdir -p aerospike-client-php \
  246. && tar -C aerospike-client-php -zxvf /tmp/aerospike-client-php.tar.gz --strip 1 \
  247. && \
  248. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  249. ( \
  250. cd aerospike-client-php/src/aerospike \
  251. && phpize \
  252. && ./build.sh \
  253. && make install \
  254. ) \
  255. else \
  256. ( \
  257. cd aerospike-client-php/src \
  258. && phpize \
  259. && ./build.sh \
  260. && make install \
  261. ) \
  262. fi \
  263. && rm /tmp/aerospike-client-php.tar.gz \
  264. && docker-php-ext-enable aerospike \
  265. ;fi
  266. ###########################################################################
  267. # Opcache:
  268. ###########################################################################
  269. ARG INSTALL_OPCACHE=false
  270. RUN if [ ${INSTALL_OPCACHE} = true ]; then \
  271. docker-php-ext-install opcache \
  272. ;fi
  273. # Copy opcache configration
  274. COPY ./opcache.ini /usr/local/etc/php/conf.d/opcache.ini
  275. ###########################################################################
  276. # Mysqli Modifications:
  277. ###########################################################################
  278. ARG INSTALL_MYSQLI=false
  279. RUN if [ ${INSTALL_MYSQLI} = true ]; then \
  280. docker-php-ext-install mysqli \
  281. ;fi
  282. ###########################################################################
  283. # Tokenizer Modifications:
  284. ###########################################################################
  285. ARG INSTALL_TOKENIZER=false
  286. RUN if [ ${INSTALL_TOKENIZER} = true ]; then \
  287. docker-php-ext-install tokenizer \
  288. ;fi
  289. ###########################################################################
  290. # Human Language and Character Encoding Support:
  291. ###########################################################################
  292. ARG INSTALL_INTL=false
  293. RUN if [ ${INSTALL_INTL} = true ]; then \
  294. # Install intl and requirements
  295. apt-get install -y zlib1g-dev libicu-dev g++ && \
  296. docker-php-ext-configure intl && \
  297. docker-php-ext-install intl \
  298. ;fi
  299. ###########################################################################
  300. # GHOSTSCRIPT:
  301. ###########################################################################
  302. ARG INSTALL_GHOSTSCRIPT=false
  303. RUN if [ ${INSTALL_GHOSTSCRIPT} = true ]; then \
  304. # Install the ghostscript extension
  305. # for PDF editing
  306. apt-get install -y \
  307. poppler-utils \
  308. ghostscript \
  309. ;fi
  310. ###########################################################################
  311. # LDAP:
  312. ###########################################################################
  313. ARG INSTALL_LDAP=false
  314. RUN if [ ${INSTALL_LDAP} = true ]; then \
  315. apt-get install -y libldap2-dev && \
  316. docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ && \
  317. docker-php-ext-install ldap \
  318. ;fi
  319. ###########################################################################
  320. # SQL SERVER:
  321. ###########################################################################
  322. ARG INSTALL_MSSQL=false
  323. RUN set -eux; if [ ${INSTALL_MSSQL} = true ]; then \
  324. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  325. apt-get -y install freetds-dev libsybdb5 \
  326. && ln -s /usr/lib/x86_64-linux-gnu/libsybdb.so /usr/lib/libsybdb.so \
  327. && docker-php-ext-install mssql pdo_dblib \
  328. && php -m | grep -q 'mssql' \
  329. && php -m | grep -q 'pdo_dblib' \
  330. ;else \
  331. ###########################################################################
  332. # Ref from https://github.com/Microsoft/msphpsql/wiki/Dockerfile-for-adding-pdo_sqlsrv-and-sqlsrv-to-official-php-image
  333. ###########################################################################
  334. # Add Microsoft repo for Microsoft ODBC Driver 13 for Linux
  335. apt-get install -y apt-transport-https gnupg \
  336. && curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
  337. && curl https://packages.microsoft.com/config/debian/9/prod.list > /etc/apt/sources.list.d/mssql-release.list \
  338. && apt-get update -yqq \
  339. # Install Dependencies
  340. && ACCEPT_EULA=Y apt-get install -y unixodbc unixodbc-dev libgss3 odbcinst msodbcsql17 locales \
  341. && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
  342. # link local aliases
  343. && ln -sfn /etc/locale.alias /usr/share/locale/locale.alias \
  344. && locale-gen \
  345. # Install pdo_sqlsrv and sqlsrv from PECL. Replace pdo_sqlsrv-4.1.8preview with preferred version.
  346. && pecl install pdo_sqlsrv sqlsrv \
  347. && docker-php-ext-enable pdo_sqlsrv sqlsrv \
  348. && php -m | grep -q 'pdo_sqlsrv' \
  349. && php -m | grep -q 'sqlsrv' \
  350. ;fi \
  351. ;fi
  352. ###########################################################################
  353. # Image optimizers:
  354. ###########################################################################
  355. USER root
  356. ARG INSTALL_IMAGE_OPTIMIZERS=false
  357. RUN if [ ${INSTALL_IMAGE_OPTIMIZERS} = true ]; then \
  358. apt-get install -y jpegoptim optipng pngquant gifsicle \
  359. ;fi
  360. ###########################################################################
  361. # ImageMagick:
  362. ###########################################################################
  363. USER root
  364. ARG INSTALL_IMAGEMAGICK=false
  365. RUN if [ ${INSTALL_IMAGEMAGICK} = true ]; then \
  366. apt-get install -y libmagickwand-dev imagemagick && \
  367. pecl install imagick && \
  368. docker-php-ext-enable imagick \
  369. ;fi
  370. ###########################################################################
  371. # IMAP:
  372. ###########################################################################
  373. ARG INSTALL_IMAP=false
  374. RUN if [ ${INSTALL_IMAP} = true ]; then \
  375. apt-get install -y libc-client-dev libkrb5-dev && \
  376. rm -r /var/lib/apt/lists/* && \
  377. docker-php-ext-configure imap --with-kerberos --with-imap-ssl && \
  378. docker-php-ext-install imap \
  379. ;fi
  380. ###########################################################################
  381. # Calendar:
  382. ###########################################################################
  383. USER root
  384. ARG INSTALL_CALENDAR=false
  385. RUN if [ ${INSTALL_CALENDAR} = true ]; then \
  386. docker-php-ext-configure calendar && \
  387. docker-php-ext-install calendar \
  388. ;fi
  389. ###########################################################################
  390. # libfaketime:
  391. ###########################################################################
  392. USER root
  393. ARG INSTALL_FAKETIME=false
  394. RUN if [ ${INSTALL_FAKETIME} = true ]; then \
  395. apt-get install -y libfaketime \
  396. ;fi
  397. ###########################################################################
  398. # Check PHP version:
  399. ###########################################################################
  400. RUN php -v | head -n 1 | grep -q "PHP ${LARADOCK_PHP_VERSION}."
  401. #
  402. #--------------------------------------------------------------------------
  403. # Final Touch
  404. #--------------------------------------------------------------------------
  405. #
  406. COPY ./laravel.ini /usr/local/etc/php/conf.d
  407. COPY ./xlaravel.pool.conf /usr/local/etc/php-fpm.d/
  408. USER root
  409. # Clean up
  410. RUN apt-get clean && \
  411. rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
  412. rm /var/log/lastlog /var/log/faillog
  413. RUN usermod -u 1000 www-data
  414. # Adding the faketime library to the preload file needs to be done last
  415. # otherwise it will preload it for all commands that follow in this file
  416. RUN if [ ${INSTALL_FAKETIME} = true ]; then \
  417. echo "/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1" > /etc/ld.so.preload \
  418. ;fi
  419. WORKDIR /var/www
  420. CMD ["php-fpm"]
  421. EXPOSE 9000