You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

284 lines
9.1 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. # Set Environment Variables
  2. ENV DEBIAN_FRONTEND noninteractive
  3. # Start as root
  4. USER root
  5. ###########################################################################
  6. # Laradock non-root user:
  7. ###########################################################################
  8. # Add a non-root user to prevent files being created with root permissions on host machine.
  9. ARG PUID=1000
  10. ENV PUID ${PUID}
  11. ARG PGID=1000
  12. ENV PGID ${PGID}
  13. # always run apt update when start and after add new source list, then clean up at end.
  14. RUN set -xe; \
  15. apt-get update -yqq && \
  16. pecl channel-update pecl.php.net && \
  17. groupadd -g ${PGID} laradock && \
  18. useradd -u ${PUID} -g laradock -m laradock -G docker_env && \
  19. usermod -p "*" laradock -s /bin/bash && \
  20. apt-get install -yqq \
  21. apt-utils \
  22. #
  23. #--------------------------------------------------------------------------
  24. # Mandatory Software's Installation
  25. #--------------------------------------------------------------------------
  26. #
  27. # Mandatory Software's such as ("php-cli", "git", "vim", ....) are
  28. # installed on the base image 'laradock/workspace' image. If you want
  29. # to add more Software's or remove existing one, you need to edit the
  30. # base image (https://github.com/Laradock/workspace).
  31. #
  32. # next lines are here becase there is no auto build on dockerhub see https://github.com/laradock/laradock/pull/1903#issuecomment-463142846
  33. libzip-dev zip unzip \
  34. # Install the zip extension
  35. php${PHP_VERSION}-zip \
  36. # nasm
  37. nasm && \
  38. php -m | grep -q 'zip'
  39. #
  40. #--------------------------------------------------------------------------
  41. # Optional Software's Installation
  42. #--------------------------------------------------------------------------
  43. #
  44. # Optional Software's will only be installed if you set them to `true`
  45. # in the `docker-compose.yml` before the build.
  46. # Example:
  47. # - WORKSPACE_INSTALL_NODE=false
  48. # - ...
  49. #
  50. ###########################################################################
  51. # Set Timezone
  52. ###########################################################################
  53. ARG TZ=Europe/Moscow
  54. ENV TZ ${TZ}
  55. RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
  56. ###########################################################################
  57. # Root Aliases
  58. ###########################################################################
  59. USER root
  60. COPY ./aliases.sh /root/aliases.sh
  61. RUN sed -i 's/\r//' /root/aliases.sh && \
  62. echo "" >> ~/.bashrc && \
  63. echo "# Load Custom Aliases" >> ~/.bashrc && \
  64. echo "source ~/aliases.sh" >> ~/.bashrc && \
  65. echo "" >> ~/.bashrc \
  66. ###########################################################################
  67. # ssh:
  68. ###########################################################################
  69. USER root
  70. ARG INSTALL_SSH=false
  71. ENV INSTALL_SSH ${INSTALL_SSH}
  72. RUN if [ ${INSTALL_SSH} = true ]; then \
  73. rm -f /etc/service/sshd/down \
  74. ;fi
  75. USER laradock
  76. RUN if [ ${INSTALL_SSH} = true ]; then \
  77. mkdir -p ~/.ssh \
  78. && ln -s /run/secrets/user_ssh_key ~/.ssh/id_rsa \
  79. && ln -s /run/secrets/user_known_hosts ~/.ssh/known_hosts \
  80. ;fi
  81. ###########################################################################
  82. # MySQL Client:
  83. ###########################################################################
  84. USER root
  85. ARG INSTALL_MYSQL_CLIENT=false
  86. RUN if [ ${INSTALL_MYSQL_CLIENT} = true ]; then \
  87. apt-get update -yqq && \
  88. apt-get -y install mysql-client \
  89. ;fi
  90. ###########################################################################
  91. # fswatch
  92. ###########################################################################
  93. USER root
  94. ARG INSTALL_FSWATCH=false
  95. RUN if [ ${INSTALL_FSWATCH} = true ]; then \
  96. apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 47FE03C1 \
  97. && add-apt-repository -y ppa:hadret/fswatch \
  98. || apt-get update -yqq \
  99. && apt-get -y install fswatch \
  100. ;fi
  101. ###########################################################################
  102. # ping:
  103. ###########################################################################
  104. USER root
  105. ARG INSTALL_PING=false
  106. RUN if [ ${INSTALL_PING} = true ]; then \
  107. apt-get update -yqq && \
  108. apt-get -y install inetutils-ping \
  109. ;fi
  110. ###########################################################################
  111. # Install S3 minio client:
  112. ###########################################################################
  113. USER root
  114. ARG INSTALL_S3_MINIO_CLIENT=false
  115. RUN if [ ${INSTALL_S3_MINIO_CLIENT} = true ]; then \
  116. curl https://dl.min.io/client/mc/release/linux-amd64/mc > /usr/local/sbin/mc \
  117. && chmod +x /usr/local/sbin/mc \
  118. ; fi
  119. ###########################################################################
  120. # xDebug:
  121. ###########################################################################
  122. RUN if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
  123. pecl install xdebug-2.5.5; \
  124. elif [ $(php -r "echo PHP_MAJOR_VERSION;") = "8" ]; then \
  125. pecl install xdebug-3.1.6; \
  126. else \
  127. pecl install xdebug-2.9.8; \
  128. fi && \
  129. echo ';zend_extension=xdebug.so' > /etc/php/${PHP_VERSION}/cli/conf.d/20-xdebug.ini && \
  130. echo "alias phpunit='php -dzend_extension=xdebug.so /var/www/vendor/bin/phpunit'" >> ~/.bashrc
  131. ###########################################################################
  132. # BZ2:
  133. ###########################################################################
  134. ARG INSTALL_BZ2=false
  135. RUN if [ ${INSTALL_BZ2} = true ]; then \
  136. apt-get install -y php${PHP_VERSION}-bz2 \
  137. ;fi
  138. ###########################################################################
  139. # Non-root user : PHPUnit path
  140. ###########################################################################
  141. # add ./vendor/bin to non-root user's bashrc (needed for phpunit)
  142. USER laradock
  143. RUN echo "" >> ~/.bashrc && \
  144. echo 'export PATH="/var/www/vendor/bin:$PATH"' >> ~/.bashrc
  145. ###########################################################################
  146. # Check PHP version:
  147. ###########################################################################
  148. RUN set -xe; php -v | head -n 1 | grep -q "PHP ${PHP_VERSION}."
  149. ###########################################################################
  150. # WP CLI:
  151. ###########################################################################
  152. # The command line interface for WordPress
  153. USER root
  154. ARG INSTALL_WP_CLI=false
  155. RUN if [ ${INSTALL_WP_CLI} = true ]; then \
  156. curl -fsSL -o /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | bash && \
  157. chmod +x /usr/local/bin/wp \
  158. ;fi
  159. ###########################################################################
  160. # Node / NVM:
  161. ###########################################################################
  162. USER laradock
  163. ENV NVM_DIR /home/laradock/.nvm
  164. RUN mkdir -p $NVM_DIR && \
  165. curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash \
  166. && . $NVM_DIR/nvm.sh
  167. # Wouldn't execute when added to the RUN statement in the above block
  168. # Source NVM when loading bash since ~/.profile isn't loaded on non-login shell
  169. RUN echo "" >> ~/.bashrc && \
  170. echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bashrc && \
  171. echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> ~/.bashrc
  172. # Add NVM binaries to root's .bashrc
  173. USER root
  174. RUN cp -R /home/laradock/.nvm /root/ && \
  175. chown -R root:root /root/.nvm && \
  176. echo "" >> ~/.bashrc && \
  177. echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bashrc && \
  178. echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm' >> ~/.bashrc
  179. ###########################################################################
  180. # Tmux
  181. ###########################################################################
  182. USER root
  183. RUN apt-get update -yqq && apt-get install -y tmux
  184. COPY ./tmux.conf /etc/tmux.conf
  185. ###########################################################################
  186. # Remove DST_Root_CA3
  187. ###########################################################################
  188. USER root
  189. RUN sed -i 's/^mozilla\/DST_Root_CA_X3\.crt/!mozilla\/DST_Root_CA_X3.crt/g' /etc/ca-certificates.conf && update-ca-certificates
  190. ###########################################################################
  191. # Tune opts:
  192. ###########################################################################
  193. ARG PHP_OPT_MAX_EXECUTION_TIME=600
  194. RUN sed -i "s/^max_execution_time = .*/max_execution_time = $PHP_OPT_MAX_EXECUTION_TIME/g" /etc/php/${PHP_VERSION}/cli/php.ini
  195. ARG PHP_OPT_MEMORY_LIMIT=256M
  196. RUN sed -i "s/^memory_limit = .*/memory_limit = $PHP_OPT_MEMORY_LIMIT/g" /etc/php/${PHP_VERSION}/cli/php.ini
  197. ARG PHP_OPT_POST_MAX_SIZE=48M
  198. RUN sed -i "s/^post_max_size = .*/post_max_size = $PHP_OPT_UPLOAD_MAX_FILESIZE/g" /etc/php/${PHP_VERSION}/cli/php.ini
  199. ARG PHP_OPT_UPLOAD_MAX_FILESIZE=16M
  200. RUN sed -i "s/^upload_max_filesize = .*/upload_max_filesize = $PHP_OPT_UPLOAD_MAX_FILESIZE/g" /etc/php/${PHP_VERSION}/cli/php.ini
  201. #
  202. #--------------------------------------------------------------------------
  203. # Final Touch
  204. #--------------------------------------------------------------------------
  205. #
  206. USER root
  207. # Clean up
  208. RUN apt-get clean && \
  209. rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
  210. rm /var/log/lastlog /var/log/faillog
  211. # Set default work directory
  212. WORKDIR /var/www