Dockerfile 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. #
  2. #--------------------------------------------------------------------------
  3. # Image Setup
  4. #--------------------------------------------------------------------------
  5. #
  6. ARG LARADOCK_PHP_VERSION
  7. FROM php:${LARADOCK_PHP_VERSION}-alpine
  8. LABEL maintainer="Mahmoud Zalt <mahmoud@zalt.me>"
  9. ARG LARADOCK_PHP_VERSION
  10. # If you're in China, or you need to change sources, will be set CHANGE_SOURCE to true in .env.
  11. ARG CHANGE_SOURCE=false
  12. RUN if [ ${CHANGE_SOURCE} = true ]; then \
  13. # Change application source from dl-cdn.alpinelinux.org to aliyun source
  14. sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories \
  15. ;fi
  16. RUN apk --update add wget \
  17. curl \
  18. git \
  19. build-base \
  20. libmemcached-dev \
  21. libmcrypt-dev \
  22. libxml2-dev \
  23. zlib-dev \
  24. autoconf \
  25. cyrus-sasl-dev \
  26. libgsasl-dev \
  27. supervisor \
  28. oniguruma-dev \
  29. procps
  30. RUN docker-php-ext-install mysqli mbstring pdo pdo_mysql tokenizer xml pcntl
  31. RUN pecl channel-update pecl.php.net && pecl install memcached mcrypt-1.0.1 mongodb && docker-php-ext-enable memcached mongodb
  32. # Add a non-root user to help install ffmpeg:
  33. ARG PUID=1000
  34. ENV PUID ${PUID}
  35. ARG PGID=1000
  36. ENV PGID ${PGID}
  37. RUN addgroup -g ${PGID} laradock && \
  38. adduser -D -G laradock -u ${PUID} laradock
  39. #Install BZ2:
  40. ARG INSTALL_BZ2=false
  41. RUN if [ ${INSTALL_BZ2} = true ]; then \
  42. apk --update add bzip2-dev; \
  43. docker-php-ext-install bz2 \
  44. ;fi
  45. #Install GD package:
  46. ARG INSTALL_GD=false
  47. RUN if [ ${INSTALL_GD} = true ]; then \
  48. apk add --update --no-cache libpng-dev; \
  49. docker-php-ext-install gd \
  50. ;fi
  51. #Install GMP package:
  52. ARG INSTALL_GMP=false
  53. RUN if [ ${INSTALL_GMP} = true ]; then \
  54. apk add --update --no-cache gmp gmp-dev; \
  55. docker-php-ext-install gmp \
  56. ;fi
  57. #Install BCMath package:
  58. ARG INSTALL_BCMATH=false
  59. RUN if [ ${INSTALL_BCMATH} = true ]; then \
  60. docker-php-ext-install bcmath \
  61. ;fi
  62. #Install Sockets package:
  63. ARG INSTALL_SOCKETS=false
  64. RUN if [ ${INSTALL_SOCKETS} = true ]; then \
  65. docker-php-ext-install sockets \
  66. ;fi
  67. # Install PostgreSQL drivers:
  68. ARG INSTALL_PGSQL=false
  69. RUN if [ ${INSTALL_PGSQL} = true ]; then \
  70. apk --update add postgresql-dev \
  71. && docker-php-ext-install pdo_pgsql \
  72. ;fi
  73. # Install ZipArchive:
  74. ARG INSTALL_ZIP_ARCHIVE=false
  75. RUN set -eux; \
  76. if [ ${INSTALL_ZIP_ARCHIVE} = true ]; then \
  77. apk --update add libzip-dev && \
  78. if [ ${LARADOCK_PHP_VERSION} = "7.3" ] || [ ${LARADOCK_PHP_VERSION} = "7.4" ]; then \
  79. docker-php-ext-configure zip; \
  80. else \
  81. docker-php-ext-configure zip --with-libzip; \
  82. fi && \
  83. # Install the zip extension
  84. docker-php-ext-install zip \
  85. ;fi
  86. # Install PhpRedis package:
  87. ARG INSTALL_PHPREDIS=false
  88. RUN if [ ${INSTALL_PHPREDIS} = true ]; then \
  89. # Install Php Redis Extension
  90. printf "\n" | pecl install -o -f redis \
  91. && rm -rf /tmp/pear \
  92. && docker-php-ext-enable redis \
  93. ;fi
  94. ARG INSTALL_FFMPEG=false
  95. RUN if [ ${INSTALL_FFMPEG} = true ]; then \
  96. # Add ffmpeg to horizon
  97. apk add ffmpeg \
  98. ;fi
  99. # Install Cassandra drivers:
  100. ARG INSTALL_CASSANDRA=false
  101. RUN if [ ${INSTALL_CASSANDRA} = true ]; then \
  102. apk --update add cassandra-cpp-driver \
  103. ;fi
  104. WORKDIR /usr/src
  105. RUN if [ ${INSTALL_CASSANDRA} = true ]; then \
  106. git clone https://github.com/datastax/php-driver.git \
  107. && cd php-driver/ext \
  108. && phpize \
  109. && mkdir -p /usr/src/php-driver/build \
  110. && cd /usr/src/php-driver/build \
  111. && ../ext/configure > /dev/null \
  112. && make clean >/dev/null \
  113. && make >/dev/null 2>&1 \
  114. && make install \
  115. && docker-php-ext-enable cassandra \
  116. ;fi
  117. # Install MongoDB drivers:
  118. ARG INSTALL_MONGO=false
  119. RUN if [ ${INSTALL_MONGO} = true ]; then \
  120. pecl install mongodb \
  121. && docker-php-ext-enable mongodb \
  122. ;fi
  123. ###########################################################################
  124. # YAML: extension
  125. ###########################################################################
  126. ARG INSTALL_YAML=false
  127. RUN if [ ${INSTALL_YAML} = true ]; then \
  128. apk --update add -U --no-cache --virtual temp yaml-dev \
  129. && apk add --no-cache yaml \
  130. && docker-php-source extract \
  131. && pecl channel-update pecl.php.net \
  132. && pecl install yaml \
  133. && docker-php-ext-enable yaml \
  134. && pecl clear-cache \
  135. && docker-php-source delete \
  136. && apk del temp \
  137. ;fi
  138. ###########################################################################
  139. # PHP Memcached:
  140. ###########################################################################
  141. ARG INSTALL_MEMCACHED=false
  142. RUN if [ ${INSTALL_MEMCACHED} = true ]; then \
  143. # Install the php memcached extension
  144. if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  145. curl -L -o /tmp/memcached.tar.gz "https://github.com/php-memcached-dev/php-memcached/archive/2.2.0.tar.gz"; \
  146. else \
  147. curl -L -o /tmp/memcached.tar.gz "https://github.com/php-memcached-dev/php-memcached/archive/v3.1.3.tar.gz"; \
  148. fi \
  149. && mkdir -p memcached \
  150. && tar -C memcached -zxvf /tmp/memcached.tar.gz --strip 1 \
  151. && ( \
  152. cd memcached \
  153. && phpize \
  154. && ./configure \
  155. && make -j$(nproc) \
  156. && make install \
  157. ) \
  158. && rm -r memcached \
  159. && rm /tmp/memcached.tar.gz \
  160. && docker-php-ext-enable memcached \
  161. ;fi
  162. RUN rm /var/cache/apk/* \
  163. && mkdir -p /var/www
  164. #
  165. #--------------------------------------------------------------------------
  166. # Optional Supervisord Configuration
  167. #--------------------------------------------------------------------------
  168. #
  169. # Modify the ./supervisor.conf file to match your App's requirements.
  170. # Make sure you rebuild your container with every change.
  171. #
  172. COPY supervisord.conf /etc/supervisord.conf
  173. ENTRYPOINT ["/usr/bin/supervisord", "-n", "-c", "/etc/supervisord.conf"]
  174. #
  175. #--------------------------------------------------------------------------
  176. # Optional Software's Installation
  177. #--------------------------------------------------------------------------
  178. #
  179. # If you need to modify this image, feel free to do it right here.
  180. #
  181. # -- Your awesome modifications go here -- #
  182. #
  183. #--------------------------------------------------------------------------
  184. # Check PHP version
  185. #--------------------------------------------------------------------------
  186. #
  187. RUN php -v | head -n 1 | grep -q "PHP ${PHP_VERSION}."
  188. #
  189. #--------------------------------------------------------------------------
  190. # Final Touch
  191. #--------------------------------------------------------------------------
  192. #
  193. WORKDIR /etc/supervisor/conf.d/