From e92cfb3718e047f3066082aca9381cede30c7449 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 17 Feb 2023 19:07:38 +0100 Subject: [PATCH 01/31] Proof of concept for single dockerfile --- env/.env.example | 1 + env/Dockerfile | 272 +++++++++++++++++++++++++++-------------- env/docker-compose.yml | 2 + env/etc/php/Dockerfile | 257 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 439 insertions(+), 93 deletions(-) create mode 100644 env/etc/php/Dockerfile diff --git a/env/.env.example b/env/.env.example index 06e77b1..35e130a 100644 --- a/env/.env.example +++ b/env/.env.example @@ -2,3 +2,4 @@ MAGENTO_CLOUD_CLI_TOKEN= COMPOSER_AUTH={"http-basic":{"repo.magento.com":{"username":"","password":""}}} M2D_XDEBUG_IDE_KEY=PHPSTORM M2D_OPENSEARCH_MAX_HEAP_SIZE=512m +M2D_PHP_VERSION=8.1 diff --git a/env/Dockerfile b/env/Dockerfile index a8f1970..0ad3452 100644 --- a/env/Dockerfile +++ b/env/Dockerfile @@ -1,117 +1,90 @@ -#PHP IMAGE -FROM php:7.4-apache-bullseye +## To build image for any PHP version, just set version in the M2D_PHP_VERSION variable. +## It can be in .env file or in your terminal with export M2D_PHP_VERSION=7.4 -#SETTING UP THE SYSTEM +## BASE PHP IMAGE - COMMON FOR ALL PHP VERSIONS ## +ARG M2D_PHP_VERSION='8.1' +FROM php:${M2D_PHP_VERSION}-apache-bullseye AS php_base_ + +# SETTING UP THE SYSTEM: RUN apt-get update \ && apt-get install -y \ - apt-utils \ - wget \ - libwebp-dev \ - libxpm-dev \ - libfreetype6-dev \ - libjpeg62-turbo-dev \ - libmcrypt-dev \ - libpng-dev \ - libxslt-dev \ - libicu-dev \ - mariadb-client \ - pv \ - vim \ - nano \ - bash-completion \ - openssh-server \ - ssl-cert \ - msmtp \ - sudo \ - dnsutils \ - iputils-ping \ - iputils-tracepath \ - host \ - strace \ - telnet \ - unzip \ - gnupg \ - gcc \ - lsof \ - libsodium-dev \ - libzip-dev \ - parallel \ + apt-utils \ + wget \ + libwebp-dev \ + libxpm-dev \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libmcrypt-dev \ + libpng-dev \ + libxslt-dev \ + libicu-dev \ + mariadb-client \ + pv \ + vim \ + nano \ + bash-completion \ + openssh-server \ + ssl-cert \ + msmtp \ + sudo \ + dnsutils \ + iputils-ping \ + iputils-tracepath \ + host \ + strace \ + telnet \ + unzip \ + gnupg \ + gcc \ + lsof \ + libsodium-dev \ + libzip-dev \ + parallel \ + git \ && apt-get update \ && apt-get clean all -#CREATE USER +# CREATE USER: ENV _USER=magento ENV _HOME_DIRECTORY=/home/${_USER} RUN useradd -m ${_USER} && echo "${_USER}:${_USER}" | chpasswd && chsh ${_USER} -s /bin/bash && adduser ${_USER} sudo -#PHP EXTENSIONS +# COMMON PHP EXTENSIONS: RUN docker-php-ext-install -j$(nproc) iconv soap sockets \ - && docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp \ - && docker-php-ext-install -j$(nproc) gd bcmath pdo_mysql xsl intl zip \ - && pecl install libsodium-2.0.22 + && docker-php-ext-install -j$(nproc) bcmath pdo_mysql xsl intl zip -#GIT -RUN apt-get update \ - && apt-get install -y git \ - && apt-get clean all - -#NODEJS +# NODEJS: RUN curl -sL https://deb.nodesource.com/setup_12.x | bash \ && apt-get install -y nodejs -#BLACKFIRE -RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ - && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \ - && mkdir -p /tmp/blackfire \ - && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \ - && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \ - && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \ - && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz \ - && mkdir -p /tmp/blackfire \ - && curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux_static/amd64 | tar zxp -C /tmp/blackfire \ - && mv /tmp/blackfire/blackfire /usr/bin/blackfire \ - && rm -Rf /tmp/blackfire - -#COMPOSER -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer1 --1\ - && apt -qy install $PHPIZE_DEPS && mkdir /${_HOME_DIRECTORY}/.composer - -#COMPOSER 2 (additional) -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer2 --2 +# INSTALL COMPOSER 1 AND COMPOSER 2: +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer1 --1 \ + && apt -qy install $PHPIZE_DEPS && mkdir /${_HOME_DIRECTORY}/.composer \ + && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer2 --2 -#COMPOSER link (1 is default for PHP 7.4) -RUN ln -s /usr/local/bin/composer1 /usr/local/bin/composer +# COMPOSER VERSION SWITCHER: +COPY ./misc/composer-link.sh /usr/local/bin/composer-link.sh -#XDEBUG -ARG M2D_XDEBUG_IDE_KEY=PHPSTORM -ENV M2D_XDEBUG_IDE_KEY=${M2D_XDEBUG_IDE_KEY:-PHPSTORM} -RUN pecl install xdebug-2.9.0 \ - && echo ";zend_extension=xdebug.so" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.max_nesting_level=10000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.idekey=$M2D_XDEBUG_IDE_KEY" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +# XDEBUG enable/disable script COPY ./misc/xdebug-php.sh /usr/local/bin/xdebug-php.sh COPY ./misc/prepare-mtf.sh /usr/local/bin/prepare-mtf.sh -COPY ./misc/composer-link.sh /usr/local/bin/composer-link.sh -#CODESNIFFER -RUN pear install PHP_CodeSniffer \ - && mkdir /usr/local/magento-ecg-code-sniffer \ - && cd /usr/local/magento-ecg-code-sniffer/ && composer require magento-ecg/coding-standard \ - && phpcs --config-set installed_paths /usr/local/magento-ecg-code-sniffer/vendor/magento-ecg/coding-standard +# CODESNIFFER: +# RUN pear install PHP_CodeSniffer \ +# && mkdir /usr/local/magento-ecg-code-sniffer \ +# && cd /usr/local/magento-ecg-code-sniffer/ && composer require magento-ecg/coding-standard \ +# && phpcs --config-set installed_paths /usr/local/magento-ecg-code-sniffer/vendor/magento-ecg/coding-standard -#SENDMAIL +# SENDMAIL: RUN echo "sendmail_path=/usr/bin/msmtp -t" >> /usr/local/etc/php/conf.d/mailcatcher.ini \ - && echo "memory_limit=4G" >> /usr/local/etc/php/conf.d/custom.ini \ + && echo "memory_limit=2G" >> /usr/local/etc/php/conf.d/custom.ini \ && echo "max_input_vars=10000" >> /usr/local/etc/php/conf.d/custom.ini \ && echo "account default" >> /etc/msmtprc \ && echo "host mailcatcher" >> /etc/msmtprc \ && echo "port 1025" >> /etc/msmtprc \ && echo "auto_from on" >> /etc/msmtprc -#SSH +# SSH: COPY ./etc/ssh ${_HOME_DIRECTORY}/.ssh ADD ./etc/ssh/magento2docker.pub ${_HOME_DIRECTORY}/.ssh/authorized_keys RUN chmod -R 700 ${_HOME_DIRECTORY}/.ssh \ @@ -124,7 +97,7 @@ RUN chmod -R 700 /root/.ssh \ && touch /root/.ssh/known_hosts \ && ssh-keygen -F github.com || ssh-keyscan github.com >> /root/.ssh/known_hosts -#APACHE +# APACHE: RUN a2enmod ssl \ && a2ensite default-ssl.conf \ && a2enmod vhost_alias \ @@ -133,21 +106,21 @@ RUN a2enmod ssl \ && chown -R ${_USER}:${_USER} /var/www/html RUN chown -R ${_USER}:${_USER} ${_HOME_DIRECTORY} -#BASH COMPLETION +# BASH COMPLETION: USER magento RUN echo "source /etc/bash_completion" >> ${_HOME_DIRECTORY}/.bashrc -#MAGENTO CLI +# MAGENTO CLI: RUN curl -sS https://accounts.magento.cloud/cli/installer | php USER root -#TUNE ENVIRONMENT +# TUNE ENVIRONMENT: RUN echo "Defaults timestamp_timeout=-1" >> /etc/sudoers -#FLAG TO NOT CACHE ANYTHING FROM THIS POINT, details: https://github.com/docker/docker/issues/1996#issuecomment-185872769 +# FLAG TO NOT CACHE ANYTHING FROM THIS POINT, details: https://github.com/docker/docker/issues/1996#issuecomment-185872769 ARG CACHEBUST=1 -#CUSTOM CONFIGURATIONS +# CUSTOM CONFIGURATIONS: COPY ./etc/git/gitconfig ${_HOME_DIRECTORY}/.gitconfig COPY ./etc/composer/auth.json /${_HOME_DIRECTORY}/.composer/auth.json COPY ./misc/* /usr/local/bin/ @@ -156,7 +129,7 @@ COPY ./etc/apache /etc/apache2/sites-enabled/ COPY ./etc/fixtures /etc/fixtures COPY ./etc/m2install/.m2install.conf* ${_HOME_DIRECTORY}/ -#MAGENTO TOOLS +# MAGENTO TOOLS: RUN curl -o /usr/local/bin/m2install.sh https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install.sh \ && curl -o /etc/bash_completion.d/m2install-bash-completion https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install-bash-completion \ && curl -o /usr/local/bin/n98-magerun2 https://files.magerun.net/n98-magerun2.phar \ @@ -170,5 +143,118 @@ RUN curl -o /usr/local/bin/m2install.sh https://raw.githubusercontent.com/yvoron && if [ -d /usr/local/src/ee-support-tools ]; then ln -s /usr/local/src/ee-support-tools/cloud-teleport/cloud-teleport /usr/local/bin/cloud-teleport; else echo; fi RUN chmod +x /usr/local/bin/* +## END OF BASE IMAGE ## + + +## BASE IMAGE WITH BLACKFIRE "" +FROM php_base_ AS php_base_blackfire + +# BLACKFIRE: +RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ + && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \ + && mkdir -p /tmp/blackfire \ + && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \ + && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \ + && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \ + && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz \ + && mkdir -p /tmp/blackfire \ + && curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux_static/amd64 | tar zxp -C /tmp/blackfire \ + && mv /tmp/blackfire/blackfire /usr/bin/blackfire \ + && rm -Rf /tmp/blackfire +## END OF BASE IMAGE WITH BLACKFIRE ## + + +## IMAGE ADJUSTMENTS FOR PHP 7.x ## +ARG M2D_BLACKFIRE='' +FROM php_base_${M2D_BLACKFIRE} AS php7x + +# COMPOSER 1 LINKED AS DEFAULT: +RUN ln -s /usr/local/bin/composer1 /usr/local/bin/composer + +# XDEBUG: +ARG M2D_XDEBUG_IDE_KEY=PHPSTORM +ENV M2D_XDEBUG_IDE_KEY=${M2D_XDEBUG_IDE_KEY:-PHPSTORM} +RUN pecl install xdebug-2.9.0 \ + && echo ";zend_extension=xdebug.so" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.idekey=$M2D_XDEBUG_IDE_KEY" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.max_nesting_level=10000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo ";xdebug.remote_log = /var/www/html/xdebug.log" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo ";xdebug.remote_log_level = 10" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo ";xdebug.remote_port = 9003" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + +# ADDITIONAL EXTENSIONS +RUN pecl install libsodium-2.0.23 +## END OF IMAGE ADJUSTMENTS FOR PHP 7.x ## + + +## IMAGE ADJUSTEMNTS FOR PHP 8.x +ARG M2D_BLACKFIRE='' +FROM php_base_${M2D_BLACKFIRE} AS php8x + +# PHP EXTENSIONS GD: +RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp \ + && docker-php-ext-install -j$(nproc) gd + +# COMPOSER 2 LINKED AS DEFAULT: +RUN ln -s /usr/local/bin/composer2 /usr/local/bin/composer + +# XDEBUG: +ARG M2D_XDEBUG_IDE_KEY=PHPSTORM +ENV M2D_XDEBUG_IDE_KEY=${M2D_XDEBUG_IDE_KEY:-PHPSTORM} +RUN pecl install xdebug \ + && echo ";zend_extension=xdebug.so" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.idekey=$M2D_XDEBUG_IDE_KEY" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.max_nesting_level=10000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo ";xdebug.log = /var/www/html/xdebug.log" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo ";xdebug.log_level = 10" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo ";xdebug.client_port = 9003" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +## END OF IMAGE ADJUSTMENTS FOR PHP 8.x ## + + +## IMAGE ADJUSTEMNTS FOR PHP 7.3 ## +FROM php7x AS php_7.3 +# PHP EXTENSIONS GD: +RUN docker-php-ext-configure gd --with-gd --with-webp-dir \ + --with-png-dir --with-zlib-dir --with-xpm-dir \ + --with-freetype-dir=/usr/include/freetype2/ --with-jpeg-dir=/usr/include/ \ + && docker-php-ext-install -j$(nproc) gd +## END OF IMAGE ADJUSTMENTS FOR PHP 7.3 ## + + +## IMAGE ADJUSTEMNTS FOR PHP 7.4 ## +FROM php7x AS php_7.4 +# PHP EXTENSIONS GD: +RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp \ + && docker-php-ext-install -j$(nproc) gd +## END OF IMAGE ADJUSTMENTS FOR PHP 7.4 ## + + +## IMAGE ADJUSTEMNTS FOR PHP 8.0 ## +FROM php8x AS php_8.0 + +# ADDITIONAL EXTENSIONS +RUN pecl install libsodium-2.0.23 +## END OF IMAGE ADJUSTMENTS FOR PHP 8.0 ## + + +## IMAGE ADJUSTEMNTS FOR PHP 8.1 ## +FROM php8x AS php_8.1 +## END OF IMAGE ADJUSTMENTS FOR PHP 8.1 ## + + +## IMAGE ADJUSTEMNTS FOR PHP 8.2 ## +FROM php8x AS php_8.2 +## END OF IMAGE ADJUSTMENTS FOR PHP 8.2 ## + + +## TARGET IMAGE ADJUSTEMNTS ## +ARG M2D_PHP_VERSION='8.1' +FROM php_${M2D_PHP_VERSION} AS php_base CMD service ssh start; apache2-foreground diff --git a/env/docker-compose.yml b/env/docker-compose.yml index 111a252..1850644 100644 --- a/env/docker-compose.yml +++ b/env/docker-compose.yml @@ -7,7 +7,9 @@ services: restart: unless-stopped build: context: . + target: php_base args: + - M2D_PHP_VERSION=${M2D_PHP_VERSION:-7.4} - M2D_XDEBUG_IDE_KEY=${M2D_XDEBUG_IDE_KEY:-PHPSTORM} environment: - PHP_IDE_CONFIG=serverName=PHPSTORM diff --git a/env/etc/php/Dockerfile b/env/etc/php/Dockerfile new file mode 100644 index 0000000..236b6f7 --- /dev/null +++ b/env/etc/php/Dockerfile @@ -0,0 +1,257 @@ +## To build image for any PHP version, just set version in the M2D_PHP_VERSION variable. +## It can be in .env file or in your terminal with export M2D_PHP_VERSION=7.4 + +## BASE PHP IMAGE - COMMON FOR ALL PHP VERSIONS ## +ARG M2D_PHP_VERSION='8.1' +FROM php:${M2D_PHP_VERSION}-apache-bullseye AS php_base_ + +# SETTING UP THE SYSTEM: +RUN apt-get update \ + && apt-get install -y \ + apt-utils \ + wget \ + libwebp-dev \ + libxpm-dev \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libmcrypt-dev \ + libpng-dev \ + libxslt-dev \ + libicu-dev \ + mariadb-client \ + pv \ + vim \ + nano \ + bash-completion \ + openssh-server \ + ssl-cert \ + msmtp \ + sudo \ + dnsutils \ + iputils-ping \ + iputils-tracepath \ + host \ + strace \ + telnet \ + unzip \ + gnupg \ + gcc \ + lsof \ + libsodium-dev \ + libzip-dev \ + parallel \ + git \ + && apt-get update \ + && apt-get clean all + +# CREATE USER: +ENV _USER=magento +ENV _HOME_DIRECTORY=/home/${_USER} +RUN useradd -m ${_USER} && echo "${_USER}:${_USER}" | chpasswd && chsh ${_USER} -s /bin/bash && adduser ${_USER} sudo + +# COMMON PHP EXTENSIONS: +RUN docker-php-ext-install -j$(nproc) iconv soap sockets \ + && docker-php-ext-install -j$(nproc) bcmath pdo_mysql xsl intl zip + +# NODEJS: +RUN curl -sL https://deb.nodesource.com/setup_12.x | bash \ + && apt-get install -y nodejs + +# INSTALL COMPOSER 1 AND COMPOSER 2: +RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer1 --1 \ + && apt -qy install $PHPIZE_DEPS && mkdir /${_HOME_DIRECTORY}/.composer \ + && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer2 --2 + +# COMPOSER VERSION SWITCHER: +COPY ./misc/composer-link.sh /usr/local/bin/composer-link.sh + +# XDEBUG enable/disable script +COPY ./misc/xdebug-php.sh /usr/local/bin/xdebug-php.sh +COPY ./misc/prepare-mtf.sh /usr/local/bin/prepare-mtf.sh + +# CODESNIFFER: +# RUN pear install PHP_CodeSniffer \ +# && mkdir /usr/local/magento-ecg-code-sniffer \ +# && cd /usr/local/magento-ecg-code-sniffer/ && composer require magento-ecg/coding-standard \ +# && phpcs --config-set installed_paths /usr/local/magento-ecg-code-sniffer/vendor/magento-ecg/coding-standard + +# SENDMAIL: +RUN echo "sendmail_path=/usr/bin/msmtp -t" >> /usr/local/etc/php/conf.d/mailcatcher.ini \ + && echo "memory_limit=2G" >> /usr/local/etc/php/conf.d/custom.ini \ + && echo "max_input_vars=10000" >> /usr/local/etc/php/conf.d/custom.ini \ + && echo "account default" >> /etc/msmtprc \ + && echo "host mailcatcher" >> /etc/msmtprc \ + && echo "port 1025" >> /etc/msmtprc \ + && echo "auto_from on" >> /etc/msmtprc + +# SSH: +COPY ./etc/ssh ${_HOME_DIRECTORY}/.ssh +ADD ./etc/ssh/magento2docker.pub ${_HOME_DIRECTORY}/.ssh/authorized_keys +RUN chmod -R 700 ${_HOME_DIRECTORY}/.ssh \ + && echo " ServerAliveInterval 30" >> /etc/ssh/ssh_config \ + && echo " TCPKeepAlive yes" >> /etc/ssh/ssh_config +COPY ./etc/ssh /root/.ssh +ADD ./etc/ssh/magento2docker.pub /root/.ssh/authorized_keys +RUN chmod -R 700 /root/.ssh \ + && echo "Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc" >> /etc/ssh/sshd_config \ + && touch /root/.ssh/known_hosts \ + && ssh-keygen -F github.com || ssh-keyscan github.com >> /root/.ssh/known_hosts + +# APACHE: +RUN a2enmod ssl \ + && a2ensite default-ssl.conf \ + && a2enmod vhost_alias \ + && a2enmod proxy \ + && a2enmod rewrite \ + && chown -R ${_USER}:${_USER} /var/www/html +RUN chown -R ${_USER}:${_USER} ${_HOME_DIRECTORY} + +# BASH COMPLETION: +USER magento +RUN echo "source /etc/bash_completion" >> ${_HOME_DIRECTORY}/.bashrc + +# MAGENTO CLI: +RUN curl -sS https://accounts.magento.cloud/cli/installer | php +USER root + +# TUNE ENVIRONMENT: +RUN echo "Defaults timestamp_timeout=-1" >> /etc/sudoers + +# FLAG TO NOT CACHE ANYTHING FROM THIS POINT, details: https://github.com/docker/docker/issues/1996#issuecomment-185872769 +ARG CACHEBUST=1 + +# CUSTOM CONFIGURATIONS: +COPY ./etc/git/gitconfig ${_HOME_DIRECTORY}/.gitconfig +COPY ./etc/composer/auth.json /${_HOME_DIRECTORY}/.composer/auth.json +COPY ./misc/* /usr/local/bin/ +COPY ./etc/apache/envvars /etc/apache2/envvars +COPY ./etc/apache /etc/apache2/sites-enabled/ +COPY ./etc/fixtures /etc/fixtures +COPY ./etc/m2install/.m2install.conf* ${_HOME_DIRECTORY}/ + +# MAGENTO TOOLS: +RUN curl -o /usr/local/bin/m2install.sh https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install.sh \ + && curl -o /etc/bash_completion.d/m2install-bash-completion https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install-bash-completion \ + && curl -o /usr/local/bin/n98-magerun2 https://files.magerun.net/n98-magerun2.phar \ + && curl -o /etc/bash_completion.d/n98-magerun2.phar.bash https://raw.githubusercontent.com/netz98/n98-magerun2/master/res/autocompletion/bash/n98-magerun2.phar.bash \ + && curl -o /usr/local/bin/m2-convert-for-composer https://raw.githubusercontent.com/isitnikov/m2-convert-patch-for-composer-install/master/convert-for-composer.php \ + && curl -o /etc/bash_completion.d/magento2-bash-completion https://raw.githubusercontent.com/yvoronoy/magento2-bash-completion/master/magento2-bash-completion-enterprise \ + && curl -L -o /tmp/teleport.tar.gz https://github.com/gravitational/teleport/releases/download/v1.3.2/teleport-v1.3.2-linux-amd64-bin.tar.gz \ + && tar -xf /tmp/teleport.tar.gz -C /tmp/ \ + && make -C /tmp/teleport/ \ + && git ls-remote git@github.com:magento-sparta/ee-support-tools.git 2>&1 | if grep -q HEAD; then git clone git@github.com:magento-sparta/ee-support-tools.git /usr/local/src/ee-support-tools; else echo; fi \ + && if [ -d /usr/local/src/ee-support-tools ]; then ln -s /usr/local/src/ee-support-tools/cloud-teleport/cloud-teleport /usr/local/bin/cloud-teleport; else echo; fi + +RUN chmod +x /usr/local/bin/* +## END OF BASE IMAGE ## + + +## BASE IMAGE WITH BLACKFIRE "" +FROM php_base_ AS php_base_blackfire + +# BLACKFIRE: +RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ + && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \ + && mkdir -p /tmp/blackfire \ + && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \ + && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \ + && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \ + && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz \ + && mkdir -p /tmp/blackfire \ + && curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux_static/amd64 | tar zxp -C /tmp/blackfire \ + && mv /tmp/blackfire/blackfire /usr/bin/blackfire \ + && rm -Rf /tmp/blackfire +## END OF BASE IMAGE WITH BLACKFIRE ## + + +## IMAGE ADJUSTMENTS FOR PHP 7.x ## +ARG M2D_BLACKFIRE='' +FROM php_base_${M2D_BLACKFIRE} AS php7x + +# XDEBUG: +ARG M2D_XDEBUG_IDE_KEY=PHPSTORM +ENV M2D_XDEBUG_IDE_KEY=${M2D_XDEBUG_IDE_KEY:-PHPSTORM} +RUN pecl install xdebug-2.9.0 \ + && echo ";zend_extension=xdebug.so" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.idekey=$M2D_XDEBUG_IDE_KEY" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.max_nesting_level=10000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo ";xdebug.remote_log = /var/www/html/xdebug.log" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo ";xdebug.remote_log_level = 10" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo ";xdebug.remote_port = 9003" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini + +# ADDITIONAL EXTENSIONS +RUN pecl install libsodium-2.0.23 +## END OF IMAGE ADJUSTMENTS FOR PHP 7.x ## + + +## IMAGE ADJUSTEMNTS FOR PHP 8.x +ARG M2D_BLACKFIRE='' +FROM php_base_${M2D_BLACKFIRE} AS php8x + +# PHP EXTENSIONS GD: +RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp \ + && docker-php-ext-install -j$(nproc) gd + +# COMPOSER 2 LINKED AS DEFAULT: +RUN ln -s /usr/local/bin/composer2 /usr/local/bin/composer + +# XDEBUG: +ARG M2D_XDEBUG_IDE_KEY=PHPSTORM +ENV M2D_XDEBUG_IDE_KEY=${M2D_XDEBUG_IDE_KEY:-PHPSTORM} +RUN pecl install xdebug \ + && echo ";zend_extension=xdebug.so" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.idekey=$M2D_XDEBUG_IDE_KEY" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo "xdebug.max_nesting_level=10000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo ";xdebug.log = /var/www/html/xdebug.log" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo ";xdebug.log_level = 10" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ + && echo ";xdebug.client_port = 9003" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini +## END OF IMAGE ADJUSTMENTS FOR PHP 8.x ## + + +## IMAGE ADJUSTEMNTS FOR PHP 7.3 ## +FROM php7x AS php_7.3 +# PHP EXTENSIONS GD: +RUN docker-php-ext-configure gd --with-gd --with-webp-dir \ + --with-png-dir --with-zlib-dir --with-xpm-dir \ + --with-freetype-dir=/usr/include/freetype2/ --with-jpeg-dir=/usr/include/ \ + && docker-php-ext-install -j$(nproc) gd +## END OF IMAGE ADJUSTMENTS FOR PHP 7.3 ## + + +## IMAGE ADJUSTEMNTS FOR PHP 7.4 ## +FROM php7x AS php_7.4 +# PHP EXTENSIONS GD: +RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp \ + && docker-php-ext-install -j$(nproc) gd +## END OF IMAGE ADJUSTMENTS FOR PHP 7.4 ## + + +## IMAGE ADJUSTEMNTS FOR PHP 8.0 ## +FROM php8x AS php_8.0 + +# ADDITIONAL EXTENSIONS +RUN pecl install libsodium-2.0.23 +## END OF IMAGE ADJUSTMENTS FOR PHP 8.0 ## + + +## IMAGE ADJUSTEMNTS FOR PHP 8.1 ## +FROM php8x AS php_8.1 +## END OF IMAGE ADJUSTMENTS FOR PHP 8.1 ## + + +## IMAGE ADJUSTEMNTS FOR PHP 8.2 ## +FROM php8x AS php_8.2 +## END OF IMAGE ADJUSTMENTS FOR PHP 8.2 ## + + +## TARGET IMAGE ADJUSTEMNTS ## +ARG M2D_PHP_VERSION='8.1' +FROM php_${M2D_PHP_VERSION} AS php_base + +CMD service ssh start; apache2-foreground From a8b6f569f4bd75496b7be9bee758685b010734ab Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 17 Mar 2023 14:49:17 +0100 Subject: [PATCH 02/31] Added base for dummy containers --- tools/dummy/README.md | 55 ++++++++++++++++++++++++++++++++++++++++++ tools/dummy/dummy | Bin 0 -> 16834 bytes tools/dummy/dummy.c | 3 +++ 3 files changed, 58 insertions(+) create mode 100644 tools/dummy/README.md create mode 100755 tools/dummy/dummy create mode 100644 tools/dummy/dummy.c diff --git a/tools/dummy/README.md b/tools/dummy/README.md new file mode 100644 index 0000000..2435bc8 --- /dev/null +++ b/tools/dummy/README.md @@ -0,0 +1,55 @@ +## Introduction +Dummy - is a lightweight container that executes dummy binary that does nothing. +You can use it whenever you need a dummy container. + +## How to use it? +The idea is to create containers when necessary. But it is hard in Docker as there are no if statements. So the trick is to use environment variables and a dummy container. +Let's assume you need Mailcatcher. This is what your setup can look like: +1. Add Mailcatcher to docker-compose.yaml file: +```yaml +mailcatcher: + build: + context: . + dockerfile: tools/mailcatcher/Dockerfile + target: m2d_mailcatcher + args: + - M2D_ENABLE_MAILCATCHER=${M2D_ENABLE_MAILCATCHER:-no} + container_name: magento2mailcatcher + ports: + - "${M2D_PORT_FOR_MAILCATCHER:-1080}:1080" +``` +2. Add Dockerfile for Mailcatcher: +```Dockerfile +## set the default value for the argument if not defined +ARG M2D_ENABLE_MAILCATCHER='no' + +## prepare a dummy container for the "no" option +FROM scratch as m2d_mailcatcher_no +COPY tools/dummy/dummy ./ +CMD ["/dummy"] + +## prepare the actual Mailcatcher container for the "yes" option +FROM schickling/mailcatcher AS m2d_mailcatcher_yes + +## build target container from mailcatcher_yes or mailcatcher_no based on value from M2D_ENABLE_MAILCATCHER argument +FROM m2d_mailcatcher_${M2D_ENABLE_MAILCATCHER} AS m2d_mailcatcher +``` +3. Set expected value for argument: +- in .env file: +``` +M2D_ENABLE_MAILCATCHER=yes +``` +- or in the terminal: +```bash +export M2D_ENABLE_MAILCATCHER=yes +``` +4. Spin up the expected container: +```bash +docker-composer up -d --build +``` + +## Need more? +If you need a dummy container that is doing something (e.g., displaying hello world), you can modify the source code and recompile it with the following: +```bash +gcc -o tools/dummy/dummy tools/dummy/dummy.c +``` \ No newline at end of file diff --git a/tools/dummy/dummy b/tools/dummy/dummy new file mode 100755 index 0000000000000000000000000000000000000000..b3c3b39d776318a5d5d88b9ead7709b4fd7c5d9e GIT binary patch literal 16834 zcmeI3OGs2<6vw}LMUiI75S9f)VP@u|vXEMID+d)NMJ0wF^P$d|lg=1ALt27DOl3jT zLfQmLOceAIDbOeo2_*``=z&2Q(PCP(t0))RIp4jLGYST+{|C-JuQ}hG?|1L^yqx+r zog{=wkeErAlSau23kP{ZtRgKTm9lbAvGbs_s)DnLqM8#^^CCVcN-AZI(^ZpLR{dIH zP8hL`(yTlii7Qv(1PLDbA;u zXGkMGPBHtJ$U4X_C9Ncl7p}AZk1V4m2Pu6cA}`d|n%C^B%ky+Jdnjf}C*?VI-6|7L zzi;`~XKOjXXf$$cE9D%d`kj)=Nmjmva>7(#*+fR&k7JUJbU!|a-&efw|MLC0rr#lx zJ_pn6EHqDbM_bVA&)u6#bNTA@?hR!4{6hOO_$$D7O*F567! zgU*xT_fIaA^lZNQue#ga`?&wv>O+&abLtOdzjhz}lm{@McCapQBxV f-)lM|JvZ#<9$gzbTXMMk! Date: Fri, 17 Mar 2023 14:55:44 +0100 Subject: [PATCH 03/31] Move docker-compose.yaml one level up to flatten the project. --- env/docker-compose.yml => docker-compose.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename env/docker-compose.yml => docker-compose.yml (100%) diff --git a/env/docker-compose.yml b/docker-compose.yml similarity index 100% rename from env/docker-compose.yml rename to docker-compose.yml From a1a38f7f7af3493fb3bce9715405a7f2f5e21fb7 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 17 Mar 2023 15:13:06 +0100 Subject: [PATCH 04/31] Refactor of Mailcatcher container --- .env.example | 9 +++++++++ docker-compose.yml | 10 ++++++++++ env/additional/mailcatcher/docker-compose.yml | 12 ------------ tools/mailcatcher/Dockerfile | 13 +++++++++++++ 4 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 .env.example delete mode 100644 env/additional/mailcatcher/docker-compose.yml create mode 100644 tools/mailcatcher/Dockerfile diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..8be0b35 --- /dev/null +++ b/.env.example @@ -0,0 +1,9 @@ +########################################## +## SERVICES/TOOLS CONFIGURATION SECTION ## +########################################## + +## MAILCATCHER +# Set to 'yes' to enable Mailcatcher or to 'no' to disable it: +M2D_ENABLE_MAILCATCHER='no' +# Set the port number on which the Mailcatcher web interface will be hosted: +M2D_PORT_FOR_MAILCATCHER=1080 diff --git a/docker-compose.yml b/docker-compose.yml index 1850644..b1ecde1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -48,6 +48,16 @@ services: environment: - BLACKFIRE_SERVER_ID - BLACKFIRE_SERVER_TOKEN + mailcatcher: + build: + context: . + dockerfile: tools/mailcatcher/Dockerfile + target: m2d_mailcatcher + args: + - M2D_ENABLE_MAILCATCHER=${M2D_ENABLE_MAILCATCHER:-no} + container_name: magento2mailcatcher + ports: + - "${M2D_PORT_FOR_MAILCATCHER:-1080}:1080" volumes: home-volume: root-volume: diff --git a/env/additional/mailcatcher/docker-compose.yml b/env/additional/mailcatcher/docker-compose.yml deleted file mode 100644 index 692148d..0000000 --- a/env/additional/mailcatcher/docker-compose.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: '2' - -services: - mailcatcher: - image: schickling/mailcatcher - ports: - - "1080:1080" -networks: - default: - external: - name: env_default - diff --git a/tools/mailcatcher/Dockerfile b/tools/mailcatcher/Dockerfile new file mode 100644 index 0000000..14933eb --- /dev/null +++ b/tools/mailcatcher/Dockerfile @@ -0,0 +1,13 @@ +## set the default value for the argument if not defined +ARG M2D_ENABLE_MAILCATCHER='no' + +## prepare a dummy container for the "no" option +FROM scratch as m2d_mailcatcher_no +COPY tools/dummy/dummy ./ +CMD ["/dummy"] + +## prepare the actual Mailcatcher container for the "yes" option +FROM schickling/mailcatcher AS m2d_mailcatcher_yes + +## build target container from mailcatcher_yes or mailcatcher_no based on value from M2D_ENABLE_MAILCATCHER argument +FROM m2d_mailcatcher_${M2D_ENABLE_MAILCATCHER} AS m2d_mailcatcher From a8e28c352b481ab76178b2683f90f5823bdcb5ae Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 17 Mar 2023 15:48:26 +0100 Subject: [PATCH 05/31] Refactor of RabbitMQ container --- .env.example | 12 ++++++++++++ docker-compose.yml | 16 ++++++++++++++++ env/additional/rabbitmq/docker-compose.yml | 13 ------------- services/message-brokers/Dockerfile | 11 +++++++++++ 4 files changed, 39 insertions(+), 13 deletions(-) delete mode 100644 env/additional/rabbitmq/docker-compose.yml create mode 100644 services/message-brokers/Dockerfile diff --git a/.env.example b/.env.example index 8be0b35..6445249 100644 --- a/.env.example +++ b/.env.example @@ -7,3 +7,15 @@ M2D_ENABLE_MAILCATCHER='no' # Set the port number on which the Mailcatcher web interface will be hosted: M2D_PORT_FOR_MAILCATCHER=1080 + +## MESSAGE-BROKER +# Set to 'yes' to enable Message Broker or to 'no' to disable it: +M2D_ENABLE_MESSAGE_BROKER='no' +# Set which message broker you want to use: +# - 'rabbitmq' for RabbitMQ [https://www.rabbitmq.com/] +M2D_MESSAGE_BROKER_VENDOR='rabbitmq' +# Set expected version of the message broker: +# - '3.8-management' +M2D_MESSAGE_BROKER_VERSION:'3.8-management' +# Set the port number used by a broker: +M2D_PORT_FOR_MESSAGE_BROKER='15672' diff --git a/docker-compose.yml b/docker-compose.yml index b1ecde1..3ff9619 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -48,6 +48,21 @@ services: environment: - BLACKFIRE_SERVER_ID - BLACKFIRE_SERVER_TOKEN + + message_broker: + build: + context: . + dockerfile: services/message-brokers/Dockerfile + target: m2d_message_broker + args: + - M2D_ENABLE_MESSAGE_BROKER=${M2D_ENABLE_MESSAGE_BROKER:-no} + - M2D_MESSAGE_BROKER_VENDOR=${M2D_MESSAGE_BROKER_VENDOR:-rabbitmq} + - M2D_MESSAGE_BROKER_VERSION=${M2D_MESSAGE_BROKER_VERSION:-'3.8-management'} + container_name: magento2messagebroker + restart: unless-stopped + ports: + - "${M2D_PORT_FOR_MESSAGE_BROKER:-15672}:15672" + mailcatcher: build: context: . @@ -58,6 +73,7 @@ services: container_name: magento2mailcatcher ports: - "${M2D_PORT_FOR_MAILCATCHER:-1080}:1080" + volumes: home-volume: root-volume: diff --git a/env/additional/rabbitmq/docker-compose.yml b/env/additional/rabbitmq/docker-compose.yml deleted file mode 100644 index 9b5e5ec..0000000 --- a/env/additional/rabbitmq/docker-compose.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: '2' - -services: - rabbitmq: - container_name: magento2rabbitmq - image: rabbitmq:3.8-management - restart: unless-stopped - ports: - - "15672:15672" -networks: - default: - external: - name: env_default diff --git a/services/message-brokers/Dockerfile b/services/message-brokers/Dockerfile new file mode 100644 index 0000000..b0d832f --- /dev/null +++ b/services/message-brokers/Dockerfile @@ -0,0 +1,11 @@ +ARG M2D_ENABLE_MESSAGE_BROKER='no' +ARG M2D_MESSAGE_BROKER_VENDOR='rabbitmq' +ARG M2D_MESSAGE_BROKER_VERSION='3.8-management' + +FROM scratch as m2d_message_broker_no +COPY tools/dummy/dummy ./ +CMD ["/dummy"] + +FROM ${M2D_MESSAGE_BROKER_VENDOR}:${M2D_MESSAGE_BROKER_VERSION} AS m2d_message_broker_yes + +FROM m2d_message_broker_${M2D_ENABLE_MESSAGE_BROKER} AS m2d_message_broker From b187688ed2cdf5d6bcd1b7b64513a99b78534f8a Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 17 Mar 2023 15:58:08 +0100 Subject: [PATCH 06/31] Refactor of Blackfire container --- .env.example | 4 ++++ docker-compose.yml | 16 +++++++++++----- tools/blackfire/Dockerfile | 9 +++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 tools/blackfire/Dockerfile diff --git a/.env.example b/.env.example index 6445249..e918206 100644 --- a/.env.example +++ b/.env.example @@ -8,6 +8,10 @@ M2D_ENABLE_MAILCATCHER='no' # Set the port number on which the Mailcatcher web interface will be hosted: M2D_PORT_FOR_MAILCATCHER=1080 +## BLACKFIRE +# Set to 'yes' to enable Blackfire or to 'no' to disable it: +M2D_ENABLE_BLACKFIRE='no' + ## MESSAGE-BROKER # Set to 'yes' to enable Message Broker or to 'no' to disable it: M2D_ENABLE_MESSAGE_BROKER='no' diff --git a/docker-compose.yml b/docker-compose.yml index 3ff9619..3ac14b2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -43,11 +43,6 @@ services: volumes: - "./etc/mysql:/etc/mysql/conf.d" - db-volume:/var/lib/mysql - blackfire: - image: blackfire/blackfire - environment: - - BLACKFIRE_SERVER_ID - - BLACKFIRE_SERVER_TOKEN message_broker: build: @@ -74,6 +69,17 @@ services: ports: - "${M2D_PORT_FOR_MAILCATCHER:-1080}:1080" + blackfire: + build: + context: . + dockerfile: tools/blackfire/Dockerfile + target: m2d_blackfire + args: + M2D_ENABLE_BLACKFIRE=${M2D_ENABLE_BLACKFIRE:-no} + environment: + - BLACKFIRE_SERVER_ID + - BLACKFIRE_SERVER_TOKEN + volumes: home-volume: root-volume: diff --git a/tools/blackfire/Dockerfile b/tools/blackfire/Dockerfile new file mode 100644 index 0000000..9a0ceb8 --- /dev/null +++ b/tools/blackfire/Dockerfile @@ -0,0 +1,9 @@ +ARG M2D_ENABLE_BLACKFIRE='no' + +FROM scratch as m2d_blackfire_no +COPY tools/dummy/dummy ./ +CMD ["/dummy"] + +FROM blackfire/blackfire AS m2d_blackfire_yes + +FROM m2d_blackfire_${M2D_ENABLE_BLACKFIRE} AS m2d_blackfire From 12abf877ff21f70c4d109ec3ddf90ef341ae49bf Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 17 Mar 2023 16:12:20 +0100 Subject: [PATCH 07/31] Refactor of Varnish container --- .env.example | 11 +++++++++++ docker-compose.yml | 14 ++++++++++++++ env/additional/varnish/docker-compose.yml | 13 ------------- services/web-cache/Dockerfile | 11 +++++++++++ 4 files changed, 36 insertions(+), 13 deletions(-) delete mode 100644 env/additional/varnish/docker-compose.yml create mode 100644 services/web-cache/Dockerfile diff --git a/.env.example b/.env.example index e918206..9d02fc9 100644 --- a/.env.example +++ b/.env.example @@ -23,3 +23,14 @@ M2D_MESSAGE_BROKER_VENDOR='rabbitmq' M2D_MESSAGE_BROKER_VERSION:'3.8-management' # Set the port number used by a broker: M2D_PORT_FOR_MESSAGE_BROKER='15672' + +## WEB CACHE +# Set to 'yes' to enable Web Cache or to 'no' to disable it +M2D_ENABLE_WEB_CACHE='no' +# Set witch web cache solution to use: +# - 'varnish' for Varnish HTTP Cache [https://varnish-cache.org/] +M2D_WEB_CACHE_VENDOR='varnish' +# Set expected version of the web cache: +M2D_WEB_CACHE_VERSION='6.5' +# Set the port number used by web cache: +M2D_PORT_FOR_WEB_CACHE='8080' diff --git a/docker-compose.yml b/docker-compose.yml index 3ac14b2..bf716f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -58,6 +58,20 @@ services: ports: - "${M2D_PORT_FOR_MESSAGE_BROKER:-15672}:15672" + web_cache: + build: + context: . + dockerfile: services/web-cache/Dokerfile + target: m2d_web_cache + args: + - M2D_ENABLE_WEB_CACHE:${M2D_ENABLE_WEB_CACHE:-no} + - M2D_WEB_CACHE_VENDOR:${M2D_WEB_CACHE_VENDOR:-varnish} + - M2D_WEB_CACHE_VERSION:${M2D_WEB_CACHE_VERSION:-'6.5'} + container_name: magento2webcache + restart: unless-stopped + ports: + - "${M2D_PORT_FOR_WEB_CACHE:-8080}:8080" + mailcatcher: build: context: . diff --git a/env/additional/varnish/docker-compose.yml b/env/additional/varnish/docker-compose.yml deleted file mode 100644 index ae85d77..0000000 --- a/env/additional/varnish/docker-compose.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: '2' - -services: - varnish: - container_name: magento2varnish - image: varnish:6.5 - ports: - - "8080:8080" -networks: - default: - external: - name: env_default - diff --git a/services/web-cache/Dockerfile b/services/web-cache/Dockerfile new file mode 100644 index 0000000..c3a9775 --- /dev/null +++ b/services/web-cache/Dockerfile @@ -0,0 +1,11 @@ +ARG M2D_ENABLE_WEB_CACHE='no' +ARG M2D_WEB_CACHE_VENDOR='varnish' +ARG M2D_WEB_CACHE_VERSION='6.5' + +FROM scratch as m2d_web_cache_no +COPY tools/dummy/dummy ./ +CMD ["/dummy"] + +FROM ${M2D_WEB_CACHE_VENDOR}:${M2D_WEB_CACHE_VERSION} AS m2d_web_cache_yes + +FROM m2d_web_cache_${M2D_ENABLE_WEB_CACHE} AS m2d_web_cache From 7662330306bbe2165720f9fa6aa761990cda5410 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 17 Mar 2023 16:24:36 +0100 Subject: [PATCH 08/31] Refactor of Redis container --- .env.example | 9 +++++++++ docker-compose.yml | 12 ++++++++++++ env/additional/redis/docker-compose.yml | 11 ----------- services/db-cache/Dockerfile | 11 +++++++++++ 4 files changed, 32 insertions(+), 11 deletions(-) delete mode 100644 env/additional/redis/docker-compose.yml create mode 100644 services/db-cache/Dockerfile diff --git a/.env.example b/.env.example index 9d02fc9..d24edd8 100644 --- a/.env.example +++ b/.env.example @@ -34,3 +34,12 @@ M2D_WEB_CACHE_VENDOR='varnish' M2D_WEB_CACHE_VERSION='6.5' # Set the port number used by web cache: M2D_PORT_FOR_WEB_CACHE='8080' + +## DB CACHE +# Set to 'yes' to enable DB Cache or to 'no' to disable it +M2D_ENABLE_DB_CACHE='no' +# Set witch db cache solution to use: +# - 'redis' for Redis [https://redis.io/] +M2D_DB_CACHE_VENDOR='redis' +# Set expected version of the db cache: +M2D_DB_CACHE_VERSION='6.0' diff --git a/docker-compose.yml b/docker-compose.yml index bf716f2..5684e4a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -72,6 +72,18 @@ services: ports: - "${M2D_PORT_FOR_WEB_CACHE:-8080}:8080" + db_cache: + build: + context: . + dockerfile: services/db-cache/Dokerfile + target: m2d_db_cache + args: + - M2D_ENABLE_DB_CACHE:${M2D_ENABLE_DB_CACHE:-no} + - M2D_DB_CACHE_VENDOR:${M2D_DB_CACHE_VENDOR:-redis} + - M2D_DB_CACHE_VERSION:${M2D_DB_CACHE_VERSION:-'6.0'} + container_name: magento2dbcache + restart: unless-stopped + mailcatcher: build: context: . diff --git a/env/additional/redis/docker-compose.yml b/env/additional/redis/docker-compose.yml deleted file mode 100644 index 641084a..0000000 --- a/env/additional/redis/docker-compose.yml +++ /dev/null @@ -1,11 +0,0 @@ -version: '2' - -services: - redis: - container_name: magento2redis - image: redis:6.0 -networks: - default: - external: - name: env_default - diff --git a/services/db-cache/Dockerfile b/services/db-cache/Dockerfile new file mode 100644 index 0000000..4b994e5 --- /dev/null +++ b/services/db-cache/Dockerfile @@ -0,0 +1,11 @@ +ARG M2D_ENABLE_DB_CACHE='no' +ARG M2D_DB_CACHE_VENDOR='redis' +ARG M2D_DB_CACHE_VERSION='6.0' + +FROM scratch as m2d_db_cache_no +COPY tools/dummy/dummy ./ +CMD ["/dummy"] + +FROM ${M2D_DB_CACHE_VENDOR}:${M2D_DB_CACHE_VERSION} AS m2d_db_cache_yes + +FROM m2d_db_cache_${M2D_ENABLE_DB_CACHE} AS m2d_db_cache From 2e67e8e45a482db10eb87774bd7266b633b69b68 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 17 Mar 2023 17:15:01 +0100 Subject: [PATCH 09/31] Refactor of Selenium container --- .env.example | 26 +++++++++++++++++++++- docker-compose.yml | 17 ++++++++++++++ env/additional/selenium/docker-compose.yml | 16 ------------- tools/selenium/Dockerfile | 19 ++++++++++++++++ 4 files changed, 61 insertions(+), 17 deletions(-) delete mode 100644 env/additional/selenium/docker-compose.yml create mode 100644 tools/selenium/Dockerfile diff --git a/.env.example b/.env.example index d24edd8..092c4be 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,14 @@ ########################################## -## SERVICES/TOOLS CONFIGURATION SECTION ## +## MAIN SETTINGS ## +########################################## + +# Set your CPU type: +# - 'm1' for Apple M1 CPUs +# - 'intel' for Intel or AMD based CPUs +M2D_CPU_TYPE='m1' + +########################################## +## TOOLS CONFIGURATION SECTION ## ########################################## ## MAILCATCHER @@ -12,6 +21,21 @@ M2D_PORT_FOR_MAILCATCHER=1080 # Set to 'yes' to enable Blackfire or to 'no' to disable it: M2D_ENABLE_BLACKFIRE='no' +## SELENIUUM +# Set to 'yes' to enable Selenium or to 'no' to disable it: +M2D_ENABLE_SELENIUM='no' +# Set Selenium version you want to use: +M2D_SELENIUM_VERSION='3.14.0' +# Set port number used by Seleniub HUB: +M2D_PORT_FOR_SELENIUM_HUB='4444' +# Set the port number used by VNC in Selenium container: +M2D_PORT_FOR_SELENIUM_VNC='5900' + + +########################################## +## SERVICES CONFIGURATION SECTION ## +########################################## + ## MESSAGE-BROKER # Set to 'yes' to enable Message Broker or to 'no' to disable it: M2D_ENABLE_MESSAGE_BROKER='no' diff --git a/docker-compose.yml b/docker-compose.yml index 5684e4a..65fcc1d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -106,6 +106,23 @@ services: - BLACKFIRE_SERVER_ID - BLACKFIRE_SERVER_TOKEN + selenium: + build: + context: . + dockerfile: tools/selenium/Dockerfile + target: m2d_selenium + args: + - M2D_CPU_TYPE:${M2D_CPU_TYPE:-m1} + - M2D_ENABLE_SELENIUM:${M2D_ENABLE_SELENIUM:-no} + - M2D_SELENIUM_VERSION:${M2D_SELENIUM_VERSION:-'3.14.0'} + container_name: selenium + volumes: + - /dev/shm:/dev/shm + ports: + - "${M2D_PORT_FOR_SELENIUM_HUB:-4444}:4444" + - "${M2D_PORT_FOR_SELENIUM_VNC:-5900}:5900" + shm_size: '2gb' + volumes: home-volume: root-volume: diff --git a/env/additional/selenium/docker-compose.yml b/env/additional/selenium/docker-compose.yml deleted file mode 100644 index 773ed7a..0000000 --- a/env/additional/selenium/docker-compose.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: '2' - -services: - selenium: - image: selenium/standalone-chrome-debug:3.14.0 - container_name: selenium - volumes: - - /dev/shm:/dev/shm - ports: - - "4444:4444" - - "5900:5900" - shm_size: '2gb' -networks: - default: - external: - name: env_default diff --git a/tools/selenium/Dockerfile b/tools/selenium/Dockerfile new file mode 100644 index 0000000..38c36cb --- /dev/null +++ b/tools/selenium/Dockerfile @@ -0,0 +1,19 @@ +ARG M2D_ENABLE_SELENIUM='no' +ARG M2D_SELENIUM_VERSION='3.14.0' +ARG M2D_CPU_TYPE='m1' + +FROM scratch as m2d_selenium_no +COPY tools/dummy/dummy ./ +CMD ["/dummy"] + +FROM m2d_selenium_no AS m2d_selenium_no_m1 +FROM m2d_selenium_no AS m2d_selenium_no_intel + +FROM selenium/standalone-chrome-debug:${M2D_SELENIUM_VERSION} AS m2d_selenium_yes_intel + +# there are no official versions compiled for Apple M1; +# there is https://hub.docker.com/u/seleniarm but they not offer standalone-chrome-debug +# the below will pick an image for the amd64 platform, and it will be executed in emulation mode so that it will be SLOW! +FROM --platform=linux/amd64 selenium/standalone-chrome-debug:${M2D_SELENIUM_VERSION} AS m2d_selenium_yes_m1 + +FROM m2d_selenium_${M2D_ENABLE_SELENIUM}_${M2D_CPU_TYPE} AS m2d_selenium From 775da4cb8b9b83e2bc7eed954b49935d84245c49 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 17 Mar 2023 21:02:12 +0100 Subject: [PATCH 10/31] Refactor of ElasticSearch and Opensearch containers --- .env.example | 14 +++++++ docker-compose.yml | 16 ++++++++ env/additional/elasticsearch6/Dockerfile | 3 -- .../elasticsearch6/config/elasticsearch.yml | 8 ---- .../elasticsearch6/docker-compose.yml | 14 ------- env/additional/elasticsearch7/Dockerfile | 3 -- .../elasticsearch7/docker-compose.yml | 14 ------- env/additional/opensearch/docker-compose.yaml | 19 --------- services/search-engines/Dockerfile | 40 +++++++++++++++++++ .../search-engines/etc}/elasticsearch.yml | 2 +- 10 files changed, 71 insertions(+), 62 deletions(-) delete mode 100644 env/additional/elasticsearch6/Dockerfile delete mode 100644 env/additional/elasticsearch6/config/elasticsearch.yml delete mode 100644 env/additional/elasticsearch6/docker-compose.yml delete mode 100644 env/additional/elasticsearch7/Dockerfile delete mode 100644 env/additional/elasticsearch7/docker-compose.yml delete mode 100644 env/additional/opensearch/docker-compose.yaml create mode 100644 services/search-engines/Dockerfile rename {env/additional/elasticsearch7/config => services/search-engines/etc}/elasticsearch.yml (92%) diff --git a/.env.example b/.env.example index 092c4be..19c1c1b 100644 --- a/.env.example +++ b/.env.example @@ -36,6 +36,20 @@ M2D_PORT_FOR_SELENIUM_VNC='5900' ## SERVICES CONFIGURATION SECTION ## ########################################## +## SEARCH ENGINE +# Set to 'yes' to enable search engine or to 'no' to disable it: +M2D_ENABLE_SEARCH_ENGINE='yes' +# Set which search engine you want to use: +# - 'elasticsearch' for ElasticSearch [https://www.elastic.co/] +# - 'opensearch' for Opensearch [https://opensearch.org/] +M2D_SEARCH_ENGINE_VENDOR='elasticsearch' +# Set expected version of the search engine: +# - ElasticSearch versions: 6, 7, 7.6, 7.7, 7.9, 7.10, 7.16, 7.17, 8, 8.4 +# - OpenSearch versions: 1, 1.2, 2, 2.5 +M2D_SEARCH_ENGINE_VERSION='7' +# Set the port number used by search engine: +M2D_PORT_FOR_SEARCH_ENGINE='9200' + ## MESSAGE-BROKER # Set to 'yes' to enable Message Broker or to 'no' to disable it: M2D_ENABLE_MESSAGE_BROKER='no' diff --git a/docker-compose.yml b/docker-compose.yml index 65fcc1d..e189b1b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -44,6 +44,22 @@ services: - "./etc/mysql:/etc/mysql/conf.d" - db-volume:/var/lib/mysql + search_engine: + build: + context: . + dockerfile: services/search-engines/Dockerfile + target: m2d_search_engine + args: + - M2D_ENABLE_SEARCH_ENGINE=${M2D_ENABLE_SEARCH_ENGINE:-yes} + - M2D_SEARCH_ENGINE_VENDOR=${M2D_SEARCH_ENGINE_VENDOR:-elasticsearch} + - M2D_SEARCH_ENGINE_VERSION=${M2D_SEARCH_ENGINE_VERSION:7} + container_name: magento2searchengine + environment: + - "ES_JAVA_OPTS=-Xms128m -Xmx1g" + - "OPENSEARCH_JAVA_OPTS=-Xms128m -Xmx1g" + ports: + - "${M2D_PORT_FOR_SEARCH_ENGINE:-9200}:9200" + message_broker: build: context: . diff --git a/env/additional/elasticsearch6/Dockerfile b/env/additional/elasticsearch6/Dockerfile deleted file mode 100644 index 44a8b2a..0000000 --- a/env/additional/elasticsearch6/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -# https://www.elastic.co/guide/en/elasticsearch/reference/6.5/docker.html#docker -FROM docker.elastic.co/elasticsearch/elasticsearch:6.5.4 -COPY --chown=elasticsearch:elasticsearch config/elasticsearch.yml /usr/share/elasticsearch/config/ diff --git a/env/additional/elasticsearch6/config/elasticsearch.yml b/env/additional/elasticsearch6/config/elasticsearch.yml deleted file mode 100644 index d6a8a0d..0000000 --- a/env/additional/elasticsearch6/config/elasticsearch.yml +++ /dev/null @@ -1,8 +0,0 @@ -http.host: 0.0.0.0 -http.port: 9206 - -indices.query.bool.max_clause_count: 10240 - -# Uncomment the following lines for a production cluster deployment -#transport.host: 0.0.0.0 -#discovery.zen.minimum_master_nodes: 1 diff --git a/env/additional/elasticsearch6/docker-compose.yml b/env/additional/elasticsearch6/docker-compose.yml deleted file mode 100644 index ad12c7b..0000000 --- a/env/additional/elasticsearch6/docker-compose.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: '2' - -services: - elasticsearch: - container_name: magento2elastic6 - environment: - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - build: . - ports: - - "9206:9206" -networks: - default: - external: - name: env_default diff --git a/env/additional/elasticsearch7/Dockerfile b/env/additional/elasticsearch7/Dockerfile deleted file mode 100644 index 93544ee..0000000 --- a/env/additional/elasticsearch7/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -# https://www.elastic.co/guide/en/elasticsearch/reference/6.5/docker.html#docker -FROM docker.elastic.co/elasticsearch/elasticsearch:7.16.3 -COPY --chown=elasticsearch:elasticsearch config/elasticsearch.yml /usr/share/elasticsearch/config/ diff --git a/env/additional/elasticsearch7/docker-compose.yml b/env/additional/elasticsearch7/docker-compose.yml deleted file mode 100644 index 5a687f0..0000000 --- a/env/additional/elasticsearch7/docker-compose.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: '2' - -services: - elasticsearch: - container_name: magento2elastic7 - environment: - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - build: . - ports: - - "9207:9207" -networks: - default: - external: - name: env_default diff --git a/env/additional/opensearch/docker-compose.yaml b/env/additional/opensearch/docker-compose.yaml deleted file mode 100644 index b935890..0000000 --- a/env/additional/opensearch/docker-compose.yaml +++ /dev/null @@ -1,19 +0,0 @@ -version: '3' - -services: - opensearch: - image: opensearchproject/opensearch:1.2.4 - container_name: magento2opensearch - environment: - - "discovery.type=single-node" - - "plugins.security.disabled=true" - - "http.host=0.0.0.0" - - "http.port=9200" - - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx${M2D_OPENSEARCH_MAX_HEAP_SIZE:-512m}" - - "DISABLE_INSTALL_DEMO_CONFIG=true" # disable demo config see https://opensearch.org/docs/latest/opensearch/install/docker-security/ - ports: - - "9200:9200" -networks: - default: - name: env_default - external: true diff --git a/services/search-engines/Dockerfile b/services/search-engines/Dockerfile new file mode 100644 index 0000000..a83b7fe --- /dev/null +++ b/services/search-engines/Dockerfile @@ -0,0 +1,40 @@ +ARG M2D_ENABLE_SEARCH_ENGINE='yes' +ARG M2D_SEARCH_ENGINE_VENDOR='elasticsearch' +ARG M2D_SEARCH_ENGINE_VERSION='7' + +FROM scratch as m2d_search_engine_no +COPY tools/dummy/dummy ./ +CMD ["/dummy"] + +FROM m2d_search_engine_no AS m2d_search_engine_no_opensearch +FROM m2d_search_engine_no AS m2d_search_engine_no_elasticsearch + +FROM opensearchproject/opensearch:1.2.4 AS m2d_search_engine_yes_opensearch_1 +FROM opensearchproject/opensearch:2.5.0 AS m2d_search_engine_yes_opensearch_2 + +FROM opensearchproject/opensearch:1.2.4 AS m2d_search_engine_yes_opensearch_1.2 +FROM opensearchproject/opensearch:2.5.0 AS m2d_search_engine_yes_opensearch_2.5 + +FROM m2d_search_engine_yes_opensearch_${M2D_SEARCH_ENGINE_VERSION} AS m2d_search_engine_yes_opensearch +ENV DISABLE_INSTALL_DEMO_CONFIG=true \ + discovery.type=single-node \ + plugins.security.disabled=true \ + http.host=0.0.0.0 \ + http.port=9200 + +FROM --platform=linux/amd64 elasticsearch:6.8.23 AS m2d_search_engine_yes_elasticsearch_6 +FROM elasticsearch:7.16.3 AS m2d_search_engine_yes_elasticsearch_7 +FROM elasticsearch:8.4.3 AS m2d_search_engine_yes_elasticsearch_8 + +FROM --platform=linux/amd64 elasticsearch:7.6.2 AS m2d_search_engine_yes_elasticsearch_7.6 +FROM --platform=linux/amd64 elasticsearch:7.7.1 AS m2d_search_engine_yes_elasticsearch_7.7 +FROM elasticsearch:7.9.3 AS m2d_search_engine_yes_elasticsearch_7.9 +FROM elasticsearch:7.10.1 AS m2d_search_engine_yes_elasticsearch_7.10 +FROM elasticsearch:7.16.3 AS m2d_search_engine_yes_elasticsearch_7.16 +FROM elasticsearch:7.17.9 AS m2d_search_engine_yes_elasticsearch_7.17 +FROM elasticsearch:8.4.3 AS m2d_search_engine_yes_elasticsearch_8.4 + +FROM m2d_search_engine_yes_elasticsearch_${M2D_SEARCH_ENGINE_VERSION} AS m2d_search_engine_yes_elasticsearch +COPY --chown=elasticsearch:elasticsearch services/search-engines/etc/elasticsearch.yml /usr/share/elasticsearch/config/ + +FROM m2d_search_engine_${M2D_ENABLE_SEARCH_ENGINE}_${M2D_SEARCH_ENGINE_VENDOR} AS m2d_search_engine diff --git a/env/additional/elasticsearch7/config/elasticsearch.yml b/services/search-engines/etc/elasticsearch.yml similarity index 92% rename from env/additional/elasticsearch7/config/elasticsearch.yml rename to services/search-engines/etc/elasticsearch.yml index bacd16a..9461cee 100644 --- a/env/additional/elasticsearch7/config/elasticsearch.yml +++ b/services/search-engines/etc/elasticsearch.yml @@ -1,5 +1,5 @@ http.host: 0.0.0.0 -http.port: 9207 +http.port: 9200 indices.query.bool.max_clause_count: 10240 From 78a9bd2d65a797c8f75c2f7c1a371140eb070e93 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 17 Mar 2023 21:41:10 +0100 Subject: [PATCH 11/31] Refactor of Database container --- .env.example | 12 ++++++++++++ docker-compose.yml | 12 ++++++++---- services/db-engines/Dockerfile | 19 +++++++++++++++++++ {env => services/db-engines}/etc/mysql/my.cnf | 0 4 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 services/db-engines/Dockerfile rename {env => services/db-engines}/etc/mysql/my.cnf (100%) diff --git a/.env.example b/.env.example index 19c1c1b..2e97ded 100644 --- a/.env.example +++ b/.env.example @@ -36,6 +36,18 @@ M2D_PORT_FOR_SELENIUM_VNC='5900' ## SERVICES CONFIGURATION SECTION ## ########################################## +## DB ENGINE +# Set which DB engine you want to use: +# - 'mariadb' for MariaDB [https://www.elastic.co/] +# - 'mysql' for Opensearch [https://opensearch.org/] +M2D_DB_ENGINE_VENDOR='mariadb' +# Set expected version of the search engine: +# - MariaDB versions: 10, 10.2, 10.3, 10.4, 10.6 +# - MySQL versions: 5, 5.7, 8, 8.0, 8.0-oracle +M2D_DB_ENGINE_VERSION='10' +# Set the port number used by search engine: +M2D_PORT_FOR_DB_ENGINE='3306' + ## SEARCH ENGINE # Set to 'yes' to enable search engine or to 'no' to disable it: M2D_ENABLE_SEARCH_ENGINE='yes' diff --git a/docker-compose.yml b/docker-compose.yml index e189b1b..8948b0a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,9 +29,14 @@ services: cap_add: - "SYS_PTRACE" db: + build: + context: . + dockerfile: services/db-engines/Dockerfile + target: m2d_db_engine + args: + - M2D_DB_ENGINE_VENDOR:${M2D_DB_ENGINE_VENDOR:-mariadb} + - M2D_DB_ENGINE_VERSION:${M2D_DB_ENGINE_VERSION:-10} container_name: magento2db - # MariaDB is most common in Cloud - image: mariadb:10.2 restart: unless-stopped environment: MYSQL_DATABASE: magento @@ -39,9 +44,8 @@ services: MYSQL_USER: magento MYSQL_PASSWORD: magento ports: - - "3306:3306" + - "${M2D_PORT_FOR_DB_ENGINE:-3306}:3306" volumes: - - "./etc/mysql:/etc/mysql/conf.d" - db-volume:/var/lib/mysql search_engine: diff --git a/services/db-engines/Dockerfile b/services/db-engines/Dockerfile new file mode 100644 index 0000000..7bf4067 --- /dev/null +++ b/services/db-engines/Dockerfile @@ -0,0 +1,19 @@ +ARG M2D_DB_ENGINE_VENDOR='mariadb' +ARG M2D_DB_ENGINE_VERSION='10.2' + +FROM mariadb:10.4 AS m2d_db_engine_mariadb_10 + +FROM mariadb:10.2 AS m2d_db_engine_mariadb_10.2 +FROM mariadb:10.3 AS m2d_db_engine_mariadb_10.3 +FROM mariadb:10.4 AS m2d_db_engine_mariadb_10.4 +FROM mariadb:10.6 AS m2d_db_engine_mariadb_10.6 + +FROM --platform=linux/amd64 mysql:5.7 AS m2d_db_engine_mysql_5 +FROM --platform=linux/amd64 mysql:8.0.28 AS m2d_db_engine_mysql_8 + +FROM --platform=linux/amd64 mysql:5.7 AS m2d_db_engine_mysql_5.7 +FROM --platform=linux/amd64 mysql:8.0.28 AS m2d_db_engine_mysql_8.0 +FROM mysql:8.0.28-oracle AS m2d_db_engine_mysql_8.0-oracle + +FROM m2d_db_engine_${M2D_DB_ENGINE_VENDOR}_${M2D_DB_ENGINE_VERSION} AS m2d_db_engine +COPY services/db-engines/etc/mysql/my.cnf /etc/mysql/conf.d diff --git a/env/etc/mysql/my.cnf b/services/db-engines/etc/mysql/my.cnf similarity index 100% rename from env/etc/mysql/my.cnf rename to services/db-engines/etc/mysql/my.cnf From 34200dea1e7960707ffe137dc138e04fac306449 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 17 Mar 2023 23:21:10 +0100 Subject: [PATCH 12/31] Refactor of Web container --- .env.example | 9 +++ docker-compose.yml | 4 +- .../web-servers/apache}/Dockerfile | 60 +++++++++---------- .../web-servers/apache/etc/apache2}/envvars | 0 .../apache2/sites-enabled}/000-default.conf | 0 .../sites-enabled}/second-level.nip.io.conf | 0 .../apache2/sites-enabled}/vhost.conf.example | 0 .../apache/etc/composer/.gitignore | 3 + .../apache}/etc/composer/auth.json.example | 0 .../apache}/etc/fixtures/.gitignore | 0 .../etc/fixtures/config.example.xml.dist | 0 .../etc/fixtures/small.example.xml.dist | 0 .../apache}/etc/git/gitconfig.example | 0 .../apache}/etc/m2install/.m2install.conf | 10 ++-- .../web-servers/apache}/etc/ssh/.gitignore | 0 .../apache}/etc/ssh/magento2docker | 0 .../apache}/etc/ssh/magento2docker.pub | 0 .../apache/tools}/composer-link.sh | 0 .../web-servers/apache/tools}/prepare-mtf.sh | 0 .../web-servers/apache/tools}/xdebug-php.sh | 0 20 files changed, 47 insertions(+), 39 deletions(-) rename {env => services/web-servers/apache}/Dockerfile (83%) rename {env/etc/apache => services/web-servers/apache/etc/apache2}/envvars (100%) rename {env/etc/apache => services/web-servers/apache/etc/apache2/sites-enabled}/000-default.conf (100%) rename {env/etc/apache => services/web-servers/apache/etc/apache2/sites-enabled}/second-level.nip.io.conf (100%) rename {env/etc/apache => services/web-servers/apache/etc/apache2/sites-enabled}/vhost.conf.example (100%) create mode 100755 services/web-servers/apache/etc/composer/.gitignore rename {env => services/web-servers/apache}/etc/composer/auth.json.example (100%) rename {env => services/web-servers/apache}/etc/fixtures/.gitignore (100%) rename {env => services/web-servers/apache}/etc/fixtures/config.example.xml.dist (100%) rename {env => services/web-servers/apache}/etc/fixtures/small.example.xml.dist (100%) rename {env => services/web-servers/apache}/etc/git/gitconfig.example (100%) rename {env => services/web-servers/apache}/etc/m2install/.m2install.conf (63%) rename {env => services/web-servers/apache}/etc/ssh/.gitignore (100%) rename {env => services/web-servers/apache}/etc/ssh/magento2docker (100%) rename {env => services/web-servers/apache}/etc/ssh/magento2docker.pub (100%) rename {env/misc => services/web-servers/apache/tools}/composer-link.sh (100%) rename {env/misc => services/web-servers/apache/tools}/prepare-mtf.sh (100%) rename {env/misc => services/web-servers/apache/tools}/xdebug-php.sh (100%) diff --git a/.env.example b/.env.example index 2e97ded..b5577bd 100644 --- a/.env.example +++ b/.env.example @@ -6,6 +6,15 @@ # - 'm1' for Apple M1 CPUs # - 'intel' for Intel or AMD based CPUs M2D_CPU_TYPE='m1' +# Set your IDE key for xDebug: +# - 'PHPSTORM' if you are PHP Storm user +# - 'VSCODE' if you are Microsoft Visual Studio Code user +# - '***' you can set any value your IDE requires +M2D_XDEBUG_IDE_KEY='PHPSTORM' +# Provide Composer authorisation: +COMPOSER_AUTH='{"http-basic":{"repo.magento.com":{"username": "","password":""}}}' +# Provide Magento CLI authentication token: +MAGENTO_CLOUD_CLI_TOKEN='' ########################################## ## TOOLS CONFIGURATION SECTION ## diff --git a/docker-compose.yml b/docker-compose.yml index 8948b0a..ba9a091 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,10 +9,10 @@ services: context: . target: php_base args: - - M2D_PHP_VERSION=${M2D_PHP_VERSION:-7.4} + - M2D_WEB_SERVER_PHP_VERSION=${M2D_WEB_SERVER_PHP_VERSION:-8.1} + - M2D_ENABLE_BLACKFIRE=${M2D_ENABLE_BLACKFIRE:-no} - M2D_XDEBUG_IDE_KEY=${M2D_XDEBUG_IDE_KEY:-PHPSTORM} environment: - - PHP_IDE_CONFIG=serverName=PHPSTORM - BLACKFIRE_CLIENT_ID - BLACKFIRE_CLIENT_TOKEN - MAGENTO_CLOUD_CLI_TOKEN diff --git a/env/Dockerfile b/services/web-servers/apache/Dockerfile similarity index 83% rename from env/Dockerfile rename to services/web-servers/apache/Dockerfile index 0ad3452..0dacaa7 100644 --- a/env/Dockerfile +++ b/services/web-servers/apache/Dockerfile @@ -1,9 +1,8 @@ -## To build image for any PHP version, just set version in the M2D_PHP_VERSION variable. -## It can be in .env file or in your terminal with export M2D_PHP_VERSION=7.4 +ARG M2D_WEB_SERVER_PHP_VERSION='8.1' +ARG M2D_ENABLE_BLACKFIRE='no' ## BASE PHP IMAGE - COMMON FOR ALL PHP VERSIONS ## -ARG M2D_PHP_VERSION='8.1' -FROM php:${M2D_PHP_VERSION}-apache-bullseye AS php_base_ +FROM php:${M2D_WEB_SERVER_PHP_VERSION}-apache-bullseye AS m2d_web_server_apache_php_base_ # SETTING UP THE SYSTEM: RUN apt-get update \ @@ -62,12 +61,8 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local && apt -qy install $PHPIZE_DEPS && mkdir /${_HOME_DIRECTORY}/.composer \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer2 --2 -# COMPOSER VERSION SWITCHER: -COPY ./misc/composer-link.sh /usr/local/bin/composer-link.sh - -# XDEBUG enable/disable script -COPY ./misc/xdebug-php.sh /usr/local/bin/xdebug-php.sh -COPY ./misc/prepare-mtf.sh /usr/local/bin/prepare-mtf.sh +# TOOLS: +COPY ./services/web-servers/apache/tools/* /usr/local/bin/ # CODESNIFFER: # RUN pear install PHP_CodeSniffer \ @@ -121,13 +116,13 @@ RUN echo "Defaults timestamp_timeout=-1" >> /etc/sudoers ARG CACHEBUST=1 # CUSTOM CONFIGURATIONS: -COPY ./etc/git/gitconfig ${_HOME_DIRECTORY}/.gitconfig -COPY ./etc/composer/auth.json /${_HOME_DIRECTORY}/.composer/auth.json -COPY ./misc/* /usr/local/bin/ -COPY ./etc/apache/envvars /etc/apache2/envvars -COPY ./etc/apache /etc/apache2/sites-enabled/ -COPY ./etc/fixtures /etc/fixtures -COPY ./etc/m2install/.m2install.conf* ${_HOME_DIRECTORY}/ +COPY ./services/web-servers/apache/etc/apache2 /etc/apache2 +# COPY ./services/web-servers/apache/etc/apache2/envvars /etc/apache2/envvars +# COPY ./services/web-servers/apache/etc/apache2/sites-enabled /etc/apache2/sites-enabled/ +COPY ./services/web-servers/apache/etc/git/gitconfig ${_HOME_DIRECTORY}/.gitconfig +COPY ./services/web-servers/apache/etc/composer/auth.json /${_HOME_DIRECTORY}/.composer/auth.json +COPY ./services/web-servers/apache/etc/fixtures /etc/fixtures +COPY ./services/web-servers/apache/etc/m2install/.m2install.conf* ${_HOME_DIRECTORY}/ # MAGENTO TOOLS: RUN curl -o /usr/local/bin/m2install.sh https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install.sh \ @@ -140,14 +135,19 @@ RUN curl -o /usr/local/bin/m2install.sh https://raw.githubusercontent.com/yvoron && tar -xf /tmp/teleport.tar.gz -C /tmp/ \ && make -C /tmp/teleport/ \ && git ls-remote git@github.com:magento-sparta/ee-support-tools.git 2>&1 | if grep -q HEAD; then git clone git@github.com:magento-sparta/ee-support-tools.git /usr/local/src/ee-support-tools; else echo; fi \ - && if [ -d /usr/local/src/ee-support-tools ]; then ln -s /usr/local/src/ee-support-tools/cloud-teleport/cloud-teleport /usr/local/bin/cloud-teleport; else echo; fi + && if [ -d /usr/local/src/ee-support-tools ]; then ln -s /usr/local/src/ee-support-tools/cloud-teleport/cloud-teleport /usr/local/bin/cloud-teleport; else echo; fi \ + && git ls-remote git@github.com:magento-sparta/m-it.git 2>&1 | if grep -q HEAD; then git clone git@github.com:magento-sparta/m-it.git /usr/local/src/m-it; else echo; fi \ + && if [ -d /usr/local/src/m-it ]; then /usr/local/src/m-it/mit-installer.sh; else echo; fi RUN chmod +x /usr/local/bin/* ## END OF BASE IMAGE ## -## BASE IMAGE WITH BLACKFIRE "" -FROM php_base_ AS php_base_blackfire +## BASE IMAGE WITHOUT BLACKFIRE ## +FROM m2d_web_server_apache_php_base_ AS m2d_web_server_apache_php_base_blackfire_no + +## BASE IMAGE WITH BLACKFIRE ## +FROM m2d_web_server_apache_php_base_ AS m2d_web_server_apache_php_base_blackfire_yes # BLACKFIRE: RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ @@ -165,8 +165,7 @@ RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ ## IMAGE ADJUSTMENTS FOR PHP 7.x ## -ARG M2D_BLACKFIRE='' -FROM php_base_${M2D_BLACKFIRE} AS php7x +FROM m2d_web_server_apache_php_base_${M2D_ENABLE_BLACKFIRE'} AS m2d_web_server_apache_php7x # COMPOSER 1 LINKED AS DEFAULT: RUN ln -s /usr/local/bin/composer1 /usr/local/bin/composer @@ -191,8 +190,7 @@ RUN pecl install libsodium-2.0.23 ## IMAGE ADJUSTEMNTS FOR PHP 8.x -ARG M2D_BLACKFIRE='' -FROM php_base_${M2D_BLACKFIRE} AS php8x +FROM m2d_web_server_apache_php_base_${M2D_ENABLE_BLACKFIRE} AS m2d_web_server_apache_php8x # PHP EXTENSIONS GD: RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp \ @@ -218,7 +216,7 @@ RUN pecl install xdebug \ ## IMAGE ADJUSTEMNTS FOR PHP 7.3 ## -FROM php7x AS php_7.3 +FROM m2d_web_server_apache_php7x AS m2d_web_server_apache_php7.3 # PHP EXTENSIONS GD: RUN docker-php-ext-configure gd --with-gd --with-webp-dir \ --with-png-dir --with-zlib-dir --with-xpm-dir \ @@ -228,7 +226,7 @@ RUN docker-php-ext-configure gd --with-gd --with-webp-dir \ ## IMAGE ADJUSTEMNTS FOR PHP 7.4 ## -FROM php7x AS php_7.4 +FROM m2d_web_server_apache_php7x AS m2d_web_server_apache_php7.4 # PHP EXTENSIONS GD: RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp \ && docker-php-ext-install -j$(nproc) gd @@ -236,7 +234,7 @@ RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-w ## IMAGE ADJUSTEMNTS FOR PHP 8.0 ## -FROM php8x AS php_8.0 +FROM m2d_web_server_apache_php8x AS m2d_web_server_apache_php8.0 # ADDITIONAL EXTENSIONS RUN pecl install libsodium-2.0.23 @@ -244,17 +242,15 @@ RUN pecl install libsodium-2.0.23 ## IMAGE ADJUSTEMNTS FOR PHP 8.1 ## -FROM php8x AS php_8.1 +FROM m2d_web_server_apache_php8x AS m2d_web_server_apache_php8.1 ## END OF IMAGE ADJUSTMENTS FOR PHP 8.1 ## ## IMAGE ADJUSTEMNTS FOR PHP 8.2 ## -FROM php8x AS php_8.2 +FROM m2d_web_server_apache_php8x AS m2d_web_server_apache_php8.2 ## END OF IMAGE ADJUSTMENTS FOR PHP 8.2 ## ## TARGET IMAGE ADJUSTEMNTS ## -ARG M2D_PHP_VERSION='8.1' -FROM php_${M2D_PHP_VERSION} AS php_base - +FROM m2d_web_server_apache_php${M2D_WEB_SERVER_PHP_VERSION} AS web_server CMD service ssh start; apache2-foreground diff --git a/env/etc/apache/envvars b/services/web-servers/apache/etc/apache2/envvars similarity index 100% rename from env/etc/apache/envvars rename to services/web-servers/apache/etc/apache2/envvars diff --git a/env/etc/apache/000-default.conf b/services/web-servers/apache/etc/apache2/sites-enabled/000-default.conf similarity index 100% rename from env/etc/apache/000-default.conf rename to services/web-servers/apache/etc/apache2/sites-enabled/000-default.conf diff --git a/env/etc/apache/second-level.nip.io.conf b/services/web-servers/apache/etc/apache2/sites-enabled/second-level.nip.io.conf similarity index 100% rename from env/etc/apache/second-level.nip.io.conf rename to services/web-servers/apache/etc/apache2/sites-enabled/second-level.nip.io.conf diff --git a/env/etc/apache/vhost.conf.example b/services/web-servers/apache/etc/apache2/sites-enabled/vhost.conf.example similarity index 100% rename from env/etc/apache/vhost.conf.example rename to services/web-servers/apache/etc/apache2/sites-enabled/vhost.conf.example diff --git a/services/web-servers/apache/etc/composer/.gitignore b/services/web-servers/apache/etc/composer/.gitignore new file mode 100755 index 0000000..314ca1e --- /dev/null +++ b/services/web-servers/apache/etc/composer/.gitignore @@ -0,0 +1,3 @@ +* +!.gitignore +!auth.json.example diff --git a/env/etc/composer/auth.json.example b/services/web-servers/apache/etc/composer/auth.json.example similarity index 100% rename from env/etc/composer/auth.json.example rename to services/web-servers/apache/etc/composer/auth.json.example diff --git a/env/etc/fixtures/.gitignore b/services/web-servers/apache/etc/fixtures/.gitignore similarity index 100% rename from env/etc/fixtures/.gitignore rename to services/web-servers/apache/etc/fixtures/.gitignore diff --git a/env/etc/fixtures/config.example.xml.dist b/services/web-servers/apache/etc/fixtures/config.example.xml.dist similarity index 100% rename from env/etc/fixtures/config.example.xml.dist rename to services/web-servers/apache/etc/fixtures/config.example.xml.dist diff --git a/env/etc/fixtures/small.example.xml.dist b/services/web-servers/apache/etc/fixtures/small.example.xml.dist similarity index 100% rename from env/etc/fixtures/small.example.xml.dist rename to services/web-servers/apache/etc/fixtures/small.example.xml.dist diff --git a/env/etc/git/gitconfig.example b/services/web-servers/apache/etc/git/gitconfig.example similarity index 100% rename from env/etc/git/gitconfig.example rename to services/web-servers/apache/etc/git/gitconfig.example diff --git a/env/etc/m2install/.m2install.conf b/services/web-servers/apache/etc/m2install/.m2install.conf similarity index 63% rename from env/etc/m2install/.m2install.conf rename to services/web-servers/apache/etc/m2install/.m2install.conf index ead69a0..21acf73 100644 --- a/env/etc/m2install/.m2install.conf +++ b/services/web-servers/apache/etc/m2install/.m2install.conf @@ -12,8 +12,8 @@ COMPOSER_VERSION=2.2 MAGENTO_EE_PATH= GIT_CE_REPO=git@github.com:magento/magento2.git GIT_EE_REPO= -GIT_BRANCH=2.2 -SEARCH_ENGINE_ELASTICSEARCH7_HOST="magento2elastic7" -SEARCH_ENGINE_ELASTICSEARCH7_PORT="9207" -SEARCH_ENGINE_ELASTICSEARCH6_HOST="magento2elastic6" -SEARCH_ENGINE_ELASTICSEARCH6_PORT="9206" +GIT_BRANCH=2.4-develop +SEARCH_ENGINE_ELASTICSEARCH7_HOST="magento2searchengine" +SEARCH_ENGINE_ELASTICSEARCH7_PORT="9200" +SEARCH_ENGINE_ELASTICSEARCH6_HOST="magento2searchengine" +SEARCH_ENGINE_ELASTICSEARCH6_PORT="9200" diff --git a/env/etc/ssh/.gitignore b/services/web-servers/apache/etc/ssh/.gitignore similarity index 100% rename from env/etc/ssh/.gitignore rename to services/web-servers/apache/etc/ssh/.gitignore diff --git a/env/etc/ssh/magento2docker b/services/web-servers/apache/etc/ssh/magento2docker similarity index 100% rename from env/etc/ssh/magento2docker rename to services/web-servers/apache/etc/ssh/magento2docker diff --git a/env/etc/ssh/magento2docker.pub b/services/web-servers/apache/etc/ssh/magento2docker.pub similarity index 100% rename from env/etc/ssh/magento2docker.pub rename to services/web-servers/apache/etc/ssh/magento2docker.pub diff --git a/env/misc/composer-link.sh b/services/web-servers/apache/tools/composer-link.sh similarity index 100% rename from env/misc/composer-link.sh rename to services/web-servers/apache/tools/composer-link.sh diff --git a/env/misc/prepare-mtf.sh b/services/web-servers/apache/tools/prepare-mtf.sh similarity index 100% rename from env/misc/prepare-mtf.sh rename to services/web-servers/apache/tools/prepare-mtf.sh diff --git a/env/misc/xdebug-php.sh b/services/web-servers/apache/tools/xdebug-php.sh similarity index 100% rename from env/misc/xdebug-php.sh rename to services/web-servers/apache/tools/xdebug-php.sh From 519bcf635a40ab2ec3e0105eb6b5397a0a81b115 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 17 Mar 2023 23:28:13 +0100 Subject: [PATCH 13/31] Refactor of PHPStorm container --- ...cker-compose.phpstorm.yml => docker-compose.phpstorm.yml | 4 ++-- {env/additional => tools}/phpstorm/Dockerfile | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) rename env/docker-compose.phpstorm.yml => docker-compose.phpstorm.yml (86%) rename {env/additional => tools}/phpstorm/Dockerfile (75%) diff --git a/env/docker-compose.phpstorm.yml b/docker-compose.phpstorm.yml similarity index 86% rename from env/docker-compose.phpstorm.yml rename to docker-compose.phpstorm.yml index e34a511..6016e59 100644 --- a/env/docker-compose.phpstorm.yml +++ b/docker-compose.phpstorm.yml @@ -4,8 +4,8 @@ services: phpstorm: container_name: phpstorm build: - context: ./ - dockerfile: additional/phpstorm/Dockerfile + context: . + dockerfile: services/phpstorm/Dockerfile ports: - "9000:9000" volumes: diff --git a/env/additional/phpstorm/Dockerfile b/tools/phpstorm/Dockerfile similarity index 75% rename from env/additional/phpstorm/Dockerfile rename to tools/phpstorm/Dockerfile index 71ca94b..68e0155 100644 --- a/env/additional/phpstorm/Dockerfile +++ b/tools/phpstorm/Dockerfile @@ -12,12 +12,12 @@ ENV _HOME_DIRECTORY=/home/${_USER} RUN useradd -m ${_USER} && echo "${_USER}:${_USER}" | chpasswd && chsh ${_USER} -s /bin/bash && adduser ${_USER} sudo #SSH -COPY ./etc/ssh ${_HOME_DIRECTORY}/.ssh +COPY ./services/web-servers/apache/etc/ssh ${_HOME_DIRECTORY}/.ssh RUN chmod -R 700 ${_HOME_DIRECTORY}/.ssh #GIT -COPY ./etc/git/gitconfig ${_HOME_DIRECTORY}/.gitconfig -COPY ./etc/composer/auth.json ${_HOME_DIRECTORY}/.composer/auth.json +COPY ./services/web-servers/apache/etc/git/gitconfig ${_HOME_DIRECTORY}/.gitconfig +COPY ./services/web-servers/apache/etc/composer/auth.json ${_HOME_DIRECTORY}/.composer/auth.json RUN chown -R ${_USER}:${_USER} ${_HOME_DIRECTORY} From c1723f28db069b5184820f1981bd6b0144df617d Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 17 Mar 2023 23:30:18 +0100 Subject: [PATCH 14/31] Project clean-up --- env/.env.example | 5 - env/docker-compose.override.yml.dist | 8 - env/etc/php/7.3/Dockerfile | 167 ----------------- env/etc/php/7.4/Dockerfile | 174 ------------------ env/etc/php/8.0/Dockerfile | 172 ------------------ env/etc/php/8.1/Dockerfile | 173 ------------------ env/etc/php/Dockerfile | 257 --------------------------- 7 files changed, 956 deletions(-) delete mode 100644 env/.env.example delete mode 100644 env/docker-compose.override.yml.dist delete mode 100644 env/etc/php/7.3/Dockerfile delete mode 100644 env/etc/php/7.4/Dockerfile delete mode 100644 env/etc/php/8.0/Dockerfile delete mode 100644 env/etc/php/8.1/Dockerfile delete mode 100644 env/etc/php/Dockerfile diff --git a/env/.env.example b/env/.env.example deleted file mode 100644 index 35e130a..0000000 --- a/env/.env.example +++ /dev/null @@ -1,5 +0,0 @@ -MAGENTO_CLOUD_CLI_TOKEN= -COMPOSER_AUTH={"http-basic":{"repo.magento.com":{"username":"","password":""}}} -M2D_XDEBUG_IDE_KEY=PHPSTORM -M2D_OPENSEARCH_MAX_HEAP_SIZE=512m -M2D_PHP_VERSION=8.1 diff --git a/env/docker-compose.override.yml.dist b/env/docker-compose.override.yml.dist deleted file mode 100644 index e786957..0000000 --- a/env/docker-compose.override.yml.dist +++ /dev/null @@ -1,8 +0,0 @@ -version: '2' - -services: - web: - volumes: - - "$HOME/.composer:/root/.composer" - - "$HOME/.gitconfig:/root/.gitconfig" - - "$HOME/.bashrc:/root/.bashrc" diff --git a/env/etc/php/7.3/Dockerfile b/env/etc/php/7.3/Dockerfile deleted file mode 100644 index d340549..0000000 --- a/env/etc/php/7.3/Dockerfile +++ /dev/null @@ -1,167 +0,0 @@ -#PHP IMAGE -FROM php:7.3-apache-bullseye - -#SETTING UP THE SYSTEM -RUN apt-get update \ - && apt-get install -y \ - apt-utils \ - wget \ - libwebp-dev \ - libxpm-dev \ - libfreetype6-dev \ - libjpeg62-turbo-dev \ - libmcrypt-dev \ - libpng-dev \ - libxslt-dev \ - libicu-dev \ - mariadb-client \ - pv \ - vim \ - nano \ - bash-completion \ - openssh-server \ - ssl-cert \ - msmtp \ - sudo \ - dnsutils \ - iputils-ping \ - iputils-tracepath \ - host \ - strace \ - telnet \ - unzip \ - gnupg \ - gcc \ - lsof \ - libzip-dev \ - libsodium-dev \ - && apt-get update \ - && apt-get clean all - -#CREATE USER -ENV _USER=magento -ENV _HOME_DIRECTORY=/home/${_USER} -RUN useradd -m ${_USER} && echo "${_USER}:${_USER}" | chpasswd && chsh ${_USER} -s /bin/bash && adduser ${_USER} sudo - -#PHP EXTENSIONS -RUN docker-php-ext-install -j$(nproc) iconv soap sockets \ - && docker-php-ext-configure gd --with-gd --with-webp-dir \ - --with-png-dir --with-zlib-dir --with-xpm-dir \ - --with-freetype-dir=/usr/include/freetype2/ --with-jpeg-dir=/usr/include/ \ - && docker-php-ext-install -j$(nproc) gd bcmath pdo_mysql xsl intl zip \ - && pecl install libsodium-2.0.22 - -#GIT -RUN apt-get update \ - && apt-get install -y git \ - && apt-get clean all - -#NODEJS -RUN curl -sL https://deb.nodesource.com/setup_12.x | bash \ - && apt-get install -y nodejs - -#BLACKFIRE -RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ - && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \ - && mkdir -p /tmp/blackfire \ - && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \ - && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \ - && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \ - && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz \ - && mkdir -p /tmp/blackfire \ - && curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux_static/amd64 | tar zxp -C /tmp/blackfire \ - && mv /tmp/blackfire/blackfire /usr/bin/blackfire \ - && rm -Rf /tmp/blackfire - -#COMPOSER -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --1\ - && apt -qy install $PHPIZE_DEPS && mkdir /${_HOME_DIRECTORY}/.composer - -#XDEBUG -ARG M2D_XDEBUG_IDE_KEY=PHPSTORM -ENV M2D_XDEBUG_IDE_KEY=${M2D_XDEBUG_IDE_KEY:-PHPSTORM} -RUN pecl install xdebug-2.9.0 \ - && echo ";zend_extension=xdebug.so" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.max_nesting_level=10000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.idekey=$M2D_XDEBUG_IDE_KEY" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -COPY ./misc/xdebug-php.sh /usr/local/bin/xdebug-php.sh - -#CODESNIFFER -RUN pear install PHP_CodeSniffer \ - && mkdir /usr/local/magento-ecg-code-sniffer \ - && cd /usr/local/magento-ecg-code-sniffer/ && composer require magento-ecg/coding-standard \ - && phpcs --config-set installed_paths /usr/local/magento-ecg-code-sniffer/vendor/magento-ecg/coding-standard - -#SENDMAIL -RUN echo "sendmail_path=/usr/bin/msmtp -t" >> /usr/local/etc/php/conf.d/mailcatcher.ini \ - && echo "memory_limit=4G" >> /usr/local/etc/php/conf.d/custom.ini \ - && echo "max_input_vars=10000" >> /usr/local/etc/php/conf.d/custom.ini \ - && echo "account default" >> /etc/msmtprc \ - && echo "host mailcatcher" >> /etc/msmtprc \ - && echo "port 1025" >> /etc/msmtprc \ - && echo "auto_from on" >> /etc/msmtprc - -#SSH -COPY ./etc/ssh ${_HOME_DIRECTORY}/.ssh -ADD ./etc/ssh/magento2docker.pub ${_HOME_DIRECTORY}/.ssh/authorized_keys -RUN chmod -R 700 ${_HOME_DIRECTORY}/.ssh \ - && echo " ServerAliveInterval 30" >> /etc/ssh/ssh_config \ - && echo " TCPKeepAlive yes" >> /etc/ssh/ssh_config -COPY ./etc/ssh /root/.ssh -ADD ./etc/ssh/magento2docker.pub /root/.ssh/authorized_keys -RUN chmod -R 700 /root/.ssh \ - && echo "Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc" >> /etc/ssh/sshd_config \ - && touch /root/.ssh/known_hosts \ - && ssh-keygen -F github.com || ssh-keyscan github.com >> /root/.ssh/known_hosts - -#APACHE -RUN a2enmod ssl \ - && a2ensite default-ssl.conf \ - && a2enmod vhost_alias \ - && a2enmod proxy \ - && a2enmod rewrite \ - && chown -R ${_USER}:${_USER} /var/www/html -RUN chown -R ${_USER}:${_USER} ${_HOME_DIRECTORY} - -#BASH COMPLETION -USER magento -RUN echo "source /etc/bash_completion" >> ${_HOME_DIRECTORY}/.bashrc - -#MAGENTO CLI -RUN curl -sS https://accounts.magento.cloud/cli/installer | php -USER root - -#TUNE ENVIRONMENT -RUN echo "Defaults timestamp_timeout=-1" >> /etc/sudoers - -#FLAG TO NOT CACHE ANYTHING FROM THIS POINT, details: https://github.com/docker/docker/issues/1996#issuecomment-185872769 -ARG CACHEBUST=1 - -#CUSTOM CONFIGURATIONS -COPY ./etc/git/gitconfig ${_HOME_DIRECTORY}/.gitconfig -COPY ./etc/composer/auth.json /${_HOME_DIRECTORY}/.composer/auth.json -COPY ./misc/* /usr/local/bin/ -COPY ./etc/apache/envvars /etc/apache2/envvars -COPY ./etc/apache /etc/apache2/sites-enabled/ -COPY ./etc/fixtures /etc/fixtures -COPY ./etc/m2install/.m2install.conf* ${_HOME_DIRECTORY}/ - -#MAGENTO TOOLS -RUN curl -o /usr/local/bin/m2install.sh https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install.sh \ - && curl -o /etc/bash_completion.d/m2install-bash-completion https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install-bash-completion \ - && curl -o /usr/local/bin/n98-magerun2 https://files.magerun.net/n98-magerun2.phar \ - && curl -o /etc/bash_completion.d/n98-magerun2.phar.bash https://raw.githubusercontent.com/netz98/n98-magerun2/master/res/autocompletion/bash/n98-magerun2.phar.bash \ - && curl -o /usr/local/bin/m2-convert-for-composer https://raw.githubusercontent.com/isitnikov/m2-convert-patch-for-composer-install/master/convert-for-composer.php \ - && curl -o /etc/bash_completion.d/magento2-bash-completion https://raw.githubusercontent.com/yvoronoy/magento2-bash-completion/master/magento2-bash-completion-enterprise \ - && curl -L -o /tmp/teleport.tar.gz https://github.com/gravitational/teleport/releases/download/v1.3.2/teleport-v1.3.2-linux-amd64-bin.tar.gz \ - && tar -xf /tmp/teleport.tar.gz -C /tmp/ \ - && make -C /tmp/teleport/ \ - && git ls-remote git@github.com:magento-sparta/ee-support-tools.git 2>&1 | if grep -q HEAD; then git clone git@github.com:magento-sparta/ee-support-tools.git /usr/local/src/ee-support-tools; else echo; fi \ - && if [ -d /usr/local/src/ee-support-tools ]; then ln -s /usr/local/src/ee-support-tools/cloud-teleport/cloud-teleport /usr/local/bin/cloud-teleport; else echo; fi - -RUN chmod +x /usr/local/bin/* - -CMD service ssh start; apache2-foreground diff --git a/env/etc/php/7.4/Dockerfile b/env/etc/php/7.4/Dockerfile deleted file mode 100644 index a8f1970..0000000 --- a/env/etc/php/7.4/Dockerfile +++ /dev/null @@ -1,174 +0,0 @@ -#PHP IMAGE -FROM php:7.4-apache-bullseye - -#SETTING UP THE SYSTEM -RUN apt-get update \ - && apt-get install -y \ - apt-utils \ - wget \ - libwebp-dev \ - libxpm-dev \ - libfreetype6-dev \ - libjpeg62-turbo-dev \ - libmcrypt-dev \ - libpng-dev \ - libxslt-dev \ - libicu-dev \ - mariadb-client \ - pv \ - vim \ - nano \ - bash-completion \ - openssh-server \ - ssl-cert \ - msmtp \ - sudo \ - dnsutils \ - iputils-ping \ - iputils-tracepath \ - host \ - strace \ - telnet \ - unzip \ - gnupg \ - gcc \ - lsof \ - libsodium-dev \ - libzip-dev \ - parallel \ - && apt-get update \ - && apt-get clean all - -#CREATE USER -ENV _USER=magento -ENV _HOME_DIRECTORY=/home/${_USER} -RUN useradd -m ${_USER} && echo "${_USER}:${_USER}" | chpasswd && chsh ${_USER} -s /bin/bash && adduser ${_USER} sudo - -#PHP EXTENSIONS -RUN docker-php-ext-install -j$(nproc) iconv soap sockets \ - && docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp \ - && docker-php-ext-install -j$(nproc) gd bcmath pdo_mysql xsl intl zip \ - && pecl install libsodium-2.0.22 - -#GIT -RUN apt-get update \ - && apt-get install -y git \ - && apt-get clean all - -#NODEJS -RUN curl -sL https://deb.nodesource.com/setup_12.x | bash \ - && apt-get install -y nodejs - -#BLACKFIRE -RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ - && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \ - && mkdir -p /tmp/blackfire \ - && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \ - && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \ - && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \ - && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz \ - && mkdir -p /tmp/blackfire \ - && curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux_static/amd64 | tar zxp -C /tmp/blackfire \ - && mv /tmp/blackfire/blackfire /usr/bin/blackfire \ - && rm -Rf /tmp/blackfire - -#COMPOSER -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer1 --1\ - && apt -qy install $PHPIZE_DEPS && mkdir /${_HOME_DIRECTORY}/.composer - -#COMPOSER 2 (additional) -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer2 --2 - -#COMPOSER link (1 is default for PHP 7.4) -RUN ln -s /usr/local/bin/composer1 /usr/local/bin/composer - -#XDEBUG -ARG M2D_XDEBUG_IDE_KEY=PHPSTORM -ENV M2D_XDEBUG_IDE_KEY=${M2D_XDEBUG_IDE_KEY:-PHPSTORM} -RUN pecl install xdebug-2.9.0 \ - && echo ";zend_extension=xdebug.so" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.max_nesting_level=10000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.idekey=$M2D_XDEBUG_IDE_KEY" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -COPY ./misc/xdebug-php.sh /usr/local/bin/xdebug-php.sh -COPY ./misc/prepare-mtf.sh /usr/local/bin/prepare-mtf.sh -COPY ./misc/composer-link.sh /usr/local/bin/composer-link.sh - -#CODESNIFFER -RUN pear install PHP_CodeSniffer \ - && mkdir /usr/local/magento-ecg-code-sniffer \ - && cd /usr/local/magento-ecg-code-sniffer/ && composer require magento-ecg/coding-standard \ - && phpcs --config-set installed_paths /usr/local/magento-ecg-code-sniffer/vendor/magento-ecg/coding-standard - -#SENDMAIL -RUN echo "sendmail_path=/usr/bin/msmtp -t" >> /usr/local/etc/php/conf.d/mailcatcher.ini \ - && echo "memory_limit=4G" >> /usr/local/etc/php/conf.d/custom.ini \ - && echo "max_input_vars=10000" >> /usr/local/etc/php/conf.d/custom.ini \ - && echo "account default" >> /etc/msmtprc \ - && echo "host mailcatcher" >> /etc/msmtprc \ - && echo "port 1025" >> /etc/msmtprc \ - && echo "auto_from on" >> /etc/msmtprc - -#SSH -COPY ./etc/ssh ${_HOME_DIRECTORY}/.ssh -ADD ./etc/ssh/magento2docker.pub ${_HOME_DIRECTORY}/.ssh/authorized_keys -RUN chmod -R 700 ${_HOME_DIRECTORY}/.ssh \ - && echo " ServerAliveInterval 30" >> /etc/ssh/ssh_config \ - && echo " TCPKeepAlive yes" >> /etc/ssh/ssh_config -COPY ./etc/ssh /root/.ssh -ADD ./etc/ssh/magento2docker.pub /root/.ssh/authorized_keys -RUN chmod -R 700 /root/.ssh \ - && echo "Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc" >> /etc/ssh/sshd_config \ - && touch /root/.ssh/known_hosts \ - && ssh-keygen -F github.com || ssh-keyscan github.com >> /root/.ssh/known_hosts - -#APACHE -RUN a2enmod ssl \ - && a2ensite default-ssl.conf \ - && a2enmod vhost_alias \ - && a2enmod proxy \ - && a2enmod rewrite \ - && chown -R ${_USER}:${_USER} /var/www/html -RUN chown -R ${_USER}:${_USER} ${_HOME_DIRECTORY} - -#BASH COMPLETION -USER magento -RUN echo "source /etc/bash_completion" >> ${_HOME_DIRECTORY}/.bashrc - -#MAGENTO CLI -RUN curl -sS https://accounts.magento.cloud/cli/installer | php -USER root - -#TUNE ENVIRONMENT -RUN echo "Defaults timestamp_timeout=-1" >> /etc/sudoers - -#FLAG TO NOT CACHE ANYTHING FROM THIS POINT, details: https://github.com/docker/docker/issues/1996#issuecomment-185872769 -ARG CACHEBUST=1 - -#CUSTOM CONFIGURATIONS -COPY ./etc/git/gitconfig ${_HOME_DIRECTORY}/.gitconfig -COPY ./etc/composer/auth.json /${_HOME_DIRECTORY}/.composer/auth.json -COPY ./misc/* /usr/local/bin/ -COPY ./etc/apache/envvars /etc/apache2/envvars -COPY ./etc/apache /etc/apache2/sites-enabled/ -COPY ./etc/fixtures /etc/fixtures -COPY ./etc/m2install/.m2install.conf* ${_HOME_DIRECTORY}/ - -#MAGENTO TOOLS -RUN curl -o /usr/local/bin/m2install.sh https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install.sh \ - && curl -o /etc/bash_completion.d/m2install-bash-completion https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install-bash-completion \ - && curl -o /usr/local/bin/n98-magerun2 https://files.magerun.net/n98-magerun2.phar \ - && curl -o /etc/bash_completion.d/n98-magerun2.phar.bash https://raw.githubusercontent.com/netz98/n98-magerun2/master/res/autocompletion/bash/n98-magerun2.phar.bash \ - && curl -o /usr/local/bin/m2-convert-for-composer https://raw.githubusercontent.com/isitnikov/m2-convert-patch-for-composer-install/master/convert-for-composer.php \ - && curl -o /etc/bash_completion.d/magento2-bash-completion https://raw.githubusercontent.com/yvoronoy/magento2-bash-completion/master/magento2-bash-completion-enterprise \ - && curl -L -o /tmp/teleport.tar.gz https://github.com/gravitational/teleport/releases/download/v1.3.2/teleport-v1.3.2-linux-amd64-bin.tar.gz \ - && tar -xf /tmp/teleport.tar.gz -C /tmp/ \ - && make -C /tmp/teleport/ \ - && git ls-remote git@github.com:magento-sparta/ee-support-tools.git 2>&1 | if grep -q HEAD; then git clone git@github.com:magento-sparta/ee-support-tools.git /usr/local/src/ee-support-tools; else echo; fi \ - && if [ -d /usr/local/src/ee-support-tools ]; then ln -s /usr/local/src/ee-support-tools/cloud-teleport/cloud-teleport /usr/local/bin/cloud-teleport; else echo; fi - -RUN chmod +x /usr/local/bin/* - -CMD service ssh start; apache2-foreground diff --git a/env/etc/php/8.0/Dockerfile b/env/etc/php/8.0/Dockerfile deleted file mode 100644 index b954e9b..0000000 --- a/env/etc/php/8.0/Dockerfile +++ /dev/null @@ -1,172 +0,0 @@ -#PHP IMAGE -FROM php:8.0-apache-bullseye - -#SETTING UP THE SYSTEM -RUN apt-get update \ - && apt-get install -y \ - apt-utils \ - wget \ - libwebp-dev \ - libxpm-dev \ - libfreetype6-dev \ - libjpeg62-turbo-dev \ - libmcrypt-dev \ - libpng-dev \ - libxslt-dev \ - libicu-dev \ - mariadb-client \ - pv \ - vim \ - nano \ - bash-completion \ - openssh-server \ - ssl-cert \ - msmtp \ - sudo \ - dnsutils \ - iputils-ping \ - iputils-tracepath \ - host \ - strace \ - telnet \ - unzip \ - gnupg \ - gcc \ - lsof \ - libsodium-dev \ - libzip-dev \ - && apt-get update \ - && apt-get clean all - -#CREATE USER -ENV _USER=magento -ENV _HOME_DIRECTORY=/home/${_USER} -RUN useradd -m ${_USER} && echo "${_USER}:${_USER}" | chpasswd && chsh ${_USER} -s /bin/bash && adduser ${_USER} sudo - -#PHP EXTENSIONS -RUN docker-php-ext-install -j$(nproc) iconv soap sockets \ - && docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp \ - && docker-php-ext-install -j$(nproc) gd bcmath pdo_mysql xsl intl zip \ - && pecl install libsodium-2.0.23 - -#GIT -RUN apt-get update \ - && apt-get install -y git \ - && apt-get clean all - -#NODEJS -RUN curl -sL https://deb.nodesource.com/setup_12.x | bash \ - && apt-get install -y nodejs - -#BLACKFIRE -RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ - && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \ - && mkdir -p /tmp/blackfire \ - && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \ - && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \ - && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \ - && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz \ - && mkdir -p /tmp/blackfire \ - && curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux_static/amd64 | tar zxp -C /tmp/blackfire \ - && mv /tmp/blackfire/blackfire /usr/bin/blackfire \ - && rm -Rf /tmp/blackfire - -#COMPOSER -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer1 --1\ - && apt -qy install $PHPIZE_DEPS && mkdir /${_HOME_DIRECTORY}/.composer \ - -#COMPOSER 2 (additional) -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer2 --2 - -#COMPOSER link (2 is default for PHP 8) -RUN ln -s /usr/local/bin/composer2 /usr/local/bin/composer - -#XDEBUG -ARG M2D_XDEBUG_IDE_KEY=PHPSTORM -ENV M2D_XDEBUG_IDE_KEY=${M2D_XDEBUG_IDE_KEY:-PHPSTORM} -RUN pecl install xdebug-3.0.1 \ - && echo ";zend_extension=xdebug.so" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.max_nesting_level=10000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.idekey=$M2D_XDEBUG_IDE_KEY" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -COPY ./misc/xdebug-php.sh /usr/local/bin/xdebug-php.sh -COPY ./misc/composer-link.sh /usr/local/bin/composer-link.sh - -#CODESNIFFER -RUN pear install PHP_CodeSniffer \ - && mkdir /usr/local/magento-ecg-code-sniffer \ - && cd /usr/local/magento-ecg-code-sniffer/ && composer require magento-ecg/coding-standard \ - && phpcs --config-set installed_paths /usr/local/magento-ecg-code-sniffer/vendor/magento-ecg/coding-standard - -#SENDMAIL -RUN echo "sendmail_path=/usr/bin/msmtp -t" >> /usr/local/etc/php/conf.d/mailcatcher.ini \ - && echo "memory_limit=4G" >> /usr/local/etc/php/conf.d/custom.ini \ - && echo "max_input_vars=10000" >> /usr/local/etc/php/conf.d/custom.ini \ - && echo "account default" >> /etc/msmtprc \ - && echo "host mailcatcher" >> /etc/msmtprc \ - && echo "port 1025" >> /etc/msmtprc \ - && echo "auto_from on" >> /etc/msmtprc - -#SSH -COPY ./etc/ssh ${_HOME_DIRECTORY}/.ssh -ADD ./etc/ssh/magento2docker.pub ${_HOME_DIRECTORY}/.ssh/authorized_keys -RUN chmod -R 700 ${_HOME_DIRECTORY}/.ssh \ - && echo " ServerAliveInterval 30" >> /etc/ssh/ssh_config \ - && echo " TCPKeepAlive yes" >> /etc/ssh/ssh_config -COPY ./etc/ssh /root/.ssh -ADD ./etc/ssh/magento2docker.pub /root/.ssh/authorized_keys -RUN chmod -R 700 /root/.ssh \ - && echo "Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc" >> /etc/ssh/sshd_config \ - && touch /root/.ssh/known_hosts \ - && ssh-keygen -F github.com || ssh-keyscan github.com >> /root/.ssh/known_hosts - -#APACHE -RUN a2enmod ssl \ - && a2ensite default-ssl.conf \ - && a2enmod vhost_alias \ - && a2enmod proxy \ - && a2enmod rewrite \ - && chown -R ${_USER}:${_USER} /var/www/html -RUN chown -R ${_USER}:${_USER} ${_HOME_DIRECTORY} - -#BASH COMPLETION -USER magento -RUN echo "source /etc/bash_completion" >> ${_HOME_DIRECTORY}/.bashrc - -#MAGENTO CLI -RUN curl -sS https://accounts.magento.cloud/cli/installer | php -USER root - -#TUNE ENVIRONMENT -RUN echo "Defaults timestamp_timeout=-1" >> /etc/sudoers - -#FLAG TO NOT CACHE ANYTHING FROM THIS POINT, details: https://github.com/docker/docker/issues/1996#issuecomment-185872769 -ARG CACHEBUST=1 - -#CUSTOM CONFIGURATIONS -COPY ./etc/git/gitconfig ${_HOME_DIRECTORY}/.gitconfig -COPY ./etc/composer/auth.json /${_HOME_DIRECTORY}/.composer/auth.json -COPY ./misc/* /usr/local/bin/ -COPY ./etc/apache/envvars /etc/apache2/envvars -COPY ./etc/apache /etc/apache2/sites-enabled/ -COPY ./etc/fixtures /etc/fixtures -COPY ./etc/m2install/.m2install.conf* ${_HOME_DIRECTORY}/ - -#MAGENTO TOOLS -RUN curl -o /usr/local/bin/m2install.sh https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install.sh \ - && curl -o /etc/bash_completion.d/m2install-bash-completion https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install-bash-completion \ - && curl -o /usr/local/bin/n98-magerun2 https://files.magerun.net/n98-magerun2.phar \ - && curl -o /etc/bash_completion.d/n98-magerun2.phar.bash https://raw.githubusercontent.com/netz98/n98-magerun2/master/res/autocompletion/bash/n98-magerun2.phar.bash \ - && curl -o /usr/local/bin/m2-convert-for-composer https://raw.githubusercontent.com/isitnikov/m2-convert-patch-for-composer-install/master/convert-for-composer.php \ - && curl -o /etc/bash_completion.d/magento2-bash-completion https://raw.githubusercontent.com/yvoronoy/magento2-bash-completion/master/magento2-bash-completion-enterprise \ - && curl -L -o /tmp/teleport.tar.gz https://github.com/gravitational/teleport/releases/download/v1.3.2/teleport-v1.3.2-linux-amd64-bin.tar.gz \ - && tar -xf /tmp/teleport.tar.gz -C /tmp/ \ - && make -C /tmp/teleport/ \ - && git ls-remote git@github.com:magento-sparta/ee-support-tools.git 2>&1 | if grep -q HEAD; then git clone git@github.com:magento-sparta/ee-support-tools.git /usr/local/src/ee-support-tools; else echo; fi \ - && if [ -d /usr/local/src/ee-support-tools ]; then ln -s /usr/local/src/ee-support-tools/cloud-teleport/cloud-teleport /usr/local/bin/cloud-teleport; else echo; fi - -RUN chmod +x /usr/local/bin/* - -CMD service ssh start; apache2-foreground diff --git a/env/etc/php/8.1/Dockerfile b/env/etc/php/8.1/Dockerfile deleted file mode 100644 index e31c9ca..0000000 --- a/env/etc/php/8.1/Dockerfile +++ /dev/null @@ -1,173 +0,0 @@ -#PHP IMAGE -FROM php:8.1-apache-bullseye - -#SETTING UP THE SYSTEM -RUN apt-get update \ - && apt-get install -y \ - apt-utils \ - wget \ - libwebp-dev \ - libxpm-dev \ - libfreetype6-dev \ - libjpeg62-turbo-dev \ - libmcrypt-dev \ - libpng-dev \ - libxslt-dev \ - libicu-dev \ - mariadb-client \ - pv \ - vim \ - nano \ - bash-completion \ - openssh-server \ - ssl-cert \ - msmtp \ - sudo \ - dnsutils \ - iputils-ping \ - iputils-tracepath \ - host \ - strace \ - telnet \ - unzip \ - gnupg \ - gcc \ - lsof \ - libsodium-dev \ - libzip-dev \ - && apt-get update \ - && apt-get clean all - -#CREATE USER -ENV _USER=magento -ENV _HOME_DIRECTORY=/home/${_USER} -RUN useradd -m ${_USER} && echo "${_USER}:${_USER}" | chpasswd && chsh ${_USER} -s /bin/bash && adduser ${_USER} sudo - -#PHP EXTENSIONS -RUN docker-php-ext-install -j$(nproc) soap sockets \ - && docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp \ - && docker-php-ext-install -j$(nproc) gd bcmath pdo_mysql xsl intl zip - -#GIT -RUN apt-get update \ - && apt-get install -y git \ - && apt-get clean all - -#NODEJS -RUN curl -sL https://deb.nodesource.com/setup_12.x | bash \ - && apt-get install -y nodejs - -#BLACKFIRE -RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ - && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \ - && mkdir -p /tmp/blackfire \ - && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \ - && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \ - && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \ - && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz \ - && mkdir -p /tmp/blackfire \ - && curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux_static/amd64 | tar zxp -C /tmp/blackfire \ - && mv /tmp/blackfire/blackfire /usr/bin/blackfire \ - && rm -Rf /tmp/blackfire - -#COMPOSER -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer1 --1 \ - && apt -qy install $PHPIZE_DEPS && mkdir /${_HOME_DIRECTORY}/.composer - -#COMPOSER 2 (additional) -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer2 --2 - -#COMPOSER link (2 is default for PHP 8.1) -RUN ln -s /usr/local/bin/composer2 /usr/local/bin/composer - -#XDEBUG -ARG M2D_XDEBUG_IDE_KEY=PHPSTORM -ENV M2D_XDEBUG_IDE_KEY=${M2D_XDEBUG_IDE_KEY:-PHPSTORM} -RUN pecl install xdebug \ - && echo ";zend_extension=xdebug.so" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.max_nesting_level=10000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.idekey=$M2D_XDEBUG_IDE_KEY" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -COPY ./misc/xdebug-php.sh /usr/local/bin/xdebug-php.sh - -# COMPOSER VERSION SWITCHER -COPY ./misc/composer-link.sh /usr/local/bin/composer-link.sh - -#CODESNIFFER -RUN pear install PHP_CodeSniffer \ - && mkdir /usr/local/magento-ecg-code-sniffer \ - && cd /usr/local/magento-ecg-code-sniffer/ && composer require magento-ecg/coding-standard \ - && phpcs --config-set installed_paths /usr/local/magento-ecg-code-sniffer/vendor/magento-ecg/coding-standard - -#SENDMAIL -RUN echo "sendmail_path=/usr/bin/msmtp -t" >> /usr/local/etc/php/conf.d/mailcatcher.ini \ - && echo "memory_limit=2G" >> /usr/local/etc/php/conf.d/custom.ini \ - && echo "max_input_vars=10000" >> /usr/local/etc/php/conf.d/custom.ini \ - && echo "account default" >> /etc/msmtprc \ - && echo "host mailcatcher" >> /etc/msmtprc \ - && echo "port 1025" >> /etc/msmtprc \ - && echo "auto_from on" >> /etc/msmtprc - -#SSH -COPY ./etc/ssh ${_HOME_DIRECTORY}/.ssh -ADD ./etc/ssh/magento2docker.pub ${_HOME_DIRECTORY}/.ssh/authorized_keys -RUN chmod -R 700 ${_HOME_DIRECTORY}/.ssh \ - && echo " ServerAliveInterval 30" >> /etc/ssh/ssh_config \ - && echo " TCPKeepAlive yes" >> /etc/ssh/ssh_config -COPY ./etc/ssh /root/.ssh -ADD ./etc/ssh/magento2docker.pub /root/.ssh/authorized_keys -RUN chmod -R 700 /root/.ssh \ - && echo "Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc" >> /etc/ssh/sshd_config \ - && touch /root/.ssh/known_hosts \ - && ssh-keygen -F github.com || ssh-keyscan github.com >> /root/.ssh/known_hosts - -#APACHE -RUN a2enmod ssl \ - && a2ensite default-ssl.conf \ - && a2enmod vhost_alias \ - && a2enmod proxy \ - && a2enmod rewrite \ - && chown -R ${_USER}:${_USER} /var/www/html -RUN chown -R ${_USER}:${_USER} ${_HOME_DIRECTORY} - -#BASH COMPLETION -USER magento -RUN echo "source /etc/bash_completion" >> ${_HOME_DIRECTORY}/.bashrc - -#MAGENTO CLI -RUN curl -sS https://accounts.magento.cloud/cli/installer | php -USER root - -#TUNE ENVIRONMENT -RUN echo "Defaults timestamp_timeout=-1" >> /etc/sudoers - -#FLAG TO NOT CACHE ANYTHING FROM THIS POINT, details: https://github.com/docker/docker/issues/1996#issuecomment-185872769 -ARG CACHEBUST=1 - -#CUSTOM CONFIGURATIONS -COPY ./etc/git/gitconfig ${_HOME_DIRECTORY}/.gitconfig -COPY ./etc/composer/auth.json /${_HOME_DIRECTORY}/.composer/auth.json -COPY ./misc/* /usr/local/bin/ -COPY ./etc/apache/envvars /etc/apache2/envvars -COPY ./etc/apache /etc/apache2/sites-enabled/ -COPY ./etc/fixtures /etc/fixtures -COPY ./etc/m2install/.m2install.conf* ${_HOME_DIRECTORY}/ - -#MAGENTO TOOLS -RUN curl -o /usr/local/bin/m2install.sh https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install.sh \ - && curl -o /etc/bash_completion.d/m2install-bash-completion https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install-bash-completion \ - && curl -o /usr/local/bin/n98-magerun2 https://files.magerun.net/n98-magerun2.phar \ - && curl -o /etc/bash_completion.d/n98-magerun2.phar.bash https://raw.githubusercontent.com/netz98/n98-magerun2/master/res/autocompletion/bash/n98-magerun2.phar.bash \ - && curl -o /usr/local/bin/m2-convert-for-composer https://raw.githubusercontent.com/isitnikov/m2-convert-patch-for-composer-install/master/convert-for-composer.php \ - && curl -o /etc/bash_completion.d/magento2-bash-completion https://raw.githubusercontent.com/yvoronoy/magento2-bash-completion/master/magento2-bash-completion-enterprise \ - && curl -L -o /tmp/teleport.tar.gz https://github.com/gravitational/teleport/releases/download/v1.3.2/teleport-v1.3.2-linux-amd64-bin.tar.gz \ - && tar -xf /tmp/teleport.tar.gz -C /tmp/ \ - && make -C /tmp/teleport/ \ - && git ls-remote git@github.com:magento-sparta/ee-support-tools.git 2>&1 | if grep -q HEAD; then git clone git@github.com:magento-sparta/ee-support-tools.git /usr/local/src/ee-support-tools; else echo; fi \ - && if [ -d /usr/local/src/ee-support-tools ]; then ln -s /usr/local/src/ee-support-tools/cloud-teleport/cloud-teleport /usr/local/bin/cloud-teleport; else echo; fi - -RUN chmod +x /usr/local/bin/* - -CMD service ssh start; apache2-foreground diff --git a/env/etc/php/Dockerfile b/env/etc/php/Dockerfile deleted file mode 100644 index 236b6f7..0000000 --- a/env/etc/php/Dockerfile +++ /dev/null @@ -1,257 +0,0 @@ -## To build image for any PHP version, just set version in the M2D_PHP_VERSION variable. -## It can be in .env file or in your terminal with export M2D_PHP_VERSION=7.4 - -## BASE PHP IMAGE - COMMON FOR ALL PHP VERSIONS ## -ARG M2D_PHP_VERSION='8.1' -FROM php:${M2D_PHP_VERSION}-apache-bullseye AS php_base_ - -# SETTING UP THE SYSTEM: -RUN apt-get update \ - && apt-get install -y \ - apt-utils \ - wget \ - libwebp-dev \ - libxpm-dev \ - libfreetype6-dev \ - libjpeg62-turbo-dev \ - libmcrypt-dev \ - libpng-dev \ - libxslt-dev \ - libicu-dev \ - mariadb-client \ - pv \ - vim \ - nano \ - bash-completion \ - openssh-server \ - ssl-cert \ - msmtp \ - sudo \ - dnsutils \ - iputils-ping \ - iputils-tracepath \ - host \ - strace \ - telnet \ - unzip \ - gnupg \ - gcc \ - lsof \ - libsodium-dev \ - libzip-dev \ - parallel \ - git \ - && apt-get update \ - && apt-get clean all - -# CREATE USER: -ENV _USER=magento -ENV _HOME_DIRECTORY=/home/${_USER} -RUN useradd -m ${_USER} && echo "${_USER}:${_USER}" | chpasswd && chsh ${_USER} -s /bin/bash && adduser ${_USER} sudo - -# COMMON PHP EXTENSIONS: -RUN docker-php-ext-install -j$(nproc) iconv soap sockets \ - && docker-php-ext-install -j$(nproc) bcmath pdo_mysql xsl intl zip - -# NODEJS: -RUN curl -sL https://deb.nodesource.com/setup_12.x | bash \ - && apt-get install -y nodejs - -# INSTALL COMPOSER 1 AND COMPOSER 2: -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer1 --1 \ - && apt -qy install $PHPIZE_DEPS && mkdir /${_HOME_DIRECTORY}/.composer \ - && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer2 --2 - -# COMPOSER VERSION SWITCHER: -COPY ./misc/composer-link.sh /usr/local/bin/composer-link.sh - -# XDEBUG enable/disable script -COPY ./misc/xdebug-php.sh /usr/local/bin/xdebug-php.sh -COPY ./misc/prepare-mtf.sh /usr/local/bin/prepare-mtf.sh - -# CODESNIFFER: -# RUN pear install PHP_CodeSniffer \ -# && mkdir /usr/local/magento-ecg-code-sniffer \ -# && cd /usr/local/magento-ecg-code-sniffer/ && composer require magento-ecg/coding-standard \ -# && phpcs --config-set installed_paths /usr/local/magento-ecg-code-sniffer/vendor/magento-ecg/coding-standard - -# SENDMAIL: -RUN echo "sendmail_path=/usr/bin/msmtp -t" >> /usr/local/etc/php/conf.d/mailcatcher.ini \ - && echo "memory_limit=2G" >> /usr/local/etc/php/conf.d/custom.ini \ - && echo "max_input_vars=10000" >> /usr/local/etc/php/conf.d/custom.ini \ - && echo "account default" >> /etc/msmtprc \ - && echo "host mailcatcher" >> /etc/msmtprc \ - && echo "port 1025" >> /etc/msmtprc \ - && echo "auto_from on" >> /etc/msmtprc - -# SSH: -COPY ./etc/ssh ${_HOME_DIRECTORY}/.ssh -ADD ./etc/ssh/magento2docker.pub ${_HOME_DIRECTORY}/.ssh/authorized_keys -RUN chmod -R 700 ${_HOME_DIRECTORY}/.ssh \ - && echo " ServerAliveInterval 30" >> /etc/ssh/ssh_config \ - && echo " TCPKeepAlive yes" >> /etc/ssh/ssh_config -COPY ./etc/ssh /root/.ssh -ADD ./etc/ssh/magento2docker.pub /root/.ssh/authorized_keys -RUN chmod -R 700 /root/.ssh \ - && echo "Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc" >> /etc/ssh/sshd_config \ - && touch /root/.ssh/known_hosts \ - && ssh-keygen -F github.com || ssh-keyscan github.com >> /root/.ssh/known_hosts - -# APACHE: -RUN a2enmod ssl \ - && a2ensite default-ssl.conf \ - && a2enmod vhost_alias \ - && a2enmod proxy \ - && a2enmod rewrite \ - && chown -R ${_USER}:${_USER} /var/www/html -RUN chown -R ${_USER}:${_USER} ${_HOME_DIRECTORY} - -# BASH COMPLETION: -USER magento -RUN echo "source /etc/bash_completion" >> ${_HOME_DIRECTORY}/.bashrc - -# MAGENTO CLI: -RUN curl -sS https://accounts.magento.cloud/cli/installer | php -USER root - -# TUNE ENVIRONMENT: -RUN echo "Defaults timestamp_timeout=-1" >> /etc/sudoers - -# FLAG TO NOT CACHE ANYTHING FROM THIS POINT, details: https://github.com/docker/docker/issues/1996#issuecomment-185872769 -ARG CACHEBUST=1 - -# CUSTOM CONFIGURATIONS: -COPY ./etc/git/gitconfig ${_HOME_DIRECTORY}/.gitconfig -COPY ./etc/composer/auth.json /${_HOME_DIRECTORY}/.composer/auth.json -COPY ./misc/* /usr/local/bin/ -COPY ./etc/apache/envvars /etc/apache2/envvars -COPY ./etc/apache /etc/apache2/sites-enabled/ -COPY ./etc/fixtures /etc/fixtures -COPY ./etc/m2install/.m2install.conf* ${_HOME_DIRECTORY}/ - -# MAGENTO TOOLS: -RUN curl -o /usr/local/bin/m2install.sh https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install.sh \ - && curl -o /etc/bash_completion.d/m2install-bash-completion https://raw.githubusercontent.com/yvoronoy/m2install/master/m2install-bash-completion \ - && curl -o /usr/local/bin/n98-magerun2 https://files.magerun.net/n98-magerun2.phar \ - && curl -o /etc/bash_completion.d/n98-magerun2.phar.bash https://raw.githubusercontent.com/netz98/n98-magerun2/master/res/autocompletion/bash/n98-magerun2.phar.bash \ - && curl -o /usr/local/bin/m2-convert-for-composer https://raw.githubusercontent.com/isitnikov/m2-convert-patch-for-composer-install/master/convert-for-composer.php \ - && curl -o /etc/bash_completion.d/magento2-bash-completion https://raw.githubusercontent.com/yvoronoy/magento2-bash-completion/master/magento2-bash-completion-enterprise \ - && curl -L -o /tmp/teleport.tar.gz https://github.com/gravitational/teleport/releases/download/v1.3.2/teleport-v1.3.2-linux-amd64-bin.tar.gz \ - && tar -xf /tmp/teleport.tar.gz -C /tmp/ \ - && make -C /tmp/teleport/ \ - && git ls-remote git@github.com:magento-sparta/ee-support-tools.git 2>&1 | if grep -q HEAD; then git clone git@github.com:magento-sparta/ee-support-tools.git /usr/local/src/ee-support-tools; else echo; fi \ - && if [ -d /usr/local/src/ee-support-tools ]; then ln -s /usr/local/src/ee-support-tools/cloud-teleport/cloud-teleport /usr/local/bin/cloud-teleport; else echo; fi - -RUN chmod +x /usr/local/bin/* -## END OF BASE IMAGE ## - - -## BASE IMAGE WITH BLACKFIRE "" -FROM php_base_ AS php_base_blackfire - -# BLACKFIRE: -RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ - && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \ - && mkdir -p /tmp/blackfire \ - && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \ - && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \ - && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \ - && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz \ - && mkdir -p /tmp/blackfire \ - && curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux_static/amd64 | tar zxp -C /tmp/blackfire \ - && mv /tmp/blackfire/blackfire /usr/bin/blackfire \ - && rm -Rf /tmp/blackfire -## END OF BASE IMAGE WITH BLACKFIRE ## - - -## IMAGE ADJUSTMENTS FOR PHP 7.x ## -ARG M2D_BLACKFIRE='' -FROM php_base_${M2D_BLACKFIRE} AS php7x - -# XDEBUG: -ARG M2D_XDEBUG_IDE_KEY=PHPSTORM -ENV M2D_XDEBUG_IDE_KEY=${M2D_XDEBUG_IDE_KEY:-PHPSTORM} -RUN pecl install xdebug-2.9.0 \ - && echo ";zend_extension=xdebug.so" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.idekey=$M2D_XDEBUG_IDE_KEY" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.remote_autostart=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.max_nesting_level=10000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo ";xdebug.remote_log = /var/www/html/xdebug.log" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo ";xdebug.remote_log_level = 10" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo ";xdebug.remote_port = 9003" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini - -# ADDITIONAL EXTENSIONS -RUN pecl install libsodium-2.0.23 -## END OF IMAGE ADJUSTMENTS FOR PHP 7.x ## - - -## IMAGE ADJUSTEMNTS FOR PHP 8.x -ARG M2D_BLACKFIRE='' -FROM php_base_${M2D_BLACKFIRE} AS php8x - -# PHP EXTENSIONS GD: -RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp \ - && docker-php-ext-install -j$(nproc) gd - -# COMPOSER 2 LINKED AS DEFAULT: -RUN ln -s /usr/local/bin/composer2 /usr/local/bin/composer - -# XDEBUG: -ARG M2D_XDEBUG_IDE_KEY=PHPSTORM -ENV M2D_XDEBUG_IDE_KEY=${M2D_XDEBUG_IDE_KEY:-PHPSTORM} -RUN pecl install xdebug \ - && echo ";zend_extension=xdebug.so" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.idekey=$M2D_XDEBUG_IDE_KEY" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo "xdebug.max_nesting_level=10000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo ";xdebug.log = /var/www/html/xdebug.log" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo ";xdebug.log_level = 10" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \ - && echo ";xdebug.client_port = 9003" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini -## END OF IMAGE ADJUSTMENTS FOR PHP 8.x ## - - -## IMAGE ADJUSTEMNTS FOR PHP 7.3 ## -FROM php7x AS php_7.3 -# PHP EXTENSIONS GD: -RUN docker-php-ext-configure gd --with-gd --with-webp-dir \ - --with-png-dir --with-zlib-dir --with-xpm-dir \ - --with-freetype-dir=/usr/include/freetype2/ --with-jpeg-dir=/usr/include/ \ - && docker-php-ext-install -j$(nproc) gd -## END OF IMAGE ADJUSTMENTS FOR PHP 7.3 ## - - -## IMAGE ADJUSTEMNTS FOR PHP 7.4 ## -FROM php7x AS php_7.4 -# PHP EXTENSIONS GD: -RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp \ - && docker-php-ext-install -j$(nproc) gd -## END OF IMAGE ADJUSTMENTS FOR PHP 7.4 ## - - -## IMAGE ADJUSTEMNTS FOR PHP 8.0 ## -FROM php8x AS php_8.0 - -# ADDITIONAL EXTENSIONS -RUN pecl install libsodium-2.0.23 -## END OF IMAGE ADJUSTMENTS FOR PHP 8.0 ## - - -## IMAGE ADJUSTEMNTS FOR PHP 8.1 ## -FROM php8x AS php_8.1 -## END OF IMAGE ADJUSTMENTS FOR PHP 8.1 ## - - -## IMAGE ADJUSTEMNTS FOR PHP 8.2 ## -FROM php8x AS php_8.2 -## END OF IMAGE ADJUSTMENTS FOR PHP 8.2 ## - - -## TARGET IMAGE ADJUSTEMNTS ## -ARG M2D_PHP_VERSION='8.1' -FROM php_${M2D_PHP_VERSION} AS php_base - -CMD service ssh start; apache2-foreground From 33cd506454f30a8bd6c86087c16f00ded1f83793 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 24 Mar 2023 11:08:12 +0100 Subject: [PATCH 15/31] Added .gitignore to git config directory of Apache container --- services/web-servers/apache/etc/git/.gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 services/web-servers/apache/etc/git/.gitignore diff --git a/services/web-servers/apache/etc/git/.gitignore b/services/web-servers/apache/etc/git/.gitignore new file mode 100644 index 0000000..d5479b8 --- /dev/null +++ b/services/web-servers/apache/etc/git/.gitignore @@ -0,0 +1,3 @@ +* +!.gitignore +!gitconfig.example From 42eb219eed6d4eee29c07977d9a206463b5b9f78 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 24 Mar 2023 23:24:02 +0100 Subject: [PATCH 16/31] Refactor of RabbitMQ container - part 2 --- .env.example | 4 ++-- docker-compose.yml | 4 ++-- services/message-brokers/Dockerfile | 7 +++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index b5577bd..ff66764 100644 --- a/.env.example +++ b/.env.example @@ -78,8 +78,8 @@ M2D_ENABLE_MESSAGE_BROKER='no' # - 'rabbitmq' for RabbitMQ [https://www.rabbitmq.com/] M2D_MESSAGE_BROKER_VENDOR='rabbitmq' # Set expected version of the message broker: -# - '3.8-management' -M2D_MESSAGE_BROKER_VERSION:'3.8-management' +# - RabbitMQ versions: 3.8, 3.9 +M2D_MESSAGE_BROKER_VERSION='3.8' # Set the port number used by a broker: M2D_PORT_FOR_MESSAGE_BROKER='15672' diff --git a/docker-compose.yml b/docker-compose.yml index ba9a091..b374857 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -72,8 +72,8 @@ services: args: - M2D_ENABLE_MESSAGE_BROKER=${M2D_ENABLE_MESSAGE_BROKER:-no} - M2D_MESSAGE_BROKER_VENDOR=${M2D_MESSAGE_BROKER_VENDOR:-rabbitmq} - - M2D_MESSAGE_BROKER_VERSION=${M2D_MESSAGE_BROKER_VERSION:-'3.8-management'} - container_name: magento2messagebroker + - M2D_MESSAGE_BROKER_VERSION=${M2D_MESSAGE_BROKER_VERSION:-3.8} + container_name: m2d-messagebroker restart: unless-stopped ports: - "${M2D_PORT_FOR_MESSAGE_BROKER:-15672}:15672" diff --git a/services/message-brokers/Dockerfile b/services/message-brokers/Dockerfile index b0d832f..8d32c4e 100644 --- a/services/message-brokers/Dockerfile +++ b/services/message-brokers/Dockerfile @@ -1,11 +1,14 @@ ARG M2D_ENABLE_MESSAGE_BROKER='no' ARG M2D_MESSAGE_BROKER_VENDOR='rabbitmq' -ARG M2D_MESSAGE_BROKER_VERSION='3.8-management' +ARG M2D_MESSAGE_BROKER_VERSION='3.8' FROM scratch as m2d_message_broker_no COPY tools/dummy/dummy ./ CMD ["/dummy"] -FROM ${M2D_MESSAGE_BROKER_VENDOR}:${M2D_MESSAGE_BROKER_VERSION} AS m2d_message_broker_yes +FROM rabbitmq:3.8-management AS m2d_message_broker_rabbitmq_3.8 +FROM rabbitmq:3.9-management AS m2d_message_broker_rabbitmq_3.9 + +FROM m2d_message_broker_${M2D_MESSAGE_BROKER_VENDOR}_${M2D_MESSAGE_BROKER_VERSION} AS m2d_message_broker_yes FROM m2d_message_broker_${M2D_ENABLE_MESSAGE_BROKER} AS m2d_message_broker From 36faa2ba164d3b28b9a758edc16165300066e9ee Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 24 Mar 2023 23:26:46 +0100 Subject: [PATCH 17/31] Refactor of Redis container - part 2 --- .env.example | 3 ++- docker-compose.yml | 10 +++++----- services/db-cache/Dockerfile | 7 ++++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.env.example b/.env.example index ff66764..9b62090 100644 --- a/.env.example +++ b/.env.example @@ -101,4 +101,5 @@ M2D_ENABLE_DB_CACHE='no' # - 'redis' for Redis [https://redis.io/] M2D_DB_CACHE_VENDOR='redis' # Set expected version of the db cache: -M2D_DB_CACHE_VERSION='6.0' +# - Redis versions: 5, 6, 6.2, 7 +M2D_DB_CACHE_VERSION='6.2' diff --git a/docker-compose.yml b/docker-compose.yml index b374857..7214afb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -95,13 +95,13 @@ services: db_cache: build: context: . - dockerfile: services/db-cache/Dokerfile + dockerfile: services/db-cache/Dockerfile target: m2d_db_cache args: - - M2D_ENABLE_DB_CACHE:${M2D_ENABLE_DB_CACHE:-no} - - M2D_DB_CACHE_VENDOR:${M2D_DB_CACHE_VENDOR:-redis} - - M2D_DB_CACHE_VERSION:${M2D_DB_CACHE_VERSION:-'6.0'} - container_name: magento2dbcache + - M2D_ENABLE_DB_CACHE=${M2D_ENABLE_DB_CACHE:-no} + - M2D_DB_CACHE_VENDOR=${M2D_DB_CACHE_VENDOR:-redis} + - M2D_DB_CACHE_VERSION=${M2D_DB_CACHE_VERSION:-6.0} + container_name: m2d-dbcache restart: unless-stopped mailcatcher: diff --git a/services/db-cache/Dockerfile b/services/db-cache/Dockerfile index 4b994e5..67f8da4 100644 --- a/services/db-cache/Dockerfile +++ b/services/db-cache/Dockerfile @@ -6,6 +6,11 @@ FROM scratch as m2d_db_cache_no COPY tools/dummy/dummy ./ CMD ["/dummy"] -FROM ${M2D_DB_CACHE_VENDOR}:${M2D_DB_CACHE_VERSION} AS m2d_db_cache_yes +FROM redis:5.0-bullseye AS m2d_db_cache_yes_redis_5 +FROM redis:6.0-bullseye AS m2d_db_cache_yes_redis_6 +FROM redis:6.2-bullseye AS m2d_db_cache_yes_redis_6.2 +FROM redis:7.0-bullseye AS m2d_db_cache_yes_redis_7 + +FROM m2d_db_cache_yes_${M2D_DB_CACHE_VENDOR}_${M2D_DB_CACHE_VERSION} AS m2d_db_cache_yes FROM m2d_db_cache_${M2D_ENABLE_DB_CACHE} AS m2d_db_cache From 0839db2054edb77a5fd2eac3d27f02f9e4f6403c Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 24 Mar 2023 23:28:02 +0100 Subject: [PATCH 18/31] Refactor of Varnish container - part 2 --- .env.example | 3 ++- docker-compose.yml | 10 +++++----- services/web-cache/Dockerfile | 12 +++++++++++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.env.example b/.env.example index 9b62090..823bd7e 100644 --- a/.env.example +++ b/.env.example @@ -90,7 +90,8 @@ M2D_ENABLE_WEB_CACHE='no' # - 'varnish' for Varnish HTTP Cache [https://varnish-cache.org/] M2D_WEB_CACHE_VENDOR='varnish' # Set expected version of the web cache: -M2D_WEB_CACHE_VERSION='6.5' +# - Varnish versions: 6, 6.0, 6.2, 6.4, 6.5, 7, 7.0, 7.1 +M2D_WEB_CACHE_VERSION='6' # Set the port number used by web cache: M2D_PORT_FOR_WEB_CACHE='8080' diff --git a/docker-compose.yml b/docker-compose.yml index 7214afb..2a66867 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -81,13 +81,13 @@ services: web_cache: build: context: . - dockerfile: services/web-cache/Dokerfile + dockerfile: services/web-cache/Dockerfile target: m2d_web_cache args: - - M2D_ENABLE_WEB_CACHE:${M2D_ENABLE_WEB_CACHE:-no} - - M2D_WEB_CACHE_VENDOR:${M2D_WEB_CACHE_VENDOR:-varnish} - - M2D_WEB_CACHE_VERSION:${M2D_WEB_CACHE_VERSION:-'6.5'} - container_name: magento2webcache + - M2D_ENABLE_WEB_CACHE=${M2D_ENABLE_WEB_CACHE:-no} + - M2D_WEB_CACHE_VENDOR=${M2D_WEB_CACHE_VENDOR:-varnish} + - M2D_WEB_CACHE_VERSION=${M2D_WEB_CACHE_VERSION:-6} + container_name: m2d-webcache restart: unless-stopped ports: - "${M2D_PORT_FOR_WEB_CACHE:-8080}:8080" diff --git a/services/web-cache/Dockerfile b/services/web-cache/Dockerfile index c3a9775..6309dd8 100644 --- a/services/web-cache/Dockerfile +++ b/services/web-cache/Dockerfile @@ -6,6 +6,16 @@ FROM scratch as m2d_web_cache_no COPY tools/dummy/dummy ./ CMD ["/dummy"] -FROM ${M2D_WEB_CACHE_VENDOR}:${M2D_WEB_CACHE_VERSION} AS m2d_web_cache_yes +FROM varnish:6.0 AS m2d_web_cache_yes_varnish_6.0 +FROM --platform=linux/amd64 varnish:6.2 AS m2d_web_cache_yes_varnish_6.2 +FROM --platform=linux/amd64 varnish:6.4 AS m2d_web_cache_yes_varnish_6.4 +FROM --platform=linux/amd64 varnish:6.5 AS m2d_web_cache_yes_varnish_6.5 +FROM varnish:7.0 AS m2d_web_cache_yes_varnish_7.0 +FROM varnish:7.1 AS m2d_web_cache_yes_varnish_7.1 + +FROM m2d_web_cache_yes_varnish_7.0 AS m2d_web_cache_yes_varnish_7 +FROM m2d_web_cache_yes_varnish_6.5 AS m2d_web_cache_yes_varnish_6 + +FROM m2d_web_cache_yes_${M2D_WEB_CACHE_VENDOR}_${M2D_WEB_CACHE_VERSION} AS m2d_web_cache_yes FROM m2d_web_cache_${M2D_ENABLE_WEB_CACHE} AS m2d_web_cache From 1e4b884e262a32ad13eac953317990e616268942 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 24 Mar 2023 23:29:45 +0100 Subject: [PATCH 19/31] Refactor of ElasticSearch and Opensearch containers - part 2 --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 2a66867..f4762d1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -56,8 +56,8 @@ services: args: - M2D_ENABLE_SEARCH_ENGINE=${M2D_ENABLE_SEARCH_ENGINE:-yes} - M2D_SEARCH_ENGINE_VENDOR=${M2D_SEARCH_ENGINE_VENDOR:-elasticsearch} - - M2D_SEARCH_ENGINE_VERSION=${M2D_SEARCH_ENGINE_VERSION:7} - container_name: magento2searchengine + - M2D_SEARCH_ENGINE_VERSION=${M2D_SEARCH_ENGINE_VERSION:-7} + container_name: m2d-searchengine environment: - "ES_JAVA_OPTS=-Xms128m -Xmx1g" - "OPENSEARCH_JAVA_OPTS=-Xms128m -Xmx1g" From a5eafa412b0ace25cc8e5bb3613966696ed94c9f Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 24 Mar 2023 23:30:48 +0100 Subject: [PATCH 20/31] Refactor of Database container - part 2 --- docker-compose.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index f4762d1..8e71ade 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,15 +28,16 @@ services: - root-volume:/root cap_add: - "SYS_PTRACE" + db: build: context: . dockerfile: services/db-engines/Dockerfile target: m2d_db_engine args: - - M2D_DB_ENGINE_VENDOR:${M2D_DB_ENGINE_VENDOR:-mariadb} - - M2D_DB_ENGINE_VERSION:${M2D_DB_ENGINE_VERSION:-10} - container_name: magento2db + - M2D_DB_ENGINE_VENDOR=${M2D_DB_ENGINE_VENDOR:-mariadb} + - M2D_DB_ENGINE_VERSION=${M2D_DB_ENGINE_VERSION:-10} + container_name: m2d-db restart: unless-stopped environment: MYSQL_DATABASE: magento From da65379375a25df67678e3342d3132f1c7b85e77 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 24 Mar 2023 23:31:39 +0100 Subject: [PATCH 21/31] Refactor of Mailcatcher container - part 2 --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 8e71ade..676d02c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -112,7 +112,7 @@ services: target: m2d_mailcatcher args: - M2D_ENABLE_MAILCATCHER=${M2D_ENABLE_MAILCATCHER:-no} - container_name: magento2mailcatcher + container_name: m2d-mailcatcher ports: - "${M2D_PORT_FOR_MAILCATCHER:-1080}:1080" From 797a9ffafaa799ef7ccceb12e6bd2445a817f3c8 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 24 Mar 2023 23:32:15 +0100 Subject: [PATCH 22/31] Refactor of Blackfire container - part 2 --- docker-compose.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 676d02c..76188ce 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -122,7 +122,8 @@ services: dockerfile: tools/blackfire/Dockerfile target: m2d_blackfire args: - M2D_ENABLE_BLACKFIRE=${M2D_ENABLE_BLACKFIRE:-no} + - M2D_ENABLE_BLACKFIRE=${M2D_ENABLE_BLACKFIRE:-no} + container_name: m2d-blackfire environment: - BLACKFIRE_SERVER_ID - BLACKFIRE_SERVER_TOKEN From 962628a1aba88f7f95ce816cf5113d79c1b0703f Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 24 Mar 2023 23:32:49 +0100 Subject: [PATCH 23/31] Refactor of Selenium container - part 2 --- docker-compose.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 76188ce..55a976f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -134,10 +134,10 @@ services: dockerfile: tools/selenium/Dockerfile target: m2d_selenium args: - - M2D_CPU_TYPE:${M2D_CPU_TYPE:-m1} - - M2D_ENABLE_SELENIUM:${M2D_ENABLE_SELENIUM:-no} - - M2D_SELENIUM_VERSION:${M2D_SELENIUM_VERSION:-'3.14.0'} - container_name: selenium + - M2D_CPU_TYPE=${M2D_CPU_TYPE:-m1} + - M2D_ENABLE_SELENIUM=${M2D_ENABLE_SELENIUM:-no} + - M2D_SELENIUM_VERSION=${M2D_SELENIUM_VERSION:-'3.14.0'} + container_name: m2d-selenium volumes: - /dev/shm:/dev/shm ports: From 9da55d7e7065e815e28571798535d231493ec780 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 24 Mar 2023 23:35:32 +0100 Subject: [PATCH 24/31] Refactor of Web container - part 2 --- .env.example | 8 +++++ docker-compose.yml | 5 +-- services/web-servers/apache/Dockerfile | 32 ++++++++++--------- .../apache/etc/m2install/.gitignore | 3 ++ .../apache/etc/m2install/.m2install.conf | 8 +++-- 5 files changed, 37 insertions(+), 19 deletions(-) create mode 100644 services/web-servers/apache/etc/m2install/.gitignore diff --git a/.env.example b/.env.example index 823bd7e..31c966f 100644 --- a/.env.example +++ b/.env.example @@ -45,6 +45,14 @@ M2D_PORT_FOR_SELENIUM_VNC='5900' ## SERVICES CONFIGURATION SECTION ## ########################################## +## WEB SERVER +# Set which Web server engine you want to use: +# - 'apache' for Apache [https://www.apache.org/] +M2D_WEB_SERVER_VENDOR='apache' +# Set which PHP version you want to use: +# - PHP versions: 7.3, 7.4, 8.1, 8.2 +M2D_WEB_SERVER_PHP_VERSION='8.1' + ## DB ENGINE # Set which DB engine you want to use: # - 'mariadb' for MariaDB [https://www.elastic.co/] diff --git a/docker-compose.yml b/docker-compose.yml index 55a976f..9167598 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,11 +3,12 @@ version: '3' services: web: hostname: magento2.test - container_name: magento2web + container_name: m2d-web restart: unless-stopped build: context: . - target: php_base + dockerfile: services/web-servers/${M2D_WEB_SERVER_VENDOR:-apache}/Dockerfile + target: web_server args: - M2D_WEB_SERVER_PHP_VERSION=${M2D_WEB_SERVER_PHP_VERSION:-8.1} - M2D_ENABLE_BLACKFIRE=${M2D_ENABLE_BLACKFIRE:-no} diff --git a/services/web-servers/apache/Dockerfile b/services/web-servers/apache/Dockerfile index 0dacaa7..7db5461 100644 --- a/services/web-servers/apache/Dockerfile +++ b/services/web-servers/apache/Dockerfile @@ -64,12 +64,6 @@ RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local # TOOLS: COPY ./services/web-servers/apache/tools/* /usr/local/bin/ -# CODESNIFFER: -# RUN pear install PHP_CodeSniffer \ -# && mkdir /usr/local/magento-ecg-code-sniffer \ -# && cd /usr/local/magento-ecg-code-sniffer/ && composer require magento-ecg/coding-standard \ -# && phpcs --config-set installed_paths /usr/local/magento-ecg-code-sniffer/vendor/magento-ecg/coding-standard - # SENDMAIL: RUN echo "sendmail_path=/usr/bin/msmtp -t" >> /usr/local/etc/php/conf.d/mailcatcher.ini \ && echo "memory_limit=2G" >> /usr/local/etc/php/conf.d/custom.ini \ @@ -80,13 +74,13 @@ RUN echo "sendmail_path=/usr/bin/msmtp -t" >> /usr/local/etc/php/conf.d/mailcatc && echo "auto_from on" >> /etc/msmtprc # SSH: -COPY ./etc/ssh ${_HOME_DIRECTORY}/.ssh -ADD ./etc/ssh/magento2docker.pub ${_HOME_DIRECTORY}/.ssh/authorized_keys +COPY ./services/web-servers/apache/etc/ssh ${_HOME_DIRECTORY}/.ssh +ADD ./services/web-servers/apache/etc/ssh/magento2docker.pub ${_HOME_DIRECTORY}/.ssh/authorized_keys RUN chmod -R 700 ${_HOME_DIRECTORY}/.ssh \ && echo " ServerAliveInterval 30" >> /etc/ssh/ssh_config \ && echo " TCPKeepAlive yes" >> /etc/ssh/ssh_config -COPY ./etc/ssh /root/.ssh -ADD ./etc/ssh/magento2docker.pub /root/.ssh/authorized_keys +COPY ./services/web-servers/apache/etc/ssh /root/.ssh +ADD ./services/web-servers/apache/etc/ssh/magento2docker.pub /root/.ssh/authorized_keys RUN chmod -R 700 /root/.ssh \ && echo "Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc" >> /etc/ssh/sshd_config \ && touch /root/.ssh/known_hosts \ @@ -117,10 +111,8 @@ ARG CACHEBUST=1 # CUSTOM CONFIGURATIONS: COPY ./services/web-servers/apache/etc/apache2 /etc/apache2 -# COPY ./services/web-servers/apache/etc/apache2/envvars /etc/apache2/envvars -# COPY ./services/web-servers/apache/etc/apache2/sites-enabled /etc/apache2/sites-enabled/ COPY ./services/web-servers/apache/etc/git/gitconfig ${_HOME_DIRECTORY}/.gitconfig -COPY ./services/web-servers/apache/etc/composer/auth.json /${_HOME_DIRECTORY}/.composer/auth.json +COPY ./services/web-servers/apache/etc/composer/auth.json* /${_HOME_DIRECTORY}/.composer/ COPY ./services/web-servers/apache/etc/fixtures /etc/fixtures COPY ./services/web-servers/apache/etc/m2install/.m2install.conf* ${_HOME_DIRECTORY}/ @@ -139,6 +131,10 @@ RUN curl -o /usr/local/bin/m2install.sh https://raw.githubusercontent.com/yvoron && git ls-remote git@github.com:magento-sparta/m-it.git 2>&1 | if grep -q HEAD; then git clone git@github.com:magento-sparta/m-it.git /usr/local/src/m-it; else echo; fi \ && if [ -d /usr/local/src/m-it ]; then /usr/local/src/m-it/mit-installer.sh; else echo; fi +USER magento +RUN if [ -d /usr/local/src/m-it ]; then /usr/local/src/m-it/mit-installer.sh; else echo; fi +USER root + RUN chmod +x /usr/local/bin/* ## END OF BASE IMAGE ## @@ -163,9 +159,10 @@ RUN version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ && rm -Rf /tmp/blackfire ## END OF BASE IMAGE WITH BLACKFIRE ## +FROM m2d_web_server_apache_php_base_blackfire_${M2D_ENABLE_BLACKFIRE} AS m2d_web_server_apache_blackfire ## IMAGE ADJUSTMENTS FOR PHP 7.x ## -FROM m2d_web_server_apache_php_base_${M2D_ENABLE_BLACKFIRE'} AS m2d_web_server_apache_php7x +FROM m2d_web_server_apache_blackfire AS m2d_web_server_apache_php7x # COMPOSER 1 LINKED AS DEFAULT: RUN ln -s /usr/local/bin/composer1 /usr/local/bin/composer @@ -190,7 +187,7 @@ RUN pecl install libsodium-2.0.23 ## IMAGE ADJUSTEMNTS FOR PHP 8.x -FROM m2d_web_server_apache_php_base_${M2D_ENABLE_BLACKFIRE} AS m2d_web_server_apache_php8x +FROM m2d_web_server_apache_blackfire AS m2d_web_server_apache_php8x # PHP EXTENSIONS GD: RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp \ @@ -253,4 +250,9 @@ FROM m2d_web_server_apache_php8x AS m2d_web_server_apache_php8.2 ## TARGET IMAGE ADJUSTEMNTS ## FROM m2d_web_server_apache_php${M2D_WEB_SERVER_PHP_VERSION} AS web_server +# CODESNIFFER: +RUN pear install PHP_CodeSniffer \ + && mkdir /usr/local/magento-ecg-code-sniffer \ + && cd /usr/local/magento-ecg-code-sniffer/ && composer require magento-ecg/coding-standard \ + && phpcs --config-set installed_paths /usr/local/magento-ecg-code-sniffer/vendor/magento-ecg/coding-standard CMD service ssh start; apache2-foreground diff --git a/services/web-servers/apache/etc/m2install/.gitignore b/services/web-servers/apache/etc/m2install/.gitignore new file mode 100644 index 0000000..9c10fa6 --- /dev/null +++ b/services/web-servers/apache/etc/m2install/.gitignore @@ -0,0 +1,3 @@ +* +!.gitignore +!.m2install.conf diff --git a/services/web-servers/apache/etc/m2install/.m2install.conf b/services/web-servers/apache/etc/m2install/.m2install.conf index 21acf73..a9c664f 100644 --- a/services/web-servers/apache/etc/m2install/.m2install.conf +++ b/services/web-servers/apache/etc/m2install/.m2install.conf @@ -13,7 +13,11 @@ MAGENTO_EE_PATH= GIT_CE_REPO=git@github.com:magento/magento2.git GIT_EE_REPO= GIT_BRANCH=2.4-develop -SEARCH_ENGINE_ELASTICSEARCH7_HOST="magento2searchengine" +SEARCH_ENGINE_ELASTICSEARCH7_HOST="m2d-searchengine" SEARCH_ENGINE_ELASTICSEARCH7_PORT="9200" -SEARCH_ENGINE_ELASTICSEARCH6_HOST="magento2searchengine" +SEARCH_ENGINE_ELASTICSEARCH6_HOST="m2d-searchengine" SEARCH_ENGINE_ELASTICSEARCH6_PORT="9200" +SEARCH_ENGINE_ELASTICSEARCH5_HOST="m2d-searchengine" +SEARCH_ENGINE_ELASTICSEARCH5_PORT="9200" +SEARCH_ENGINE_ELASTICSEARCH2_HOST="m2d-searchengine" +SEARCH_ENGINE_ELASTICSEARCH2_PORT="9200" From c50e4024171f4586fe28d5e8e59fe13ba798402a Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 24 Mar 2023 23:36:31 +0100 Subject: [PATCH 25/31] Added varaibles for source folder and sync type --- .env.example | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.env.example b/.env.example index 31c966f..b848a7b 100644 --- a/.env.example +++ b/.env.example @@ -2,6 +2,14 @@ ## MAIN SETTINGS ## ########################################## +# Set the base path were you want to keep Magento source files +# e.g. /var/www/html or ~/src/html +M2D_SOURCE_DIRECTORY='/var/www/html' +# Define a synchronisation type used to sync source directory between host and container +# - 'mutagen' container will use named volume and Mutagen [https://mutagen.io/] will be used to sync files (default) +# - 'sshfs' container will use named volume and SSHFS will be used to mount it to the host +# - 'bind' will binds source directory on host to container (performance on Mac and Windows may be not sufficient) +M2D_SOURCE_DIRECTORY_SYNC_TYPE='mutagen' # Set your CPU type: # - 'm1' for Apple M1 CPUs # - 'intel' for Intel or AMD based CPUs From 60bf2293928d88a45ddf17dcc5b3ab03aaeff7a6 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 24 Mar 2023 23:39:27 +0100 Subject: [PATCH 26/31] Define default network --- docker-compose.phpstorm.yml | 6 ++++-- docker-compose.yml | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docker-compose.phpstorm.yml b/docker-compose.phpstorm.yml index 6016e59..41c0072 100644 --- a/docker-compose.phpstorm.yml +++ b/docker-compose.phpstorm.yml @@ -14,10 +14,12 @@ services: - src-volume:/var/www/html environment: - DISPLAY=host.docker.internal:0 + networks: default: - external: - name: env_default + name: m2d-network + external: true + volumes: src-volume: phpstorm-config: diff --git a/docker-compose.yml b/docker-compose.yml index 9167598..41e2ee5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -146,6 +146,10 @@ services: - "${M2D_PORT_FOR_SELENIUM_VNC:-5900}:5900" shm_size: '2gb' +networks: + default: + name: m2d-network + volumes: home-volume: root-volume: From 36d6a2a21344d6e0aca697cc1ea3f2e1acbe8560 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Fri, 24 Mar 2023 23:41:22 +0100 Subject: [PATCH 27/31] Align ignored files with the new project structure --- .gitignore | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 4010498..4c49bd7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,24 +1 @@ -src/* -!src/index.php - -env/.env -env/etc/composer/auth.json -!env/etc/git/* -!env/etc/git/gitconfig.example -env/etc/git/gitconfig - -env/etc/m2install/.m2install.conf.override -env/docker-compose.override.yml - -.idea -env/etc/apache/* -!env/etc/vhost.conf.example -!env/etc/apache/envvars -!env/etc/apache/000-default.conf -!env/etc/apache/second-level.nip.io.conf - -env/misc/* -!env/misc/xdebug-php.sh -!env/misc/prepare-mtf.sh - -env/etc/host/config.sh.override +.env From e54e767aa0be5ba0732a62addcfa47f7cb26ecf5 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Sat, 25 Mar 2023 02:37:06 +0100 Subject: [PATCH 28/31] Refactor of Web container - part 3 --- .env.example | 6 ++++++ docker-compose.yml | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index b848a7b..efd437c 100644 --- a/.env.example +++ b/.env.example @@ -60,6 +60,12 @@ M2D_WEB_SERVER_VENDOR='apache' # Set which PHP version you want to use: # - PHP versions: 7.3, 7.4, 8.1, 8.2 M2D_WEB_SERVER_PHP_VERSION='8.1' +# Set the port number used by SSH: +M2D_PORT_FOR_WEB_SERVER_SSH='2222' +# Set the port number used by HTTP: +M2D_PORT_FOR_WEB_SERVER_HTTP='80' +# Set the port number used by HTTPS: +M2D_PORT_FOR_WEB_SERVER_HTTPS='443' ## DB ENGINE # Set which DB engine you want to use: diff --git a/docker-compose.yml b/docker-compose.yml index 41e2ee5..992c117 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,9 +19,9 @@ services: - MAGENTO_CLOUD_CLI_TOKEN - COMPOSER_AUTH ports: - - "80:80" - - "443:443" - - "2222:22" + - "${M2D_PORT_FOR_WEB_SERVER_HTTP:-80}:80" + - "${M2D_PORT_FOR_WEB_SERVER_HTTPS:-443}:443" + - "${M2D_PORT_FOR_WEB_SERVER_SSH:-2222}:22" volumes: - src-volume:/var/www/html - src-composer-cache-volume:/root/.composer/cache From 398c992d5463632f57b2642660bb4c7959fff74f Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Sat, 25 Mar 2023 02:39:10 +0100 Subject: [PATCH 29/31] Added scripts to setup and use project --- bin/m2d | 585 +++++++++++++++++++++ docker-compose.bind.yml | 6 + services/web-servers/apache/bin/install.sh | 156 ++++++ 3 files changed, 747 insertions(+) create mode 100755 bin/m2d create mode 100644 docker-compose.bind.yml create mode 100755 services/web-servers/apache/bin/install.sh diff --git a/bin/m2d b/bin/m2d new file mode 100755 index 0000000..09bd5b7 --- /dev/null +++ b/bin/m2d @@ -0,0 +1,585 @@ +#!/usr/bin/env bash +# shellcheck shell=bash + +function _m2d_display_help_main () +{ + echo " +Usage: ./bin/m2d COMMAND [OPTIONS] + +Options: + -h, --help Disply help for command + +Commands: + build Build or rebuild containers + disable Disable selected service or tool + down Stop and remove containers and networks + enable Enable selected service or tool + logs View logs from containers + set Sets configuration value + setup Configure project + show Shows configuration value + stop Stops containers + sync Manage data sync from between host an containers + up Create and start containers +" +} + +function _m2d_display_help_set () +{ + echo " +Usage: ./bin/m2d set [OPTIONS] PARAMETER VALUE + +Options: + -h, --help Disply help for command + +Parameters: + php Alias for parameter M2D_WEB_SERVER_PHP_VERSION + [M2D_*] Parameter name. List of possible parameters and their values is in .env.example +" +} + +function _m2d_display_help_show () +{ + echo " +Usage: ./bin/m2d show [OPTIONS] PARAMETER + +Options: + -h, --help Disply help for command + +Parameters: + [M2D_*] Parameter name. List of possible parameters is in .env.example +" +} + +function _m2d_display_help_setup () +{ + echo " +Usage: ./bin/m2d setup [OPTIONS] [COMMAND] [PROJECT_ID] + +Options: + -h, --help Disply help for command + +Commands: + init Starts creator of initial configuration for Web container and .env file + env Starts .env file creator + from-cloud Generates .env file based on provided PROJECT_ID +" +} + +function _m2d_display_help_enable_disable () +{ + echo " +Usage: ./bin/m2d $1 [OPTIONS] COMMAND + +Options: + -h, --help Disply help for command + +Commands: + blackfire ${1^} blackfire container + db-cache ${1^} db-cache container + elastic Alias for 'search-engine ' command + m Alias for 'mailcatcher' command + mailcatcher ${1^} mailcatcher container + message-broker ${1^} message broker container + rabbit Alias for 'message-broker' command + redis Alias for 'db-cache' command + search-engine ${1^} search engine container + selenium ${1^} selenium container + varnish Alias for 'web-cache' command + web-cache ${1^} web-cache container + +After container is $1 it must be rebuild with: \`./bin/m2d build\` or \`./bin/m2d up --build\` +" +} + +function _m2d_display_help_up () +{ + echo " +Usage: ./bin/m2d up [OPTIONS] + +Options: + -h, --help Disply help for command + -b, --build Build images before starting containers. +" +} + +function _m2d_display_help_commad_generic () +{ + echo " +Usage: ./bin/m2d $1 [OPTIONS] + +Options: + -h, --help Disply help for command +" +} + +function _m2d_display_help_go () +{ + echo " +Usage: ./bin/m2d go [OPTIONS] CONTAINER_NAME + +Options: + -h, --help Disply help for command + +Containers: + web Alias for m2d-web container + +Current containers: +" +docker ps --format '{{.Names}}' +} + +function _m2d_display_help_logs () +{ + echo " +Usage: ./bin/m2d logs [OPTIONS] CONTAINER_NAME + +Options: + -h, --help Disply help for command + +Current containers: +" +docker ps --format '{{.Names}}' +} + +function _m2d_display_help_sync () +{ + echo " +Usage: ./bin/m2d sync [OPTIONS] ACTION + +Options: + -h, --help Disply help for command + +Actions: + start Starts synchronisation if applicable + pause Pause synchronisation if applicable + stop Stops synchronization if applicable + status Display synchronization status if applicable + restart Restart synchronisation if applicable +" +} + +function _m2d_init_source_folder () +{ + local env_file="$1" + local current_folder=$(_m2d_env_get_parameter "$env_file" M2D_SOURCE_DIRECTORY) + local new_folder + + read -p "Set the path where you want to keep Magento source files. Press enter to keep current '$current_folder': " new_folder + + if [[ -z "$new_folder" ]]; then + new_folder="$current_folder" + fi + + new_folder=$(eval echo "$new_folder") + + if [[ ! -d "$new_folder" ]]; then + local confirm + read -p "Path '$new_folder' doesn't exist. Create it? [y/n]: " confirm + [[ $confirm == 'y' ]] && mkdir -p "$new_folder" + fi + + echo "$new_folder" +} + +function _m2d_init_env() +{ + local env_file="$1" + local current_value value confirm + + if [[ -f "$env_file" ]]; then + read -p 'You already have .env file. Do you want to recreate it? [y/n]: ' confirm + if [[ $confirm == 'y' ]]; then + cp "$env_file.example" "$env_file" + fi + else + cp "$env_file.example" "$env_file" + fi + + read -p 'Do you want to configure main Magento2Docker settings? [y/n]: ' confirm + if [[ $confirm != 'y' ]]; then + echo "Magento2Docker will use settings from this file: '$env_file'" + echo 'Please verify them before further usage!' + return 0 + fi + + while [[ ! -d "$value" ]]; + do + value=$(_m2d_init_source_folder "$env_file") + done + _m2d_env_set_parameter "$env_file" M2D_SOURCE_DIRECTORY "$value" + + read -p 'Are you on Apple M1 chip? [y/n]: ' confirm + if [[ $confirm == 'y' ]]; then + _m2d_env_set_parameter "$env_file" M2D_CPU_TYPE m1 + else + _m2d_env_set_parameter "$env_file" M2D_CPU_TYPE intel + fi + + value=$(_m2d_env_get_parameter "$env_file" M2D_XDEBUG_IDE_KEY) + read -p "Provide IDE key for xDebug (e.g.: PHPSTORM, VSCODE). Press enter to keep current '$value': " value + if [[ -n $value ]]; then + _m2d_env_set_parameter "$env_file" M2D_XDEBUG_IDE_KEY "$value" + fi + + value=$(_m2d_env_get_parameter "$env_file" MAGENTO_CLOUD_CLI_TOKEN) + read -p "Provide Magento Cloud CLI authentication token. Press enter to keep current '$value': " value + if [[ -n $value ]]; then + _m2d_env_set_parameter "$env_file" MAGENTO_CLOUD_CLI_TOKEN "$value" + fi +} + +function _m2d_env_set_parameter () +{ + local env_file="$1" + local parameter="$2" + local value="$3" + + if [[ ! -f "$env_file" ]]; then + echo "Env file '$env_file' doesn't exist! Initialize it by executing \`./bin/m2d setup env\`" + return 1 + fi + + sed -i.back "s|^\\(${parameter}=\\).*|\\1'$value'|" "$env_file" +} + +function _m2d_env_get_parameter () +{ + local env_file="$1" + local parameter="$2" + local default="${3:-}" + + if [[ ! -f "$env_file" ]]; then + echo "Env file '$env_file' doesn't exist! Initialize it by executing \`./bin/m2d setup env\`" + return 1 + fi + + local value=$(grep "^$parameter=" "$env_file" | cut -d '=' -f 2 | tr -d "'") + value="${value:=$default}" + + echo "$value" +} + +function _m2d_exec_container () +{ + local container_name="$1" + local allowed=$(docker ps --format '{{.Names}}' | grep "$container_name") + local user_name="${2:-root}" + + if [[ -n "$allowed" ]]; then + docker exec -it --user "$user_name" "$container_name" /bin/bash + else + echo "Sorry, container '$container_name' does not exists!" + fi +} + +function _m2d_logs_container () +{ + local container_name="$1" + local allowed=$(docker ps --format '{{.Names}}' | grep "$container_name") + + if [[ -n "$allowed" ]]; then + docker logs -f "$container_name" + else + echo "Sorry, container '$container_name' does not exists!" + fi +} + +function _m2d_sync () +{ + local action="$1" + local env_file="$2" + local sync_type=$(_m2d_env_get_parameter "$env_file" M2D_SOURCE_DIRECTORY_SYNC_TYPE) + local sync_dir=$(_m2d_env_get_parameter "$env_file" M2D_SOURCE_DIRECTORY) + local server_vendor=$(_m2d_env_get_parameter "$env_file" M2D_WEB_SERVER_VENDOR) + local ssh_port=$(_m2d_env_get_parameter "$env_file" M2D_PORT_FOR_WEB_SERVER_SSH) + local project_path="$3" + + case $sync_type in + 'bind') + echo "Nothing to do for '$action' in '$sync_type' sync type" + ;; + 'sshfs') + case $action in + 'start') + local identity_file="$project_path/services/web-servers/$server_vendor/etc/ssh/magento2docker" + chmod 400 "$identity_file" + sshfs magento@127.0.0.1:/var/www/html "$sync_dir" \ + -o reconnect \ + -o StrictHostKeyChecking=no \ + -o follow_symlinks \ + -o IdentityFile="$identity_file" \ + -o port="$ssh_port" \ + -o compression=no + ;; + 'stop'|'pause') + umount -f "$sync_dir" + ;; + *) + echo "Nothing to do for '$action' in '$sync_type' sync type" + ;; + esac + ;; + 'mutagen') + case $action in + 'start') + if [[ -n $(mutagen sync list | grep m2d-sync) ]]; then + mutagen sync resume m2d-sync + else + mutagen sync create --name=magento2web \ + --default-group-beta=magento \ + --default-owner-beta=magento \ + --sync-mode=two-way-resolved \ + --default-file-mode=0664 \ + --default-directory-mode=0755 \ + --ignore=/.idea \ + --ignore=/.magento \ + --ignore=/.docker \ + --ignore=/.github \ + --ignore-vcs \ + --ignore=/**/var/cache \ + --ignore=/**/var/page_cache \ + --ignore=/**/var/session \ + --ignore=/**/var/log \ + --ignore=/**/.DS_Store \ + --symlink-mode=posix-raw \ + "$sync_dir" \ + docker://magento@m2d-web/var/www/html/ + fi + ;; + 'pause') + mutagen sync pause m2d-sync + ;; + 'stop') + mutagen sync terminate m2d-sync + ;; + 'status') + mutagen sync monitor m2d-sync + ;; + 'restart') + _m2d_sync stop "$env_file" + _m2d_sync start "$env_file" + ;; + *) + echo "Nothing to do for '$action' in '$sync_type' sync type" + ;; + esac + ;; + *) + echo "Sync type '$sync_type' is not supported!" + ;; + esac +} + + +M2D_SCRIPT_DIRECTORY=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) +M2D_PROJECT_PATH="$(realpath $M2D_SCRIPT_DIRECTORY/../)" +M2D_ENV_FILE="$(realpath $M2D_PROJECT_PATH/.env)" + +case $1 in + 'set') + case $2 in + '-h'|'--help') + _m2d_display_help_set + ;; + 'php') + _m2d_env_set_parameter "$M2D_ENV_FILE" "M2D_WEB_SERVER_PHP_VERSION" "$3" + ;; + 'es') + _m2d_env_set_parameter "$M2D_ENV_FILE" "M2D_SEARCH_ENGINE_VENDOR" elasticsearch + _m2d_env_set_parameter "$M2D_ENV_FILE" "M2D_SEARCH_ENGINE_VERSION" "$3" + ;; + *) + _m2d_env_set_parameter "$M2D_ENV_FILE" "$2" "$3" + ;; + esac + ;; + + 'show') + case $2 in + '-h'|'--help') + _m2d_display_help_show + ;; + *) + _m2d_env_get_parameter "$M2D_ENV_FILE" "$2" + ;; + esac + ;; + + 'setup') + case $2 in + 'init') + _m2d_init_env "$M2D_ENV_FILE" + source "$M2D_SCRIPT_DIRECTORY/../services/web-servers/apache/bin/install.sh" + ;; + 'env') + _m2d_init_env "$M2D_ENV_FILE" + ;; + 'from-cloud') + echo 'Not yet implemented!' + ;; + *) + _m2d_display_help_setup + ;; + esac + ;; + + 'enable') + case $2 in + '-h'|'--help') + _m2d_display_help_enable_disable "enable" + ;; + 'blackfire') + _m2d_env_set_parameter "$M2D_ENV_FILE" M2D_ENABLE_BLACKFIRE yes + ;; + 'mailcatcher'|'m') + _m2d_env_set_parameter "$M2D_ENV_FILE" M2D_ENABLE_MAILCATCHER yes + ;; + 'selenium') + _m2d_env_set_parameter "$M2D_ENV_FILE" M2D_ENABLE_SELENIUM yes + ;; + 'web-cache'|'varnish') + _m2d_env_set_parameter "$M2D_ENV_FILE" M2D_ENABLE_WEB_CACHE yes + ;; + 'db-cache'|'redis') + _m2d_env_set_parameter "$M2D_ENV_FILE" M2D_ENABLE_DB_CACHE yes + ;; + 'message-broker'|'rabbit') + _m2d_env_set_parameter "$M2D_ENV_FILE" M2D_ENABLE_MESSAGE_BROKER yes + ;; + 'search-engine'|'elastic') + _m2d_env_set_parameter "$M2D_ENV_FILE" M2D_ENABLE_SEARCH_ENGINE yes + ;; + esac + ;; + + 'disable') + case $2 in + '-h'|'--help') + _m2d_display_help_enable_disable "disable" + ;; + 'blackfire') + _m2d_env_set_parameter "$M2D_ENV_FILE" M2D_ENABLE_BLACKFIRE no + ;; + 'mailcatcher'|'m') + _m2d_env_set_parameter "$M2D_ENV_FILE" M2D_ENABLE_MAILCATCHER no + ;; + 'selenium') + _m2d_env_set_parameter "$M2D_ENV_FILE" M2D_ENABLE_SELENIUM no + ;; + 'web-cache'|'varnish') + _m2d_env_set_parameter "$M2D_ENV_FILE" M2D_ENABLE_WEB_CACHE no + ;; + 'db-cache'|'redis') + _m2d_env_set_parameter "$M2D_ENV_FILE" M2D_ENABLE_DB_CACHE no + ;; + 'message-broker'|'rabbit') + _m2d_env_set_parameter "$M2D_ENV_FILE" M2D_ENABLE_MESSAGE_BROKER no + ;; + 'search-engine'|'elastic') + _m2d_env_set_parameter "$M2D_ENV_FILE" M2D_ENABLE_SEARCH_ENGINE no + ;; + esac + ;; + + 'up') + case $2 in + '-h'|'--help') + _m2d_display_help_up + ;; + '-b'|'--build') + if [[ 'bind' == $(_m2d_env_get_parameter "$M2D_ENV_FILE" M2D_SOURCE_DIRECTORY_SYNC_TYPE) ]]; then + docker-compose --project-directory "$M2D_PROJECT_PATH" \ + -f "$M2D_PROJECT_PATH/docker-compose.yaml" \ + -f "$M2D_PROJECT_PATH/docker-compose.bind.yaml" \ + up -d --build + else + docker-compose --project-directory "$M2D_PROJECT_PATH" up -d --build + fi + _m2d_sync start "$M2D_ENV_FILE" "$M2D_PROJECT_PATH" + ;; + *) + docker-compose --project-directory "$M2D_PROJECT_PATH" up -d + _m2d_sync start "$M2D_ENV_FILE" "$M2D_PROJECT_PATH" + ;; + esac + ;; + 'down') + case $2 in + '-h'|'--help') + _m2d_display_help_commad_generic "down" + ;; + *) + docker-compose --project-directory "$M2D_PROJECT_PATH" down + _m2d_sync stop "$M2D_ENV_FILE" "$M2D_PROJECT_PATH" + ;; + esac + ;; + 'stop') + case $2 in + '-h'|'--help') + _m2d_display_help_commad_generic "stop" + ;; + *) + docker-compose --project-directory "$M2D_PROJECT_PATH" stop + _m2d_sync pause "$M2D_ENV_FILE" "$M2D_PROJECT_PATH" + ;; + esac + ;; + 'build') + case $2 in + '-h'|'--help') + _m2d_display_help_commad_generic "build" + ;; + *) + if [[ 'bind' == $(_m2d_env_get_parameter "$M2D_ENV_FILE" M2D_SOURCE_DIRECTORY_SYNC_TYPE) ]]; then + docker-compose --project-directory "$M2D_PROJECT_PATH" \ + -f "$M2D_PROJECT_PATH/docker-compose.yaml" \ + -f "$M2D_PROJECT_PATH/docker-compose.bind.yaml" \ + build + else + docker-compose --project-directory "$M2D_PROJECT_PATH" build + fi + ;; + esac + ;; + + 'go') + case $2 in + '-h'|'--help') + _m2d_display_help_go + ;; + 'web') + docker exec -it --env COLUMNS=`tput cols` --env LINES=`tput lines` --user magento m2d-web bash + ;; + *) + _m2d_exec_container "$2" "$3" + ;; + esac + ;; + + 'logs') + case $2 in + '-h'|'--help') + _m2d_display_help_logs + ;; + *) + _m2d_logs_container "$2" + ;; + esac + ;; + + 'sync') + case $2 in + '-h'|'--help') + _m2d_display_help_sync + ;; + *) + _m2d_sync "$2" "$M2D_ENV_FILE" "$M2D_PROJECT_PATH" + ;; + esac + ;; + *) + _m2d_display_help_main + ;; +esac diff --git a/docker-compose.bind.yml b/docker-compose.bind.yml new file mode 100644 index 0000000..25b89fa --- /dev/null +++ b/docker-compose.bind.yml @@ -0,0 +1,6 @@ +version: '3' + +services: + web: + volumes: + - ${M2D_SOURCE_DIRECTORY}:/var/www/html diff --git a/services/web-servers/apache/bin/install.sh b/services/web-servers/apache/bin/install.sh new file mode 100755 index 0000000..82ea980 --- /dev/null +++ b/services/web-servers/apache/bin/install.sh @@ -0,0 +1,156 @@ +#!/usr/bin/env bash +# shellcheck shell=bash + +function _m2d_install_apache_init_ahut_json () +{ + local confirm target_file + + target_file="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)/../etc/composer/auth.json" + + if [[ -f "$target_file" ]]; then + read -p 'You already have auth.json file. Do you want to keep it? [y/n]: ' confirm + + if [[ $confirm == 'y' ]]; then + return 0 + fi + + mv "$target_file" "$target_file.backup" + fi + + if [[ -f ~/.composer/auth.json ]]; then + read -p 'Do you want to use your current auth.json file (from ~/.composer/auth.json)? [y/n]: ' confirm + + if [[ $confirm == 'y' ]]; then + cp ~/.composer/auth.json "$target_file" + return 0 + fi + fi + + read -p 'Do you want to use existing auth.json file? [y/n]: ' confirm + if [[ $confirm == 'y' ]]; then + local auth_json_path + while [[ ! -f "$target_file" ]] + do + read -p 'Provide a path to auth.json file you want to use: ' auth_json_path + auth_json_path=$(realpath "${auth_json_path/#\~/$HOME}" 2> /dev/null) + + echo "$auth_json_path" + + if [[ -f "$auth_json_path" ]]; then + cp "$auth_json_path" "$target_file" + return 0 + fi + + read -p "'$auth_json_path' doesn't exists! Do you want to try again? [y/n]: " confirm + + if [[ $confirm == 'n' ]]; then + break + fi + done + fi + + local username password file_content + read -p 'Provide public key to repo.magento.com: ' username + read -p 'Provide private key to repo.magento.com: ' password + + file_content=$(cat <> "$target_file" +} + +function _m2d_install_apache_init_git_config () +{ + local confirm target_file + + target_file="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)/../etc/git/gitconfig" + + if [[ -f "$target_file" ]]; then + read -p 'You already have gitconfig file. Do you want to keep it? [y/n]: ' confirm + + if [[ $confirm == 'y' ]]; then + return 0 + fi + + mv "$target_file" "$target_file.backup" + fi + + if [[ -f ~/.gitconfig ]]; then + read -p 'Do you want to use your current gitconfig file (from ~/.gitconfig)? [y/n]: ' confirm + + if [[ $confirm == 'y' ]]; then + cp ~/.gitconfig "$target_file" + return 0 + fi + fi + + local email name file_content + read -p 'Provide your email addres: ' email + read -p 'Provide your full name (name and surname): ' name + + file_content=$(cat <> "$target_file" +} + +function _m2d_install_apache_init_certs () +{ + local confirm + local target_path="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)/../etc/ssh" + + if [[ -f ~/.ssh/config ]]; then + read -p 'Do you want to add SSH config file(s) to the web container? [y/n]: ' confirm + + if [[ $confirm == 'y' ]]; then + cp ~/.ssh/config* "$target_path/" + fi + fi + + if [[ -f ~/.ssh/known_hosts ]]; then + read -p 'Do you want to add known_hosts file to the web container? [y/n]: ' confirm + + if [[ $confirm == 'y' ]]; then + cp ~/.ssh/known_hosts "$target_path/" + fi + fi + + read -p 'Do you want to select the SSH keys to be added to the web container? [y/n]: ' confirm + + if [[ $confirm == 'n' ]]; then + return 0 + fi + + for ssh_pub_key in ~/.ssh/*.pub; do + if [[ "$(basename $ssh_pub_key)" == 'magento2docker.pub' ]]; then + continue + fi + + read -p "Add '$ssh_pub_key'? [y/n]: " confirm + + if [[ $confirm != 'y' ]]; then + continue + fi + + cp "$ssh_pub_key" "$target_path/$(basename $ssh_pub_key)" + cp "${ssh_pub_key%.pub}" "$target_path/$(basename ${ssh_pub_key%.pub})" + done +} + +_m2d_install_apache_init_ahut_json +_m2d_install_apache_init_git_config +_m2d_install_apache_init_certs From 3d2971eec9c3e3e8d130547718495907cca84af3 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Sat, 25 Mar 2023 02:42:16 +0100 Subject: [PATCH 30/31] Removed unused files --- env/Makefile | 176 ------------------------------ env/bin/.init | 3 - env/bin/magento-cloud | 4 - env/bin/shell | 4 - env/bin/shell-root | 3 - env/bin/up | 4 - env/etc/host/config.sh | 8 -- env/etc/osx.docker.loopback.plist | 17 --- 8 files changed, 219 deletions(-) delete mode 100644 env/Makefile delete mode 100644 env/bin/.init delete mode 100755 env/bin/magento-cloud delete mode 100755 env/bin/shell delete mode 100755 env/bin/shell-root delete mode 100755 env/bin/up delete mode 100644 env/etc/host/config.sh delete mode 100644 env/etc/osx.docker.loopback.plist diff --git a/env/Makefile b/env/Makefile deleted file mode 100644 index 877b376..0000000 --- a/env/Makefile +++ /dev/null @@ -1,176 +0,0 @@ -.PHONY: dev prod down stop build mount umount clean web db magento-console phpstorm -FS_MOUNT_TYPE:=$(shell bash etc/host/config.sh FS_MOUNT_TYPE) -ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) -SRC_DIR:=$(shell bash etc/host/config.sh SOURCE_DIRECTORY) - -mutagenSession = $(shell mutagen sync list | grep 'magento2web') - -up: - $(info "=====$(shell cat Dockerfile | grep 'FROM')=====") - docker-compose up -d -down: - docker-compose down -stop: - docker-compose stop -build: - docker-compose build --build-arg CACHEBUST=`date +%s` -up73: php73 build up -up74: php74 build up -up80: php80 build up -up81: php81 build up -php73: - $(info ""=====Buildng container with php 7.3"=====") - $(shell yes | cp etc/php/7.3/Dockerfile .) -php74: - $(info ""=====Buildng container with php 7.4"=====") - $(shell yes | cp etc/php/7.4/Dockerfile .) -php80: - $(info ""=====Buildng container with php 8.0"=====") - $(shell yes | cp etc/php/8.0/Dockerfile .) -php81: - $(info ""=====Buildng container with php 8.1"=====") - $(shell yes | cp etc/php/8.1/Dockerfile .) -logs: - docker logs -f magento2web -logs-db: - docker logs -f magento2db -add-host: - echo "127.0.0.1 $(host)" | sudo tee -a /etc/hosts - cp etc/apache/vhost.conf.example etc/apache/$(host).conf - cat etc/apache/$(host).conf | sed "s/ServerName example.com/ServerName $(host)/" > etc/apache/$(host).conf.tmp - mv etc/apache/$(host).conf.tmp etc/apache/$(host).conf - cat etc/apache/$(host).conf | sed "s/\/var\/www\/html\/example/\/var\/www\/html\/$(host)/" > etc/apache/$(host).conf.tmp - mv etc/apache/$(host).conf.tmp etc/apache/$(host).conf - docker-compose build - docker-compose up -d - docker exec -it --user magento magento2web mkdir -p /var/www/html/$(host) - docker exec -i --user magento magento2web sh -c "cat ~/.m2install.conf | sed 's/HTTP_HOST=.*/HTTP_HOST=http:\/\/$(host)\//g' | tee /var/www/html/$(host)/.m2install.conf 1>/dev/null" - docker exec -i --user magento magento2web sh -c "sed -i 's/BASE_PATH=.*/BASE_PATH=/g' /var/www/html/$(host)/.m2install.conf" -remove-host: - cat /etc/hosts | sed 's/.*$(host)//g' > /tmp/hosts.tmp - sudo mv /tmp/hosts.tmp /etc/hosts - rm etc/apache/$(host).conf - docker-compose build - docker-compose up -d - docker exec -i --user magento magento2web sh -c "rm /var/www/html/$(host)/.m2install.conf" - -dev: up mount -dev-stop: umount stop -all: up elastic7 mailcatcher - -phpstorm: - xhost + 127.0.0.1 - docker-compose -f docker-compose.phpstorm.yml build - docker-compose -f docker-compose.yml -f docker-compose.phpstorm.yml up -d -mount-sshfs: - chmod 400 $(ROOT_DIR)/etc/ssh/magento2docker - sshfs magento@127.0.0.1:/var/www/html $(SRC_DIR) -o reconnect -o StrictHostKeyChecking=no -o follow_symlinks -o IdentityFile=$(ROOT_DIR)/etc/ssh/magento2docker -o port=2222 -o compression=no -umount-sshfs: - umount -f $(SRC_DIR) -mount-mutagen: -ifeq ($(mutagenSession),) - mutagen sync create --name=magento2web \ - --default-group-beta=magento \ - --default-owner-beta=magento \ - --sync-mode=two-way-resolved \ - --default-file-mode=0664 \ - --default-directory-mode=0755 \ - --ignore=/.idea \ - --ignore=/.magento \ - --ignore=/.docker \ - --ignore=/.github \ - --ignore-vcs \ - --ignore=/**/var/cache \ - --ignore=/**/var/page_cache \ - --ignore=/**/var/session \ - --ignore=/**/var/log \ - --ignore=/**/.DS_Store \ - --symlink-mode=posix-raw \ - $(SRC_DIR) \ - docker://magento@magento2web/var/www/html/ -else - @echo "Mutagen magento2web session exits, resuming" - mutagen sync resume magento2web -endif -umount-mutagen: - mutagen sync pause magento2web -mount: -ifeq "$(FS_MOUNT_TYPE)" "sshfs" - make mount-sshfs -else - make mount-mutagen -endif -umount: -ifeq "$(FS_MOUNT_TYPE)" "sshfs" - make umount-sshfs -else - make umount-mutagen -endif -clean: - docker stop `docker ps -a -q`; docker rm `docker ps -a -q` - -web: - docker exec -it --env COLUMNS=`tput cols` --env LINES=`tput lines` --user magento magento2web bash -db: - docker exec -it magento2db bash -magento-console: - docker exec -it magento2web n98-magerun2 dev:console - -#Additional Containers -elastic6: - cd additional/elasticsearch6 && docker-compose up -d && cd - - # Web interface: - # http://127.0.0.1:9206 -logs-elastic6: - docker logs -f magento2elastic6 -elastic6-stop: - cd additional/elasticsearch6 && docker-compose stop && cd - -elastic7: - cd additional/elasticsearch7 && docker-compose up -d && cd - - # Web interface: - # http://127.0.0.1:9207 -logs-elastic7: - docker logs -f magento2elastic7 -elastic7-stop: - cd additional/elasticsearch7 && docker-compose stop && cd - -opensearch: - cd additional/opensearch && docker-compose up -d && cd - - # Web interface: - # http://127.0.0.1:9200 -logs-opensearch: - docker logs -f magento2opensearch -opensearch-stop: - cd additional/opensearch && docker-compose stop && cd - -selenium: - cd additional/selenium && docker-compose up -d && cd - - # VNC open vnc://:secret@127.0.0.1:5900 -mailcatcher: - cd additional/mailcatcher && docker-compose up -d && cd - - # Management Console: - # http://127.0.0.1:1080/ -mailcatcher-stop: - cd additional/mailcatcher && docker-compose stop && cd - -rabbitmq: - cd additional/rabbitmq && docker-compose up -d && cd - - # Management Console: - # http://localhost:15672 - # guest:guest -rabbitmq-stop: - cd additional/rabbitmq && docker-compose stop && cd - -redis: - cd additional/redis && docker-compose up -d && cd - -redis-cli: - docker exec -it magento2redis redis-cli -redis-stop: - cd additional/redis && docker-compose stop && cd - -varnish: - cd additional/varnish && docker-compose up -d && cd - - # Update port to 8080 for Magento Base URL configuration -varnish-cli: - docker exec -it magento2varnish varnishadm -varnish-stop: - cd additional/varnish && docker-compose stop && cd - -varnish-logs: - docker logs -f magento2varnish - -# vim: ts=4 sw=4 sts=4 sr noet diff --git a/env/bin/.init b/env/bin/.init deleted file mode 100644 index 3ac4f17..0000000 --- a/env/bin/.init +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -set -x diff --git a/env/bin/magento-cloud b/env/bin/magento-cloud deleted file mode 100755 index a930dae..0000000 --- a/env/bin/magento-cloud +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -source bin/.init -docker exec -it --user magento magento2web /home/magento/.magento-cloud/bin/magento-cloud ssh-cert:load -docker exec -it --user magento magento2web /home/magento/.magento-cloud/bin/magento-cloud "$@" diff --git a/env/bin/shell b/env/bin/shell deleted file mode 100755 index 30efbc9..0000000 --- a/env/bin/shell +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -source bin/.init - -docker exec -it --user magento magento2web bash diff --git a/env/bin/shell-root b/env/bin/shell-root deleted file mode 100755 index 38d3c53..0000000 --- a/env/bin/shell-root +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -source bin/.init -docker exec -it magento2web bash diff --git a/env/bin/up b/env/bin/up deleted file mode 100755 index 7dfb262..0000000 --- a/env/bin/up +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -source bin/.init -docker-compose up -d -( cd additional/elasticsearch7 && docker-compose up -d && cd - ) diff --git a/env/etc/host/config.sh b/env/etc/host/config.sh deleted file mode 100644 index cf88d1f..0000000 --- a/env/etc/host/config.sh +++ /dev/null @@ -1,8 +0,0 @@ -FS_MOUNT_TYPE='mutagen' -SOURCE_DIRECTORY=$(cd ../src && pwd) - -if [ -f etc/host/config.sh.override ] -then - source etc/host/config.sh.override -fi -echo ${!1} diff --git a/env/etc/osx.docker.loopback.plist b/env/etc/osx.docker.loopback.plist deleted file mode 100644 index 9d92720..0000000 --- a/env/etc/osx.docker.loopback.plist +++ /dev/null @@ -1,17 +0,0 @@ - - - - - Label - docker.loopback - ProgramArguments - - ifconfig - lo0 - alias - 10.254.254.254 - - RunAtLoad - - - From b3e20dae9b18615b219833320c1956b12895b5a0 Mon Sep 17 00:00:00 2001 From: Adam Wojciechowski Date: Sat, 25 Mar 2023 03:35:47 +0100 Subject: [PATCH 31/31] Fixed README.md to match new usage --- README.md | 130 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 82 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 66208e8..5e22cf8 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,22 @@ -# Magento2 Docker Environment -An Ideal Magento2 Development Environment OSX Centric. +# Magento2Docker Environment +A near to perfect Magento2 Development Environment OS agnostic, OSX focused. Key features of the project: - Simple Apache PHP container based on original images. - - Ideal to work with multiple projects same time + - Ideal to work with multiple projects same time. - Multi-project setup with clean host names. Based on external nip.io wildcard DNS server. - - Provides real-time file synchronization by Mutagen - - Includes PHPStorm container which can be rendered by X.ORG port for OSX + - Provides real-time file synchronization by Mutagen. + - Includes PHPStorm container which can be rendered by X.ORG port for OSX. - Includes great set of tools with zero configuration like Blackfire, XDebug. - - Includes external services: ElasticSearch 2.x - 6.x, Redis, MailCatcher, RabbitMQ. - - Provides Make tool as a wrapper. Simplify managing containers and support bash completion to hightlight commands. - + - Includes all external services needed by Magento: ElasticSearch, Opensearch, Redis, Varnish, MySQL, MariaDB, MailCatcher, RabbitMQ, other. + - Provides bash CLI tool a wrapper. Simplify managing containers. + - Fully compatible with standard docker-compose commands. + - Intel and Apple M1 CPU support. + - Easily extensible. + - Single docker-compose.yaml file approach with .env file to configure everything. ## Contents - - [Pre-requirements](#pre-requirements) - [Installation](#installation) +- [Supported services and tools](#supported-services-and-tools) - [Usage](#usage) - [Quick Start](#quick-start) - [How to install a magento](#how-install-magento) @@ -30,62 +33,93 @@ Key features of the project: - [Install Docker](https://docs.docker.com/engine/installation/mac/) - [Install Mutagen](https://mutagen.io/documentation/introduction/installation/) - [Install bash completion (optional)](https://github.com/bobthecow/git-flow-completion/wiki/Install-Bash-git-completion) - + ## Installation You can download archive of this project on [Release Page](https://github.com/yvoronoy/magento2docker/releases). - Clone or Download the repository ```git clone git@github.com:yvoronoy/magento2docker.git``` - - Copy or create `env/etc/composer/auth.json` and put your [Access Keys](http://devdocs.magento.com/guides/v2.0/install-gde/prereq/dev_install.html) - - `cp env/etc/composer/auth.json.example env/etc/composer/auth.json` - - Edit env/etc/composer/auth.json and put your credentials [Access Keys](http://devdocs.magento.com/guides/v2.0/install-gde/prereq/dev_install.html) - - Update your gitconfig if needed - - `cp env/etc/git/gitconfig.example env/etc/git/gitconfig` - - Update and edit Commerce Cloud CLI Token - - `cp env/.env.example env/.env` - - (Optional) Copy your private ssh keys, configs to have access to resources from inside container - - `cp ~/.ssh/id_rsa env/etc/ssh/` - - `cp ~/.ssh/config env/etc/ssh/` + - Go to project folder + - Execute setup creator `./bin/m2d setup init` + - Optional: fine tune all setings by editing `.env` file + +## Supported services and tools +### Web Servers +- Apache with PHP: 7.3, 7.4, 8.0, 8.1, 8.2 + +### DB Engines +- MySQL: 5.7, 8.0, 8.0-oracle, and 5.7 as 5, 8.0.28 as 8 +- MariaDB: 10.2, 10.3, 10.4, 10.6, and 10.4 as 10 + +### Search Engines +- Opensearch: 1.2.4 as 1.2, 1.2.4 as 1, 2.5.0 as 2.5, 2.5.0 as 2 +- Elasticsearch: 6.8.23 as 6, 7.16.3 as 7, 7.6.2 as 7.6, 7.7.1 as 7.7, 7.9.3 as 7.9, 7.10.1 as 7.10, 7.16.3 as 7.16, 7.17.9 as 7.17, 8.4.3 as 8, 8.4.3 as 8.4 + +### DB Cache Engines +- Redis: 6.2, 5.0 as 5, 6.0 as 6, 7.0 as 7 + +### Web Cache Engines +- Varnish: 6.0, 6.2, 6.4, 6.5, 7.0, 7.1, and 7.0 as 7, 6.5 as 6 + +### Tools +- Blackfire: latest +- Mailcatcher: latest +- Selenium: 3.14.0 + ## Usage +To work with Magento2Docker you can use `m2d` CLI command located in `bin` of Magento2Docker project. ### Quick Start -Commands should be executed from _env_ directory. -Run make command to run environment. +With Magento2Docker v3 it is super easy to start or stop containers: +```bash +# Display help +./bin/m2d --help -``` -# Build and mount containers (default: php-7.4) -bin/up +# To start containers: +./bin/m2d up + +# To stop containers: +./bin/m2d stop + +# To stop and remove containers and networks: +./bin/m2d down + +# To enable service e.g. mailcatcher +./bin/m2d enable mailcatcher -# Login on web server container -bin/shell +# To disable service e.g. elasticsearch: +./bin/m2d disable search-engine -# Change php version - - For php-7.3: make up73 - - For php-7.4: make up74 - - For php-8.0: make up80 - - For php-8.1: make up81 +# To edit any .env parameter (e.g. PHP version): +./bin/m2d set M2D_WEB_SERVER_PHP_VERSION 8.1 + +# To display any .env parameter (e.g. search engine type): +./bin.m2d show M2D_SEARCH_ENGINE_VENDOR + +# To start containers after enabling or disabling services or editing parameters: +./bin/m2d up --buld ``` + ### How to install a magento inside container - - Login to container `make web` + - Login to container `./bin/m2d go web` - Create a directory e.g: magento2 - - Inside the magento2 directory run `m2install.sh -s composer -v 2.3.3` + - Inside the magento2 directory run `m2install.sh -s composer -v 2.4.6` - Open browser and go to http://magento2.127.0.0.1.nip.io/ ### How to deploy dumps (backups) inside container - Put dumps to src folder on your host machine - - Login to container `make web` + - Login to container `./bin/m2d go web` - Run `m2install.sh` ## How to link Composer versions -Containers for PHP 7.4, PHP 8.0, and PHP 8.1 has Composer 2 because of Magento supports Composer 2 since 2.4.2 -version. +Containers with PHP 7.x have Composer 1 set as default, containers with PHP 8.x have Composer 2 set as default version. ### Usage: -- Login to your container `bin/shell-root` +- Login to container `./bin/m2d go web` - To use composer as default you have two commands: - - Run command `composer-link.sh 1` to use Composer 1 - - Run command `composer-link.sh 2` to use Composer 2 + - Run command `sudo composer-link.sh 1` to use Composer 1 + - Run command `sudo composer-link.sh 2` to use Composer 2 ## How to Enable xDebug @@ -93,8 +127,8 @@ The container already includes PHP xDebug extension. The xDebug extension is dis it is dramatically decrease performance. ### Usage - - Login to your container `make web` - - Run command `xdebug-php.sh 1` + - Login to your container `./bin/m2d go web` + - Run command `sudo xdebug-php.sh 1` - Run IDE (PHPStorm) and press button _Start Listening for PHPDebug Connection_ @@ -110,13 +144,14 @@ it is dramatically decrease performance. Profiling with Blackfire is on-demand. This means that Blackfire adds no overhead for your end users, which makes it safe to use in production. ### Get your Blackfire credentials -Blackfire provides you a free account "Hack" which allows you to run profiles on your development environment. +Blackfire provides you a free account "Hack" which allows you to run profiles on your development environment. - Create account and login here: https://blackfire.io/login - Install Browser Extension https://blackfire.io/docs/integrations/chrome - Go to the page https://blackfire.io/docs/integrations/docker - Define these environment variables from this page on the host system (OSX) - You can save them permanently by putting them into ~/.bash_profile file - - Recreate containers by using command `make up` + - Enable blackfire container `./bin/m2d enable blackfire` + - Recreate containers by using command `./bin/m2d up --build` ## How to run PHPStorm inside container @@ -130,18 +165,17 @@ Blackfire provides you a free account "Hack" which allows you to run profiles on Run the following command inside env directory ``` -make phpstorm +docker-compose -f docker-compose.phpstorm.yml up -d --build ``` ## Todo List ## Contributing 1. Fork this repository. -2. Create your feature branch: `git checkout -b my-new-feature`. +2. Create your feature branch: `git checkout -b feature/my-cool-feature`. 3. Commit your changes: `git commit -am 'Add some feature'`. -4. Push to the branch: `git push origin my-new-feature`. +4. Push to the branch: `git push origin feature/my-cool-feature`. 5. Submit a pull request. ## Credits Special thanks to @snosov and @tshabatyn who share their ideas and inspired to build this project. -