diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..8f111364f --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.DS_Store + +# Ignore everything in the src directory +src/* + +# Except for the src/app directory +!src/app/code/Komoju/ \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 80b81f6d7..000000000 --- a/Dockerfile +++ /dev/null @@ -1,130 +0,0 @@ -FROM php:7.3-fpm-buster - -ARG MAGENTO_VERSION=2.3.4 - -RUN apt-get update && apt-get install -y \ - cron \ - git \ - gzip \ - libbz2-dev \ - libfreetype6-dev \ - libicu-dev \ - libjpeg62-turbo-dev \ - libmcrypt-dev \ - libpng-dev \ - libsodium-dev \ - libssh2-1-dev \ - libxslt1-dev \ - libzip-dev \ - lsof \ - default-mysql-client \ - vim \ - zip - -RUN docker-php-ext-configure \ - gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ - -RUN docker-php-ext-install \ - bcmath \ - bz2 \ - calendar \ - exif \ - gd \ - gettext \ - intl \ - mbstring \ - mysqli \ - opcache \ - pcntl \ - pdo_mysql \ - soap \ - sockets \ - sodium \ - sysvmsg \ - sysvsem \ - sysvshm \ - xsl \ - zip - -RUN cd /tmp \ - && curl -O https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz \ - && tar zxvf ioncube_loaders_lin_x86-64.tar.gz \ - && export PHP_VERSION=$(php -r "echo PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;") \ - && export PHP_EXT_DIR=$(php-config --extension-dir) \ - && cp "./ioncube/ioncube_loader_lin_${PHP_VERSION}.so" "${PHP_EXT_DIR}/ioncube.so" \ - && rm -rf ./ioncube \ - && rm ioncube_loaders_lin_x86-64.tar.gz \ - && docker-php-ext-enable ioncube - -RUN pecl channel-update pecl.php.net \ - && pecl install xdebug - -RUN docker-php-ext-enable xdebug \ - && sed -i -e 's/^zend_extension/\;zend_extension/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini - -## Replace next lines with below commented out version once issue is resolved -# https://github.com/php/pecl-networking-ssh2/pull/36 -# https://bugs.php.net/bug.php?id=78560 -RUN curl -o /tmp/ssh2-1.2.tgz https://pecl.php.net/get/ssh2 \ - && pear install /tmp/ssh2-1.2.tgz \ - && rm /tmp/ssh2-1.2.tgz \ - && docker-php-ext-enable ssh2 -#RUN pecl install ssh2-1.2 \ -# && docker-php-ext-enable ssh2 - -RUN groupadd -g 1000 app \ - && useradd -g 1000 -u 1000 -d /var/www -s /bin/bash app - -RUN apt-get install -y gnupg \ - && curl -sL https://deb.nodesource.com/setup_10.x | bash - \ - && apt-get install -y nodejs \ - && mkdir /var/www/.config /var/www/.npm \ - && chown app:app /var/www/.config /var/www/.npm \ - && npm install -g grunt-cli - -RUN curl -sSLO https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 \ - && chmod +x mhsendmail_linux_amd64 \ - && mv mhsendmail_linux_amd64 /usr/local/bin/mhsendmail - -RUN curl -sS https://getcomposer.org/installer | \ - php -- --version=1.9.0 --install-dir=/usr/local/bin --filename=composer - -RUN curl -s https://packages.blackfire.io/gpg.key | apt-key add - \ - && echo "deb http://packages.blackfire.io/debian any main" | tee /etc/apt/sources.list.d/blackfire.list \ - && apt-get update \ - && apt-get install blackfire-agent blackfire-php - -RUN printf '* *\t* * *\tapp\t%s/usr/local/bin/php /var/www/html/update/cron.php\n' >> /etc/crontab \ - && printf '* *\t* * *\tapp\t%s/usr/local/bin/php /var/www/html/bin/magento cron:run\n' >> /etc/crontab \ - && printf '* *\t* * *\tapp\t%s/usr/local/bin/php /var/www/html/bin/magento setup:cron:run\n#\n' >> /etc/crontab - -COPY docker-conf/www.conf /usr/local/etc/php-fpm.d/ -COPY docker-conf/php.ini /usr/local/etc/php/ -COPY docker-conf/php-fpm.conf /usr/local/etc/ - -##### This is the beginning of our custom code - -RUN mkdir -p /etc/nginx/html /var/www/html /sock \ - && chown -R app:app /etc/nginx /var/www /usr/local/etc/php/conf.d /sock - -RUN cd /tmp \ - && curl -OL http://pubfiles.nexcess.net/magento/ce-packages/magento2-${MAGENTO_VERSION}.tar.gz - -RUN tar xzf /tmp/magento2-${MAGENTO_VERSION}.tar.gz -o -C /var/www/html - -RUN rm /tmp/magento2-${MAGENTO_VERSION}.tar.gz - -# v7.1.0 was the version I initially used when linting, so I decided to pin it -# to that. There's no other special reason, and no reason this can't be bumped -# whenever we want. -RUN npm install -g eslint@7.1.0 - -##### This is the end of our custom code - -USER app:app - -VOLUME /var/www - -WORKDIR /var/www/html - -EXPOSE 9001 diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..af3cfa3bc --- /dev/null +++ b/Makefile @@ -0,0 +1,272 @@ +SHELL := /usr/bin/env bash + +args = `arg="$(filter-out $(firstword $(MAKECMDGOALS)),$(MAKECMDGOALS))" && echo $${arg:-${1}}` + +green = $(shell printf "\e[32;01m$1\e[0m") +yellow = $(shell printf "\e[33;01m$1\e[0m") +red = $(shell printf "\e[33;31m$1\e[0m") + +format = $(shell printf "%-40s %s" "$(call green,bin/$1)" $2) + +comma:= , + +.DEFAULT_GOAL:=help + +%: + @: + +help: + @echo "" + @echo "$(call yellow,Use the following CLI commands:)" + @echo "$(call red,===============================)" + @echo "$(call format,analyse,'Run `phpstan analyse` within the container to statically analyse code, passing in directory to analyse.')" + @echo "$(call format,bash,'Drop into the bash prompt of your Docker container.')" + @echo "$(call format,blackfire,'Disable or enable Blackfire. Accepts argument `disable`, `enable`, or `status`.')" + @echo "$(call format,cache-clean,'Access the cache-clean CLI.')" + @echo "$(call format,check-dependencies,'Provides helpful recommendations for dependencies.')" + @echo "$(call format,cli,'Run any CLI command without going into the bash prompt.')" + @echo "$(call format,clinotty,'Run any CLI command with no TTY.')" + @echo "$(call format,cliq,'Run any CLI command but pipe all output to /dev/null.')" + @echo "$(call format,composer,'Run the composer binary.')" + @echo "$(call format,configure-linux`,'Adds the Docker container IP address to /etc/hosts if not already present. Optionally enables port 9003 for Xdebug')" + @echo "$(call format,copyfromcontainer,'Copy folders or files from container to host.')" + @echo "$(call format,copytocontainer,'Copy folders or files from host to container.')" + @echo "$(call format,create-user,'Create either an admin user or customer account.')" + @echo "$(call format,cron,'Start or stop the cron service.')" + @echo "$(call format,debug-cli,'Enable Xdebug for bin/magento, with an optional argument of the IDE key. Defaults to PHPSTORM.')" + @echo "$(call format,deploy,'Runs the standard Magento deployment process commands. Pass extra locales besides `en_US` via an optional argument.')" + @echo "$(call format,dev-test-run,' Facilitates running PHPUnit tests for a specified test type.')" + @echo "$(call format,dev-urn-catalog-generate,'Generate URNs for PHPStorm and remap paths to local host.')" + @echo "$(call format,devconsole,'Alias for n98-magerun2 dev:console.')" + @echo "$(call format,docker-compose,'Support V1 (`docker-compose`) and V2 (`docker compose`) docker compose command, and use custom configuration files.')" + @echo "$(call format,docker-stats,'Display status for CPU$(comma) memory usage$(comma) and memory limit of currently-running Docker containers.')" + @echo "$(call format,download,'Download & extract specific Magento version to the src directory.')" + @echo "$(call format,fixowns,'This will fix filesystem ownerships within the container.')" + @echo "$(call format,fixperms,'This will fix filesystem permissions within the container.')" + @echo "$(call format,grunt,'Run the grunt binary.')" + @echo "$(call format,install-php-extensions,'Install PHP extension in the container.')" + @echo "$(call format,log,'Monitor the Magento log files. Pass no params to tail all files.')" + @echo "$(call format,magento,'Run the Magento CLI.')" + @echo "$(call format,magento-version,'Determine the Magento version installed in the current environment..')" + @echo "$(call format,mftf,'Run the Magento MFTF.')" + @echo "$(call format,mysql,'Run the MySQL CLI with database config from env/db.env.')" + @echo "$(call format,mysqldump,'Backup the Magento database.')" + @echo "$(call format,n98-magerun2,'Access the n98-magerun2 CLI.')" + @echo "$(call format,node,'Run the node binary.')" + @echo "$(call format,npm,'Run the npm binary.')" + @echo "$(call format,phpcbf,'Auto-fix PHP_CodeSniffer errors with Magento2 options.')" + @echo "$(call format,phpcs,'Run PHP_CodeSniffer with Magento2 options.')" + @echo "$(call format,phpcs-json-report,'Run PHP_CodeSniffer with Magento2 options and save to `report.json` file.')" + @echo "$(call format,pwa-studio,'(BETA) Start the PWA Studio server.')" + @echo "$(call format,redis,'Run a command from the redis container.')" + @echo "$(call format,remove,'Remove all containers.')" + @echo "$(call format,removeall,'Remove all containers$(comma) networks$(comma) volumes and images.')" + @echo "$(call format,removenetwork,'Remove a network associated with the current directory name.')" + @echo "$(call format,removevolumes,'Remove all volumes.')" + @echo "$(call format,restart,'Stop and then start all containers.')" + @echo "$(call format,root,'Run any CLI command as root without going into the bash prompt.')" + @echo "$(call format,rootnotty,'Run any CLI command as root with no TTY.')" + @echo "$(call format,setup,'Run the Magento setup process$(comma) with optional domain name.')" + @echo "$(call format,setup-composer-auth,'Setup authentication credentials for Composer.')" + @echo "$(call format,setup-domain,'Setup Magento domain name.')" + @echo "$(call format,setup-grunt,'Install and configure Grunt JavaScript task runner.')" + @echo "$(call format,setup-install,'Automates the installation process for a Magento instance.')" + @echo "$(call format,setup-integration-tests,'Script to set up integration tests.')" + @echo "$(call format,setup-pwa-studio,'(BETA) Install PWA Studio.')" + @echo "$(call format,setup-pwa-studio-sampledata,'This script makes it easier to install Venia sample data.')" + @echo "$(call format,setup-ssl,'Generate an SSL certificate for one or more domains.')" + @echo "$(call format,setup-ssl-ca,'Generate a certificate authority and copy it to the host.')" + @echo "$(call format,spx,'Disable or enable output compression to enable or disbale SPX.')" + @echo "$(call format,start,'Start all containers.')" + @echo "$(call format,status,'Check the container status.')" + @echo "$(call format,stop,'Stop all project containers.')" + @echo "$(call format,stopall,'Stop all docker running containers.')" + @echo "$(call format,update,'Update your project to the latest version of docker-magento.')" + @echo "$(call format,xdebug,'Disable or enable Xdebug. Accepts argument `disable`, `enable`, or `status`.')" + + +analyse: + @./bin/analyse $(call args) + +bash: + @./usr/bin/env bash + +cache-clean: + @./bin/cache-clean $(call args) + +check-dependencies: + @./bin/check-dependencies + +cli: + @./bin/cli $(call args) + +clinotty: + @./bin/clinotty $(call args) + +cliq: + @./bin/cliq $(call args) + +composer: + @./bin/composer $(call args) + +configure-linux: + @./bin/configure-linux + +copyfromcontainer: + @./bin/copyfromcontainer $(call args) + +copytocontainer: + @./bin/copytocontainer $(call args) + +cron: + @./bin/cron $(call args) + +debug-cli: + @./bin/debug-cli $(call args) + +deploy: + @./bin/deploy $(call args) + +dev-test-run: + @./bin/dev-test-run + +dev-urn-catalog-generate: + @./bin/dev-urn-catalog-generate + +devconsole: + @./bin/devconsole + +docker-compose: + @./bin/docker-compose + +docker-stats: + @./bin/docker-stats + +download: + @./bin/download $(call args) + +fixowns: + @./bin/fixowns $(call args) + +fixperms: + @./bin/fixperms $(call args) + +grunt: + @./bin/grunt $(call args) + +install-php-extensions: + @./bin/install-php-extensions $(call args) + +log: + @./bin/log $(call args) + +magento: + @./bin/magento $(call args) + +magento-version: + @./bin/magento-version + +mftf: + @./bin/mftf $(call args) + +mysql: + @./bin/mysql $(call args) + +mysqldump: + @./bin/mysqldump $(call args) + +n98-magerun2: + @./bin/n98-magerun2 $(call args) + +node: + @./bin/node $(call args) + +npm: + @./bin/npm $(call args) + +phpcbf: + @./bin/phpcbf $(call args) + +phpcs: + @./bin/phpcs $(call args) + +phpcs-json-report: + @./bin/phpcs-json-report $(call args) + +pwa-studio: + @./bin/pwa-studio + +redis: + @./bin/redis $(call args) + +remove: + @./bin/remove + +removeall: + @./bin/removeall + +removenetwork: + @./bin/removenetwork + +removevolumes: + @./bin/removevolumes + +restart: + @./bin/restart $(call args) + +root: + @./bin/root $(call args) + +rootnotty: + @./bin/rootnotty $(call args) + +setup: + @./bin/setup $(call args) + +setup-composer-auth: + @./bin/setup-composer-auth + +setup-domain: + @./bin/setup-domain $(call args) + +setup-grunt: + @./bin/setup-grunt + +setup-install: + @./bin/setup-install $(call args) + +setup-integration-tests: + @./bin/setup-integration-tests + +setup-pwa-studio: + @./bin/setup-pwa-studio $(call args) + +setup-pwa-studio-sampledata: + @./bin/setup-pwa-studio-sampledata $(call args) + +setup-ssl: + @./bin/setup-ssl $(call args) + +setup-ssl-ca: + @./bin/setup-ssl-ca + +spx: + @./bin/spx $(call args) + +start: + @./bin/start $(call args) + +status: + @./bin/status + +stop: + @./bin/stop $(call args) + +stopall: + @./bin/stopall $(call args) + +update: + @./bin/update + +xdebug: + @./bin/xdebug $(call args) diff --git a/bin/analyse b/bin/analyse new file mode 100755 index 000000000..e41bae135 --- /dev/null +++ b/bin/analyse @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +bin/cli vendor/bin/phpstan analyse "$@" diff --git a/bin/bash b/bin/bash index 55d7b0562..5349aac74 100755 --- a/bin/bash +++ b/bin/bash @@ -1,2 +1,2 @@ -#!/bin/bash +#!/usr/bin/env bash bin/cli bash diff --git a/bin/blackfire b/bin/blackfire new file mode 100755 index 000000000..a100f43ef --- /dev/null +++ b/bin/blackfire @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +S=$(bin/clinotty cat /usr/local/etc/php/conf.d/blackfire.ini | grep -iGc '\;extension=blackfire.so'); + +blackfire_status() { + if [[ $S == 1 ]]; then + echo "Blackfire is disabled." + else + echo "Blackfire is enabled." + fi +} + +blackfire_toggle() { + if [[ $S == 1 ]]; then + blackfire_enable + else + blackfire_disable + fi +} + +blackfire_enable() { + if [[ $S == 1 ]]; then + bin/root sed -i -e 's/^;extension=blackfire.so/extension=blackfire.so/g' /usr/local/etc/php/conf.d/blackfire.ini + sleep 1 + bin/restart phpfpm + echo "Blackfire has been enabled." + else + echo "Blackfire is already enabled." + fi +} + +blackfire_disable() { + if [[ $S == 0 ]]; then + bin/root sed -i -e 's/^extension=blackfire.so/;extension=blackfire.so/g' /usr/local/etc/php/conf.d/blackfire.ini + sleep 1 + bin/restart phpfpm + echo "Blackfire has been disabled." + else + echo "Blackfire is already disabled." + fi +} + +firstArgLetter="$(echo "$1" | head -c 1)" + +if [[ $firstArgLetter == "d" ]]; then + blackfire_disable +elif [[ $firstArgLetter == "e" ]]; then + blackfire_enable +elif [[ $firstArgLetter == "t" ]]; then + blackfire_toggle +elif [[ $firstArgLetter == "s" ]]; then + blackfire_status +else + printf "Please specify either 'disable', 'enable', 'status' or 'toggle' as an argument.\nEx: bin/blackfire status\n" +fi diff --git a/bin/cache-clean b/bin/cache-clean new file mode 100755 index 000000000..cd6bf582a --- /dev/null +++ b/bin/cache-clean @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +COMPOSER_GLOBAL=/var/www/.composer-global +CACHE_CLEAN=${COMPOSER_GLOBAL}/vendor/bin/cache-clean.js + +if ! bin/cliq ls $CACHE_CLEAN; then + echo "Installing devtools metapackage, just a moment..." + bin/cliq mkdir -p ${COMPOSER_GLOBAL} + bin/composer require --working-dir=${COMPOSER_GLOBAL} --quiet markshust/magento2-metapackage-devtools-cli:^1.0 + echo "Devtools installed." +fi + +if [ "$1" == "--watch" ]; then + # Kill duplicate watch process + WATCH_PID=$(bin/clinotty ps -eaf | grep "$CACHE_CLEAN --quiet --watch" | grep -v grep | awk '{print $2}') + if [[ "" != "$WATCH_PID" ]]; then + bin/cliq kill -9 "$WATCH_PID" + fi + + # Run watch mode in the background + bin/cliq $CACHE_CLEAN --quiet --watch & +else + bin/cli $CACHE_CLEAN "$@" +fi diff --git a/bin/check-dependencies b/bin/check-dependencies new file mode 100755 index 000000000..e12b5e8d3 --- /dev/null +++ b/bin/check-dependencies @@ -0,0 +1,74 @@ +#!/usr/bin/env bash + +# Define colors for formatting +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Declare arrays for storing common dependencies and Magento versions +declare -a common_dependencies +declare -a magento_versions=("2.4.7" "2.4.6-p5" "2.4.6-p4" "2.4.6-p3" "2.4.6-p2" "2.4.6-p1" "2.4.6" "2.4.5-p7" "2.4.5-p6" "2.4.5-p5" "2.4.5-p4" "2.4.5-p3" "2.4.5-p2" "2.4.5-p1" "2.4.5" "2.4.4-p8" "2.4.4-p7" "2.4.4-p6" "2.4.4-p5" "2.4.4-p4" "2.4.4-p3" "2.4.4-p2" "2.4.4-p1" "2.4.4" "2.4.3-p3" "2.4.2-p2") + +# Assign common dependencies to corresponding Magento versions +common_dependencies[0]="Composer:2.7 Elasticsearch:8.11 OpenSearch:2.12 MariaDB:10.6 MySQL:8.0 PHP:8.3,8.2 RabbitMQ:3.13 Redis:7.2 Varnish:7.5 Apache:2.4 nginx:1.24 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.11.20 'AWS-ElastiCache':Redis7.0 'AWS-Elasticsearch':-- 'AWS-OpenSearch':2.11" +common_dependencies[1]="Composer:2.2 Elasticsearch:8.11,7.17 OpenSearch:2.12 MariaDB:10.6 MySQL:8.0 PHP:8.2,8.1 RabbitMQ:3.12,3.11,3.9 Redis:7.0 Varnish:7.5 Apache:2.4 nginx:1.24 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.16 'AWS-ElastiCache':Redis6.2 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[2]="Composer:2.2 Elasticsearch:8.11,7.17 OpenSearch:2.5 MariaDB:10.6 MySQL:8.0 PHP:8.2,8.1 RabbitMQ:3.11,3.9 Redis:7.0 Varnish:7.3 Apache:2.4 nginx:1.24 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.16 'AWS-ElastiCache':Redis6.2 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[3]="Composer:2.2 Elasticsearch:8.5,7.17 OpenSearch:2.5 MariaDB:10.6 MySQL:8.0 PHP:8.2,8.1 RabbitMQ:3.11,3.9 Redis:7.0 Varnish:7.3 Apache:2.4 nginx:1.24 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.16 'AWS-ElastiCache':Redis6.2 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[4]="Composer:2.2 Elasticsearch:8.5,7.17 OpenSearch:2.5 MariaDB:10.6 MySQL:8.0 PHP:8.2,8.1 RabbitMQ:3.11,3.9 Redis:7.0 Varnish:7.3 Apache:2.4 nginx:1.22 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.16 'AWS-ElastiCache':Redis6.2 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[5]="Composer:2.2 Elasticsearch:8.5,7.17 OpenSearch:2.5 MariaDB:10.6 MySQL:8.0 PHP:8.2,8.1 RabbitMQ:3.11,3.9 Redis:7.0 Varnish:7.3 Apache:2.4 nginx:1.22 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.16 'AWS-ElastiCache':Redis6.2 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[6]="Composer:2.2 Elasticsearch:8.4,7.17 OpenSearch:2.5 MariaDB:10.6 MySQL:8.0 PHP:8.2,8.1 RabbitMQ:3.11,3.9 Redis:7.0 Varnish:7.1 Apache:2.4 nginx:1.22 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.16 'AWS-ElastiCache':Redis6.2 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[7]="Composer:2.2 Elasticsearch:7.17 OpenSearch:1.3 MariaDB:10.4 MySQL:8.0 PHP:8.1 RabbitMQ:3.11,3.9 Redis:7.0 Varnish:7.5 Apache:2.4 nginx:1.24 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.13 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[8]="Composer:2.2 Elasticsearch:7.17 OpenSearch:1.2 MariaDB:10.4 MySQL:8.0 PHP:8.1 RabbitMQ:3.11,3.9 Redis:6.2 Varnish:7.3 Apache:2.4 nginx:1.24 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.13 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[9]="Composer:2.2 Elasticsearch:7.17 OpenSearch:1.2 MariaDB:10.4 MySQL:8.0 PHP:8.1 RabbitMQ:3.11,3.9 Redis:6.2 Varnish:7.3 Apache:2.4 nginx:1.24 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.13 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[10]="Composer:2.2 Elasticsearch:7.17 OpenSearch:1.2 MariaDB:10.4 MySQL:8.0 PHP:8.1 RabbitMQ:3.11,3.9 Redis:6.2 Varnish:7.3 Apache:2.4 nginx:1.22 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.13 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[11]="Composer:2.2 Elasticsearch:7.17 OpenSearch:1.2 MariaDB:10.4 MySQL:8.0 PHP:8.1 RabbitMQ:3.11,3.9 Redis:6.2 Varnish:7.3 Apache:2.4 nginx:1.22 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.13 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[12]="Composer:2.2 Elasticsearch:7.17 OpenSearch:1.2 MariaDB:10.4 MySQL:8.0 PHP:8.1 RabbitMQ:3.9 Redis:6.2 Varnish:7.1 Apache:2.4 nginx:1.22 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.13 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[13]="Composer:2.2 Elasticsearch:7.17 OpenSearch:1.2 MariaDB:10.4 MySQL:8.0 PHP:8.1 RabbitMQ:3.9 Redis:6.2 Varnish:7.0 Apache:2.4 nginx:1.22 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.13 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':7.9 'AWS-OpenSearch':1.2" +common_dependencies[14]="Composer:2.2 Elasticsearch:7.17 OpenSearch:1.2 MariaDB:10.4 MySQL:8.0 PHP:8.1 RabbitMQ:3.9 Redis:6.2 Varnish:7.0 Apache:2.4 nginx:1.22 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.13 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':7.9 'AWS-OpenSearch':1.2" +common_dependencies[15]="Composer:2.2 Elasticsearch:7.17 OpenSearch:1.3 MariaDB:10.4 MySQL:8.0 PHP:8.1 RabbitMQ:3.9 Redis:7.0 Varnish:7.5 Apache:2.4 nginx:1.24 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.13 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[16]="Composer:2.2 Elasticsearch:7.17 OpenSearch:1.2 MariaDB:10.4 MySQL:8.0 PHP:8.1 RabbitMQ:3.9 Redis:6.2 Varnish:7.3 Apache:2.4 nginx:1.24 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.13 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[17]="Composer:2.2 Elasticsearch:7.17 OpenSearch:1.2 MariaDB:10.4 MySQL:8.0 PHP:8.1 RabbitMQ:3.9 Redis:6.2 Varnish:7.3 Apache:2.4 nginx:1.24 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.13 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[18]="Composer:2.2 Elasticsearch:7.17 OpenSearch:1.2 MariaDB:10.4 MySQL:8.0 PHP:8.1 RabbitMQ:3.9 Redis:6.2 Varnish:7.3 Apache:2.4 nginx:1.22 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.13 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[19]="Composer:2.2 Elasticsearch:7.17 OpenSearch:1.2 MariaDB:10.4 MySQL:8.0 PHP:8.1 RabbitMQ:3.9 Redis:6.2 Varnish:7.3 Apache:2.4 nginx:1.22 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.13 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[20]="Composer:2.2 Elasticsearch:7.17 OpenSearch:1.2 MariaDB:10.4 MySQL:8.0 PHP:8.1 RabbitMQ:3.9 Redis:6.2 Varnish:7.1 Apache:2.4 nginx:1.22 'AWS-Aurora-(MySQL)':8.0 'AWS-S3':✔️ 'AWS-MQ':3.9.13 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':-- 'AWS-OpenSearch':1.2" +common_dependencies[21]="Composer:2.1 Elasticsearch:7.16 OpenSearch:1.2 MariaDB:10.4 MySQL:8.0 PHP:8.1 RabbitMQ:3.9 Redis:6.2 Varnish:7.0 Apache:2.4 nginx:1.22 'AWS-Aurora-(MySQL)':5.7 'AWS-S3':✔️ 'AWS-MQ':3.8.11 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':7.9 'AWS-OpenSearch':--" +common_dependencies[22]="Composer:2.1 Elasticsearch:7.16 OpenSearch:1.2 MariaDB:10.4 MySQL:8.0 PHP:8.1 RabbitMQ:3.9 Redis:6.2 Varnish:7.0 Apache:2.4 nginx:1.22 'AWS-Aurora-(MySQL)':5.7 'AWS-S3':✔️ 'AWS-MQ':3.8.11 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':7.9 'AWS-OpenSearch':--" +common_dependencies[23]="Composer:2.1 Elasticsearch:7.16 OpenSearch:1.2 MariaDB:10.4 MySQL:8.0 PHP:8.1 RabbitMQ:3.9 Redis:6.2 Varnish:7.0 Apache:2.4 nginx:1.22 'AWS-Aurora-(MySQL)':5.7 'AWS-S3':✔️ 'AWS-MQ':3.8.11 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':7.9 'AWS-OpenSearch':--" +common_dependencies[24]="Composer:1 Elasticsearch:7.16 OpenSearch:1.2 MariaDB:10.4 MySQL:8.0 PHP:7.4 RabbitMQ:3.8 Redis:6.0 Varnish:6.5 Apache:2.4 nginx:1.18 'AWS-Aurora-(MySQL)':5.7 'AWS-S3':✔️ 'AWS-MQ':3.8.11 'AWS-ElastiCache':Redis6 'AWS-Elasticsearch':7.9 'AWS-OpenSearch':--" +common_dependencies[25]="Composer:1 Elasticsearch:7.9 OpenSearch:-- MariaDB:10.4 MySQL:8.0 PHP:7.4 RabbitMQ:3.8 Redis:6.0 Varnish:6.4 Apache:2.4 nginx:1.18 'AWS-Aurora-(MySQL)':-- 'AWS-S3':✔️ 'AWS-MQ':-- 'AWS-ElastiCache':-- 'AWS-Elasticsearch':-- 'AWS-OpenSearch':--" + +# Function to print available Magento versions +print_magento_versions() { + echo "Available Magento 2 versions:" + for version in "${magento_versions[@]}"; do + echo "$version" + done +} + +# Function to print dependencies for a given Magento version +print_dependencies() { + local version=$1 + local index + for (( index=0; index<${#magento_versions[@]}; index++ )); do + if [[ "${magento_versions[$index]}" == "$version" ]]; then + echo -e "${GREEN}Recommended software dependencies:${NC}" + local dependencies=${common_dependencies[$index]} + IFS=' ' read -ra deps <<< "$dependencies" + for dep in "${deps[@]}"; do + echo " • $dep" + done + return + fi + done + # If the provided Magento version is not recognized, prompt the user to choose a valid version + echo -e "${RED}Magento version not recognized. Please choose a valid version from the list below:${NC}" + print_magento_versions + echo -e "${BLUE}Additional info about system requirements of Magento in the DevDocs at ${YELLOW}https://experienceleague.adobe.com/en/docs/commerce-operations/installation-guide/system-requirements" +} + +# Prompt the user to enter a Magento version and print its dependencies +read -r -p "Enter the Magento 2 version you'd like to check dependencies on: " magento_version + +print_dependencies "$magento_version" diff --git a/bin/cli b/bin/cli index 3956059ac..9763aff9f 100755 --- a/bin/cli +++ b/bin/cli @@ -1,3 +1,3 @@ -#!/bin/bash +#!/usr/bin/env bash [ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit -docker-compose exec phpfpm "$@" +bin/docker-compose exec phpfpm "$@" diff --git a/bin/clinotty b/bin/clinotty index 03f650db1..fbb965d53 100755 --- a/bin/clinotty +++ b/bin/clinotty @@ -1,3 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash [ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit -docker-compose exec -T phpfpm "$@" +# -T: Disable pseudo-tty allocation +bin/docker-compose exec -T phpfpm "$@" diff --git a/bin/cliq b/bin/cliq new file mode 100755 index 000000000..e28ba616a --- /dev/null +++ b/bin/cliq @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +[ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit +# Without stdout and stderr +bin/clinotty "$@" >/dev/null 2>&1 diff --git a/bin/composer b/bin/composer index 12244397f..56e7aa46a 100755 --- a/bin/composer +++ b/bin/composer @@ -1,2 +1,2 @@ -#!/bin/bash +#!/usr/bin/env bash bin/cli composer "$@" diff --git a/bin/configure-linux b/bin/configure-linux new file mode 100755 index 000000000..80d0182ec --- /dev/null +++ b/bin/configure-linux @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +if [ "$(uname)" == "Darwin" ]; then + echo "This script is designed for Linux and will not work properly on macOS." +else + # Get the IP address from the Docker container + docker_ip=$(docker run --rm alpine ip route | awk 'NR==1 {print $3}') + + # Check if the IP address already exists in /etc/hosts + if grep -q "$docker_ip host.docker.internal" /etc/hosts; then + echo "The entry already exists in /etc/hosts. No action needed." + else + # Add a new entry to /etc/hosts + echo "$docker_ip host.docker.internal" | sudo tee -a /etc/hosts + echo "A new entry in the /etc/hosts file has been created" + fi + + # Ask the user whether to execute the iptables command + read -r -p "Do you want to open port 9003 for Xdebug? (y/n): " choice + if [ "$choice" == "y" ]; then + sudo iptables -A INPUT -p tcp --dport 9003 -j ACCEPT + echo "Port 9003 has been opened for xdebug." + fi + + echo "Tasks completed successfully" +fi diff --git a/bin/copyfromcontainer b/bin/copyfromcontainer index bf08dcb2b..8e2dd1b22 100755 --- a/bin/copyfromcontainer +++ b/bin/copyfromcontainer @@ -1,11 +1,18 @@ -#!/bin/bash +#!/usr/bin/env bash [ -z "$1" ] && echo "Please specify a directory or file to copy from container (ex. vendor, --all)" && exit REAL_SRC=$(cd -P "src" && pwd) +if [ ! -d "$REAL_SRC" ]; then + mkdir -p "$REAL_SRC" +fi if [ "$1" == "--all" ]; then - docker cp $(docker-compose ps -q phpfpm|awk '{print $1}'):/var/www/html/./ $REAL_SRC/ + docker cp "$(bin/docker-compose ps -q phpfpm|awk '{print $1}')":/var/www/html/./ "$REAL_SRC/" echo "Completed copying all files from container to host" else - docker cp $(docker-compose ps -q phpfpm|awk '{print $1}'):/var/www/html/$1 $REAL_SRC/ + if [ -f "$1" ] ; then + docker cp "$(bin/docker-compose ps -q phpfpm|awk '{print $1}')":/var/www/html/"$1" "$REAL_SRC/$1" + else + docker cp "$(bin/docker-compose ps -q phpfpm|awk '{print $1}')":/var/www/html/"$1" "$REAL_SRC/$(dirname "$1")" + fi echo "Completed copying $1 from container to host" fi diff --git a/bin/copytocontainer b/bin/copytocontainer index c3f289724..404aadb5c 100755 --- a/bin/copytocontainer +++ b/bin/copytocontainer @@ -1,15 +1,19 @@ -#!/bin/bash +#!/usr/bin/env bash [ -z "$1" ] && echo "Please specify a directory or file to copy to container (ex. vendor, --all)" && exit REAL_SRC=$(cd -P "src" && pwd) if [ "$1" == "--all" ]; then - docker cp $REAL_SRC/./ $(docker-compose ps -q phpfpm|awk '{print $1}'):/var/www/html/ + docker cp "$REAL_SRC/./" "$(bin/docker-compose ps -q phpfpm|awk '{print $1}')":/var/www/html/ echo "Completed copying all files from host to container" bin/fixowns bin/fixperms else - docker cp $REAL_SRC/$1 $(docker-compose ps -q phpfpm|awk '{print $1}'):/var/www/html/ + if [ -f "$REAL_SRC/$1" ]; then + docker cp "$REAL_SRC/${1}" "$(bin/docker-compose ps -q phpfpm|awk '{print $1}')":/var/www/html/"$1" + else + docker cp "$REAL_SRC/${1}" "$(bin/docker-compose ps -q phpfpm|awk '{print $1}')":/var/www/html/"$(dirname "$1")" + fi echo "Completed copying $1 from host to container" - bin/fixowns $1 - bin/fixperms $1 + bin/fixowns "$1" + bin/fixperms "$1" fi diff --git a/bin/create-user b/bin/create-user new file mode 100755 index 000000000..d92b3c86e --- /dev/null +++ b/bin/create-user @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +read -r -p "Create an admin (a) or a customer (c)? [a/c]: " account_type +[[ "$account_type" == [Aa] ]] && read -r -p "Username: " USERNAME +read -r -p "Email: " EMAIL +read -r -p "Password (at least 8 characters): " PASSWORD +read -r -p "First Name: " FIRSTNAME +read -r -p "Last Name: " LASTNAME + +if [[ "$account_type" == [Aa] ]]; then + bin/magento admin:user:create \ + --admin-user="${USERNAME}" \ + --admin-password="${PASSWORD}" \ + --admin-email="${EMAIL}" \ + --admin-firstname="${FIRSTNAME}" \ + --admin-lastname="${LASTNAME}" +elif [[ "$account_type" == [Cc] ]]; then + bin/n98-magerun2 customer:create "${EMAIL}" "${PASSWORD}" "${FIRSTNAME}" "${LASTNAME}" +else + echo "Invalid option. Please choose either a or c." +fi diff --git a/bin/cron b/bin/cron new file mode 100755 index 000000000..70f5689e2 --- /dev/null +++ b/bin/cron @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +[ -z "$1" ] && echo "Please specify a service operation (start|stop|status|restart|reload|force-reload)" && exit +bin/root service cron "$@" +bin/root touch /var/www/html/var/.setup_cronjob_status /var/www/html/var/.update_cronjob_status +bin/root chown app:app /var/www/html/var/.setup_cronjob_status /var/www/html/var/.update_cronjob_status diff --git a/bin/debug-cli b/bin/debug-cli new file mode 100755 index 000000000..d495f98d5 --- /dev/null +++ b/bin/debug-cli @@ -0,0 +1,62 @@ +#!/bin/bash +S=$(bin/clinotty cat /usr/local/etc/php/php.ini | grep -iGc 'xdebug.mode = off'); +R=$(grep -c 'XDEBUG_CONFIG=idekey' ./env/phpfpm.env) + +if [[ -z "$2" ]] + then + platform="PHPSTORM" + else + platform=$2 +fi + +local_debug_status(){ + if [[ $R != 0 ]]; then + echo "Cli debug enabled" + else + echo "Cli debug disabled" + fi +} + +local_debug_toggle() { + if [[ $R != 0 ]]; then + local_debug_disable + else + local_debug_enable + fi +} + +local_debug_enable() { + if [[ $S == 1 ]]; then + bin/xdebug enable + fi + + if [[ $R != 0 ]]; then + echo "Already enabled" + exit 0 + fi + + echo "XDEBUG_CONFIG=idekey=$platform" >> ./env/phpfpm.env + sleep 1 + bin/restart phpfpm + echo "Cli debug enabled" +} + +local_debug_disable() { + sed -i '' '/XDEBUG_CONFIG=idekey/d' ./env/phpfpm.env + sleep 1 + bin/restart phpfpm + echo "Cli debug disabled" +} + +firstArgLetter="$(echo "$1" | head -c 1)" +if [[ $firstArgLetter == "d" ]]; then + local_debug_disable +elif [[ $firstArgLetter == "e" ]]; then + local_debug_enable +elif [[ $firstArgLetter == "t" ]]; then + local_debug_toggle +elif [[ $firstArgLetter == "s" ]]; then + local_debug_status +else + printf "Please specify either 'disable', 'enable', 'status' or 'toggle' as mandatory argument.\nSpecify as an optional second argument the platform. Default is PHPSTORM\nEx: bin/debug-cli enable [PHPSTORM]\n" +fi diff --git a/bin/deploy b/bin/deploy new file mode 100755 index 000000000..2a91bdf25 --- /dev/null +++ b/bin/deploy @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +bin/composer install +bin/magento maintenance:enable +bin/cli rm -rf generated/code var/view_preprocessed +bin/magento cache:flush +bin/magento setup:upgrade +bin/magento setup:di:compile +bin/magento setup:static-content:deploy en_US "$@" -f +bin/magento maintenance:disable +bin/magento cache:flush diff --git a/bin/dev-test-run b/bin/dev-test-run new file mode 100755 index 000000000..7e2d6dcf6 --- /dev/null +++ b/bin/dev-test-run @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +[ -z "$1" ] && echo "Please specify test type (ex. integration)" && exit + +TEST_TYPE="$1" +shift +bin/clinotty bash -c "cd dev/tests/${TEST_TYPE} && ../../../vendor/bin/phpunit -c phpunit.xml.dist $*" diff --git a/bin/dev-urn-catalog-generate b/bin/dev-urn-catalog-generate index 03d870ffe..64fdf5525 100755 --- a/bin/dev-urn-catalog-generate +++ b/bin/dev-urn-catalog-generate @@ -1,14 +1,7 @@ -#!/bin/bash +#!/usr/bin/env bash bin/magento dev:urn-catalog:generate misc.xml bin/copyfromcontainer misc.xml -bin/clinotty rm misc.xml - -REAL_SRC=$(cd -P "src" && pwd) - -sed -i .bak "s?/var/www/html?$PROJECT_DIR$/src?g" $REAL_SRC/misc.xml -rm $REAL_SRC/misc.xml.bak - -mkdir -p $REAL_SRC/.idea -mv $REAL_SRC/misc.xml $REAL_SRC/.idea/misc.xml +mkdir -p src/.idea +mv src/misc.xml src/.idea/misc.xml echo "URN's have been generated, you may now restart PHPStorm" diff --git a/bin/devconsole b/bin/devconsole index 1c00dd7ec..d0030e74e 100755 --- a/bin/devconsole +++ b/bin/devconsole @@ -1,2 +1,2 @@ -#!/bin/bash -bin/cli bin/n98-magerun2.phar dev:console +#!/usr/bin/env bash +bin/n98-magerun2 dev:console diff --git a/bin/docker-compose b/bin/docker-compose new file mode 100755 index 000000000..6d295802c --- /dev/null +++ b/bin/docker-compose @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +if docker compose version > /dev/null 2>&1; then + DOCKER_COMPOSE="docker compose" +else + DOCKER_COMPOSE="docker-compose" +fi + +COMPOSE_FILES=("compose.yaml" "compose.healthcheck.yaml") + +# If --no-dev is passed to this script, we won't load the compose.dev.yaml file, +# but this argument should be removed so it isn't passed to docker compose. +if [ "$1" == "--no-dev" ]; then + # Remove the "--no-dev" argument so it isn't passed to docker compose + shift 1 +else + # The "--no-dev" argument wasn't passed in, so let's load the dev config. + COMPOSE_FILES+=("compose.dev.yaml") +fi + +# Loop over the list of compose files, and prefix them with -f. +# This ensures paths with spaces aren't split when passed as parameters. +COMPOSE_FILES_PREFIXED=() +for file in "${COMPOSE_FILES[@]}"; do + COMPOSE_FILES_PREFIXED+=("-f" "$file") +done + +${DOCKER_COMPOSE} "${COMPOSE_FILES_PREFIXED[@]}" "$@" diff --git a/bin/docker-stats b/bin/docker-stats new file mode 100755 index 000000000..06c60c2de --- /dev/null +++ b/bin/docker-stats @@ -0,0 +1,71 @@ +#!/usr/bin/env bash + +stty -echo + +INTERVAL=3 + +trap 'stty echo; exit' INT EXIT + +print_header() { + echo "+----------------------------------------------------+--------------+----------+----------+------------------------+" + printf "| %-50s | %-12s | %-8s | %-8s | %-22s |\n" "NAME" "CONTAINER ID" "CPU %" "MEM %" "MEM USAGE / MEM LIMIT" + echo "+----------------------------------------------------+--------------+----------+----------+------------------------+" +} + +print_container_info() { + local container_info + local container_name + local container_id + local cpu_perc + local mem_perc + local mem_usage + + container_info="$1" + container_name=$(echo "$container_info" | cut -f1) + container_id=$(echo "$container_info" | cut -f2) + cpu_perc=$(echo "$container_info" | cut -f3) + mem_perc=$(echo "$container_info" | cut -f4) + mem_usage=$(echo "$container_info" | cut -f5) + + +print_container_info() { + local container_info + local container_name + local container_id + local cpu_perc + local mem_perc + local mem_usage + + container_info="$1" + container_name=$(echo "$container_info" | cut -f1) + container_id=$(echo "$container_info" | cut -f2) + cpu_perc=$(echo "$container_info" | cut -f3) + mem_perc=$(echo "$container_info" | cut -f4) + mem_usage=$(echo "$container_info" | cut -f5) + + printf "| %-50s | %-12s | %-8s | %-8s | %-22s |\n" "$container_name" "$container_id" "$cpu_perc" "$mem_perc" "$mem_usage" +} + +} + +while true; do + DOCKER_STATS=$(docker stats --no-stream --format "{{.Name}}\t{{.ID}}\t{{.CPUPerc}}\t{{.MemPerc}}\t{{.MemUsage}}") + + clear + + if [[ -n "$DOCKER_STATS" ]]; then + print_header + + while IFS= read -r line; do + print_container_info "$(echo "$line" | awk '{gsub(/\//, " "); print}')" + done <<< "$DOCKER_STATS" + + echo "+----------------------------------------------------+--------------+----------+----------+------------------------+" + else + echo "No active containers found" + break + fi + + sleep $INTERVAL +done + diff --git a/bin/download b/bin/download new file mode 100755 index 000000000..f0ad09499 --- /dev/null +++ b/bin/download @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +VERSION=${1:-2.4.6-p4} +EDITION=${2:-community} + +# Define ANSI escape codes for colors +YELLOW='\033[0;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +bin/stop + +# if [ -d "./src" ]; then +# echo "Error: The \"src\" directory is not empty. Please remove all contents within this directory and try again." +# exit 1 +# fi + +bin/start --no-dev +[ $? != 0 ] && echo "Failed to start Docker services" && exit + +bin/setup-composer-auth + +bin/fixowns + +if [ "$EDITION" == "mageos-nightly" ]; then + bin/clinotty composer create-project --stability alpha --repository-url=https://upstream-nightly.mage-os.org magento/project-community-edition . +elif [ "$EDITION" == "mageos-mirror" ] || [ "$EDITION" == "mageos" ]; then + bin/clinotty composer create-project --repository-url=https://mirror.mage-os.org magento/project-community-edition="${VERSION}" . +elif [ "$EDITION" == "mageos-hypernode-mirror" ]; then + bin/clinotty composer create-project --repository-url=https://mage-os.hypernode.com/mirror magento/project-community-edition="${VERSION}" . +elif [ "$EDITION" == "mageos-maxcluster-mirror" ]; then + bin/clinotty composer create-project --repository-url=https://mage-os.maxcluster.net/mirror magento/project-community-edition="${VERSION}" . +else + bin/clinotty composer create-project --repository=https://repo.magento.com/ magento/project-"${EDITION}"-edition="${VERSION}" . +fi + +if [ $? != 0 ]; then + echo -e "${BLUE}Please check the installation guide at ${YELLOW}https://github.com/markshust/docker-magento#install-fails-because-project-directory-is-not-empty${BLUE} for troubleshooting.${NC}" +else + bin/clinotty [ ! -f "./var/composer_home/auth.json" ] && bin/clinotty mkdir -p ./var/composer_home && bin/clinotty cp /var/www/.composer/auth.json ./var/composer_home/auth.json +fi diff --git a/bin/fixowns b/bin/fixowns index 78d7f3a3d..52d96f9f0 100755 --- a/bin/fixowns +++ b/bin/fixowns @@ -1,10 +1,10 @@ -#!/bin/bash -echo "Correcting filesystem ownerships..." +#!/usr/bin/env bash +echo "Fixing filesystem ownerships..." if [ -z "$1" ]; then bin/rootnotty chown -R app:app /var/www/ else - bin/rootnotty chown -R app:app /var/www/html/$1 + bin/rootnotty chown -R app:app /var/www/html/"$1" fi -echo "Filesystem ownerships corrected." +echo "Filesystem ownerships fixed." diff --git a/bin/fixperms b/bin/fixperms index 4634750a1..63b2a538d 100755 --- a/bin/fixperms +++ b/bin/fixperms @@ -1,17 +1,11 @@ -#!/bin/bash -echo "Correcting filesystem permissions..." +#!/usr/bin/env bash +echo "Fixing filesystem permissions..." if [ -z "$1" ]; then - bin/clinotty find var vendor pub/static pub/media app/etc -type f -exec chmod u+w {} \; - bin/clinotty find var vendor pub/static pub/media app/etc -type d -exec chmod u+w {} \; + bin/clinotty find var vendor pub/static pub/media app/etc \( -type f -or -type d \) -exec chmod u+w {} +; bin/clinotty chmod u+x bin/magento - bin/clinotty chmod u+x -R vendor/bin - - # updating perms for CodeSniffer directly, since the vendor/bin symlinking is wonky - bin/clinotty chmod u+x -R vendor/squizlabs/php_codesniffer/bin/ else - bin/clinotty find $1 -type f -exec chmod u+w {} \; - bin/clinotty find $1 -type d -exec chmod u+w {} \; + bin/clinotty find "$1" \( -type f -or -type d \) -exec chmod u+w {} +; fi -echo "Filesystem permissions corrected." +echo "Filesystem permissions fixed." diff --git a/bin/generate-translations b/bin/generate-translations deleted file mode 100755 index f8e984537..000000000 --- a/bin/generate-translations +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -bin/magento i18n:collect-phrases -o /var/www/html/app/code/Komoju/Payments/i18n/en_US.csv app/code/Komoju/Payments/ diff --git a/bin/grunt b/bin/grunt index 49871a0e4..1a9d5e80d 100755 --- a/bin/grunt +++ b/bin/grunt @@ -1,2 +1,2 @@ -#!/bin/bash -bin/cli grunt "$@" +#!/usr/bin/env bash +bin/cli npx grunt "$@" diff --git a/bin/install-php-extensions b/bin/install-php-extensions new file mode 100755 index 000000000..06b2e57a2 --- /dev/null +++ b/bin/install-php-extensions @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +if ! bin/cliq ls /usr/local/bin/install-php-extensions; then + echo "Downloading install-php-extensions, just a moment..." + bin/rootnotty curl -sSLf \ + -o /usr/local/bin/install-php-extensions \ + https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions + bin/rootnotty chmod +x /usr/local/bin/install-php-extensions +fi + +bin/root install-php-extensions "$@" diff --git a/bin/lint-autofix b/bin/lint-autofix deleted file mode 100755 index dd0853b5d..000000000 --- a/bin/lint-autofix +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -# auto-fix the PHP code -bin/cli vendor/squizlabs/php_codesniffer/bin/phpcbf --standard=Magento2 --ignore=vendor app/code/Komoju/ - -# auto-fix the ESLint code -bin/cli eslint -c .eslintrc app/code/Komoju/ --ignore-pattern vendor/ --fix \ No newline at end of file diff --git a/bin/lint-check b/bin/lint-check deleted file mode 100755 index c8de2bf55..000000000 --- a/bin/lint-check +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -# lint the PHP code -bin/cli vendor/squizlabs/php_codesniffer/bin/phpcs --standard=Magento2 --ignore=vendor app/code/Komoju/ - -if [ $? -eq 0 ] -then - echo "No PHP linting violations found" -fi - -# lint the JS code -bin/cli eslint -c .eslintrc app/code/Komoju/ --ignore-pattern vendor/ - -if [ $? -eq 0 ] -then - echo "No JavaScript linting violations found" -fi \ No newline at end of file diff --git a/bin/log b/bin/log new file mode 100755 index 000000000..53ff9198d --- /dev/null +++ b/bin/log @@ -0,0 +1,46 @@ +#!/usr/bin/env bash + +CONTAINER_LOG_PATH="/var/www/html/var/log/"; + +display_help() { + echo -e "Description: + Tail logs from the Magento var/log folder all and specific logs + +Usage: + bin/log + +Arguments: + specific_log_files If specific_log_files are NOT provided, show all logs. Ex: bin/log system.log cache.log + +Options: + -h, --help Display help message" +} + +generate_logs_file_path() { + local container_log_path="$1" + shift # This shifts the positional parameters to the left, so $2 becomes $1, $3 becomes $2, etc. + local log_files=("$@") + local log_file_paths=() + + for file in "${log_files[@]}"; do + log_file_paths+=("$container_log_path$file") + done + + echo "${log_file_paths[@]}" +} + +get_all_logs_file_path() { + local logs_location="$1" + + bin/docker-compose exec phpfpm ls -p "$logs_location" | grep -v '/$' | sed "s|^|$logs_location|" +} + +if [[ $1 == "-h" || $1 == "--help" ]]; then + display_help +elif [[ -z $1 ]]; then + mapfile -t all_logs_file_path < <(get_all_logs_file_path "$CONTAINER_LOG_PATH") + bin/docker-compose exec phpfpm tail -f "${all_logs_file_path[@]}" +else + mapfile -t logs_file_path < <(generate_logs_file_path "$CONTAINER_LOG_PATH" "$@") + bin/docker-compose exec phpfpm tail -f "${logs_file_path[@]}" +fi diff --git a/bin/magento b/bin/magento index b176b13b6..d3793e9ae 100755 --- a/bin/magento +++ b/bin/magento @@ -1,16 +1,2 @@ -#!/bin/bash -if [ "$1" == "sampledata:deploy" ]; then - echo "Disabling Temando_Shipping module to fix conflict with deploying sample data." - bin/cli bin/magento module:disable Temando_Shipping - - bin/cli bin/magento sampledata:deploy - - echo "Automatically running setup:upgrade for you to populate sample data!" - bin/cli bin/magento setup:upgrade - - echo "Re-enabling Temando_Shipping module and flushing cache since sample data is now deployed." - bin/cli bin/magento module:enable Temando_Shipping - bin/cli bin/magento cache:flush -else - bin/cli bin/magento "$@" -fi +#!/usr/bin/env bash +bin/cli bin/magento "$@" diff --git a/bin/magento-version b/bin/magento-version new file mode 100755 index 000000000..484622864 --- /dev/null +++ b/bin/magento-version @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# Method 1: Using bin/magento --version +version=$(bin/magento --version --no-ansi 2> /dev/null | cut -d" " -f 3) + +if [[ -z "$version" ]]; then + # Method 2: Using grep in composer.lock + version=$(grep -A 1 "magento/magento2-base" ./src/composer.lock | grep "version" | awk -F "\"" '{print $4}') +fi + +if [[ -z "$version" ]]; then + # Method 3: Using bin/yq in composer.json + version=$(bin/yq -oj '.version' ./src/composer.json | sed 's/"//g') +fi + +# If version is still not obtained, output error message +if [[ -z "$version" ]]; then + echo "Failed to retrieve Magento version." +else + echo "$version" +fi diff --git a/bin/mftf b/bin/mftf new file mode 100755 index 000000000..f76f0a597 --- /dev/null +++ b/bin/mftf @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +bin/clinotty vendor/bin/mftf "$@" \ No newline at end of file diff --git a/bin/mysql b/bin/mysql index 903894306..1e93b9f3c 100755 --- a/bin/mysql +++ b/bin/mysql @@ -1,3 +1,11 @@ -#!/bin/bash +#!/usr/bin/env bash + +# shellcheck source=../env/db.env source env/db.env -bin/cli mysql -hdb -u${MYSQL_USER} -p${MYSQL_PASSWORD} ${MYSQL_DATABASE} "$@" +if [ -t 0 ]; then + # Need tty to run mysql shell + bin/cli mysql -h"${MYSQL_HOST}" -u"${MYSQL_USER}" -p"${MYSQL_PASSWORD}" "${MYSQL_DATABASE}" "$@" +else + # Read from stdin, ex: bin/mysql < dbdump.sql + bin/clinotty mysql -h"${MYSQL_HOST}" -u"${MYSQL_USER}" -p"${MYSQL_PASSWORD}" "${MYSQL_DATABASE}" "$@" +fi diff --git a/bin/mysqldump b/bin/mysqldump new file mode 100755 index 000000000..8f56f769f --- /dev/null +++ b/bin/mysqldump @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +bin/n98-magerun2 db:dump --stdout "$@" diff --git a/bin/n98-magerun2 b/bin/n98-magerun2 index 98adf2f0f..d3b088390 100755 --- a/bin/n98-magerun2 +++ b/bin/n98-magerun2 @@ -1,8 +1,14 @@ -#!/bin/bash -if ! bin/clinotty ls bin/n98-magerun2.phar 1> /dev/null 2>&1; then - bin/clinotty curl -O https://files.magerun.net/n98-magerun2.phar - bin/clinotty chmod +x n98-magerun2.phar - bin/clinotty mkdir -p bin - bin/clinotty mv n98-magerun2.phar bin/n98-magerun2.phar +#!/usr/bin/env bash +if ! bin/cliq ls bin/n98-magerun2.phar; then + echo "Downloading n98-magerun2.phar, just a moment..." + bin/clinotty curl -sS -O https://files.magerun.net/n98-magerun2.phar + bin/clinotty curl -sS -o n98-magerun2.phar.sha256 https://files.magerun.net/sha256.php?file=n98-magerun2.phar + bin/clinotty shasum -a 256 -c n98-magerun2.phar.sha256 + [ $? != 0 ] && echo "sha256 checksum do not match!" && exit + + bin/cliq chmod +x n98-magerun2.phar + bin/cliq mkdir -p bin + bin/cliq mv n98-magerun2.phar bin fi + bin/cli bin/n98-magerun2.phar "$@" diff --git a/bin/node b/bin/node index 5614f8eb9..c33318414 100755 --- a/bin/node +++ b/bin/node @@ -1,2 +1,2 @@ -#!/bin/bash +#!/usr/bin/env bash bin/cli node "$@" diff --git a/bin/npm b/bin/npm index 3bcd6d630..447055673 100755 --- a/bin/npm +++ b/bin/npm @@ -1,2 +1,2 @@ -#!/bin/bash +#!/usr/bin/env bash bin/cli npm "$@" diff --git a/bin/phpcbf b/bin/phpcbf new file mode 100755 index 000000000..dfb0f578d --- /dev/null +++ b/bin/phpcbf @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +bin/clinotty vendor/bin/phpcbf --standard=Magento2 --extensions=php,phtml --error-severity=10 --ignore-annotations "$@" diff --git a/bin/phpcs b/bin/phpcs new file mode 100755 index 000000000..694e69bf5 --- /dev/null +++ b/bin/phpcs @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +bin/clinotty vendor/bin/phpcs --standard=Magento2 --extensions=php,phtml --error-severity=10 --ignore-annotations "$@" diff --git a/bin/phpcs-json-report b/bin/phpcs-json-report new file mode 100755 index 000000000..b7d6da633 --- /dev/null +++ b/bin/phpcs-json-report @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +bin/clinotty vendor/bin/phpcs --standard=Magento2 --extensions=php,phtml --error-severity=10 --ignore-annotations --report=json "$@" > report.json diff --git a/bin/pwa-studio b/bin/pwa-studio index 19e677ba4..8603b1bc2 100755 --- a/bin/pwa-studio +++ b/bin/pwa-studio @@ -1,4 +1,6 @@ -#!/bin/bash +#!/usr/bin/env bash +set -o errexit + if [ ! -d pwa-studio ]; then echo "PWA studio must first be installed by running bin/setup-pwa-studio" exit diff --git a/bin/redis b/bin/redis index 5c678cd93..758967f1b 100755 --- a/bin/redis +++ b/bin/redis @@ -1,2 +1,2 @@ -#!/bin/bash -docker-compose exec redis "$@" +#!/usr/bin/env bash +bin/docker-compose exec redis "$@" diff --git a/bin/remove b/bin/remove index 8ce3dc192..d2c587b26 100755 --- a/bin/remove +++ b/bin/remove @@ -1,2 +1,2 @@ -#!/bin/bash -docker-compose -f docker-compose.yml -f docker-compose.dev.yml rm --stop +#!/usr/bin/env bash +bin/docker-compose rm diff --git a/bin/removeall b/bin/removeall index 3a418f21b..b46b7932b 100755 --- a/bin/removeall +++ b/bin/removeall @@ -1,3 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +bin/stopall bin/remove bin/removevolumes +bin/removenetwork diff --git a/bin/removenetwork b/bin/removenetwork new file mode 100755 index 000000000..3e8d6fc88 --- /dev/null +++ b/bin/removenetwork @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +current_folder=${PWD##*/} +volume_prefix=$(echo "$current_folder" | awk '{print tolower($0)}' | sed 's/\.//g') +docker network rm "$volume_prefix"_default diff --git a/bin/removevolumes b/bin/removevolumes index e3d256f6f..e79d919e6 100755 --- a/bin/removevolumes +++ b/bin/removevolumes @@ -1,8 +1,8 @@ -#!/bin/bash +#!/usr/bin/env bash current_folder=${PWD##*/} -volume_prefix=`echo $current_folder | awk '{print tolower($0)}' | sed 's/\.//g'` -docker volume rm ${volume_prefix}_appdata -docker volume rm ${volume_prefix}_dbdata -docker volume rm ${volume_prefix}_rabbitmqdata -docker volume rm ${volume_prefix}_sockdata -docker volume rm ${volume_prefix}_ssldata +volume_prefix=$(echo "$current_folder" | awk '{print tolower($0)}' | sed 's/\.//g') +docker volume rm "${volume_prefix}"_appdata +docker volume rm "${volume_prefix}"_dbdata +docker volume rm "${volume_prefix}"_rabbitmqdata +docker volume rm "${volume_prefix}"_sockdata +docker volume rm "${volume_prefix}"_ssldata diff --git a/bin/restart b/bin/restart index aae2b1669..b90161cb0 100755 --- a/bin/restart +++ b/bin/restart @@ -1,3 +1,3 @@ -#!/bin/bash -bin/stop -bin/start +#!/usr/bin/env bash +bin/stop "$@" +bin/start "$@" diff --git a/bin/root b/bin/root index 263e45024..461d80404 100755 --- a/bin/root +++ b/bin/root @@ -1,3 +1,3 @@ -#!/bin/bash +#!/usr/bin/env bash [ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit -docker-compose exec -u root phpfpm "$@" +bin/docker-compose exec -u root phpfpm "$@" diff --git a/bin/rootnotty b/bin/rootnotty index 5fb3e22c4..890c003b4 100755 --- a/bin/rootnotty +++ b/bin/rootnotty @@ -1,3 +1,3 @@ -#!/bin/bash +#!/usr/bin/env bash [ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit -docker-compose exec -u root -T phpfpm "$@" +bin/docker-compose exec -u root -T phpfpm "$@" diff --git a/bin/setup b/bin/setup index 333d1d2e6..49abba69a 100755 --- a/bin/setup +++ b/bin/setup @@ -1,100 +1,55 @@ -#!/bin/bash -BASE_URL=${1:-magento2.test} +#!/usr/bin/env bash +set -o errexit -bin/stop +MEM_BYTES=$(docker info -f '{{.MemTotal}}') +MEM_MB=$(( MEM_BYTES / 1000000 )) +# When Docker Desktop is set to 6GB in the GUI, it is reported as 6227 MB +(( MEM_MB < 6227 )) && echo "There must be at least 6GB of RAM allocated to Docker in order to continue." && exit -# fix for invalid google-shopping-api checksum contained in archive installs (temporary fix until nexcess archive is patched) -sed -e 's/5f5929ef9f2ec4ca048a2add261d22c92807630f/ce31e720d60451784b9fdb3769e43e149f50d436/' src/composer.lock > composer.lock && mv composer.lock src/composer.lock +DOMAIN=${1:-magento.test} -docker-compose -f docker-compose.yml up -d -sleep 1 #Ensure containers are started... +bin/stop -bin/fixowns -bin/fixperms +bin/start --no-dev +[ $? != 0 ] && echo "Failed to start Docker services" && exit bin/clinotty chmod u+x bin/magento +#rm -rf src && mkdir src -if hash composer 2>/dev/null; then - PUBLIC_KEY="$(composer config -gl | grep '\[http-basic.repo.magento.com.username\]' | cut -c40-)" - PRIVATE_KEY="$(composer config -gl | grep '\[http-basic.repo.magento.com.password\]' | cut -c40-)" -fi - -if [ -z "$PUBLIC_KEY" ] || [ -z "$PRIVATE_KEY" ]; then - exec < /dev/tty - echo - echo - echo " Authentication required (repo.magento.com, public_key and private_key):" - read -p " Username: " PUBLIC_KEY - read -p " Password: " PRIVATE_KEY - echo - if [ -n "$PUBLIC_KEY" ] && [ -n "$PRIVATE_KEY" ] && hash composer 2>/dev/null; then - read -p " Add authentication information to host composer config? y/n: " ADD_AUTH - echo - if [[ $ADD_AUTH =~ ^[Yy]$ ]]; then - composer global config http-basic.repo.magento.com $PUBLIC_KEY $PRIVATE_KEY - fi - ADD_AUTH='' - fi - exec <&- -fi - -if [ -n "$PUBLIC_KEY" ] && [ -n "$PRIVATE_KEY" ]; then - bin/clinotty composer config http-basic.repo.magento.com $PUBLIC_KEY $PRIVATE_KEY - PUBLIC_KEY='' - PRIVATE_KEY='' -fi - -echo "Forcing reinstall of composer deps to ensure perms & reqs..." -bin/clinotty composer clearcache -bin/clinotty composer global require hirak/prestissimo -bin/clinotty composer install - -bin/clinotty bin/magento setup:install \ - --db-host=db \ - --db-name=magento \ - --db-user=magento \ - --db-password=magento \ - --base-url=https://$BASE_URL/ \ - --admin-firstname=John \ - --admin-lastname=Smith \ - --admin-email=john.smith@gmail.com \ - --admin-user=john.smith \ - --admin-password=password123 \ - --language=en_US \ - --currency=JPY \ - --timezone=Asia/Tokyo \ - --amqp-host=rabbitmq \ - --amqp-port=5672 \ - --amqp-user=guest \ - --amqp-password=guest \ - --amqp-virtualhost=/ \ - --use-rewrites=1 - -echo "Turning on developer mode.." -bin/clinotty bin/magento deploy:mode:set developer +echo "Adding Magento modules to Composer allow-plugins directive..." +bin/clinotty composer config --no-plugins allow-plugins.magento/magento-composer-installer true +bin/clinotty composer config --no-plugins allow-plugins.magento/inventory-composer-installer true +bin/clinotty composer config --no-plugins allow-plugins.laminas/laminas-dependency-plugin true -bin/clinotty bin/magento indexer:reindex +echo "Running, Magento setup:install..." +bin/setup-install "${DOMAIN}" + +echo "Copying files from container to host after install..." +bin/copyfromcontainer --all echo "Forcing deploy of static content to speed up initial requests..." bin/clinotty bin/magento setup:static-content:deploy -f -echo "Enabling Redis for cache..." -bin/clinotty bin/magento setup:config:set --no-interaction --cache-backend=redis --cache-backend-redis-server=redis --cache-backend-redis-db=0 +echo "Re-indexing with Elasticsearch..." +bin/clinotty bin/magento indexer:reindex -echo "Enabling Redis for Full Page Cache..." -bin/clinotty bin/magento setup:config:set --no-interaction --page-cache=redis --page-cache-redis-server=redis --page-cache-redis-db=1 +echo "Setting basic URL and generating SSL certificate..." +bin/setup-domain "${DOMAIN}" -echo "Enabling Redis for session..." -bin/clinotty bin/magento setup:config:set --no-interaction --session-save=redis --session-save-redis-host=redis --session-save-redis-log-level=4 --session-save-redis-db=2 +echo "Fixing owner and permissions..." +bin/fixowns +bin/fixperms -echo "Clearing the cache for good measure..." +echo "Clearing the cache to apply updates..." bin/clinotty bin/magento cache:flush -echo "Restarting containers to allow changes to take affect" -bin/restart +echo "Installing cron, run 'bin/cron start' to enable..." +bin/clinotty bin/magento cron:install + +echo "Turning on developer mode..." +bin/clinotty bin/magento deploy:mode:set developer -echo "Enabling Komoju Payments module" -bin/clinotty bin/magento setup:upgrade +cp -r .vscode src/ echo "Docker development environment setup complete." -echo "You may now access your Magento instance at https://${BASE_URL}/" +echo "You may now access your Magento instance at https://${DOMAIN}/" diff --git a/bin/setup-composer-auth b/bin/setup-composer-auth new file mode 100755 index 000000000..c2eb922f8 --- /dev/null +++ b/bin/setup-composer-auth @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +MAGENTO_USERNAME_PROP="http-basic.repo.magento.com.username" +MAGENTO_PASSWORD_PROP="http-basic.repo.magento.com.password" +hash composer 2>/dev/null && IS_COMPOSER_ON_HOST=true + +PUBLIC_KEY="$(bin/clinotty composer config --global $MAGENTO_USERNAME_PROP 2>/dev/null)" +PRIVATE_KEY="$(bin/clinotty composer config --global $MAGENTO_PASSWORD_PROP 2>/dev/null)" + +if [ -n "$PUBLIC_KEY" ] && [ -n "$PRIVATE_KEY" ]; then + echo "Composer auth has already been set up." + exit 0 +fi + +if [ "$IS_COMPOSER_ON_HOST" ]; then + PUBLIC_KEY="$(composer config --global $MAGENTO_USERNAME_PROP 2>/dev/null)" + PRIVATE_KEY="$(composer config --global $MAGENTO_PASSWORD_PROP 2>/dev/null)" +fi + +if [ -z "$PUBLIC_KEY" ] || [ -z "$PRIVATE_KEY" ]; then + exec < /dev/tty + echo + echo "Composer authentication required (repo.magento.com public and private keys):" + read -r -p " Username: " PUBLIC_KEY + read -r -p " Password: " PRIVATE_KEY + echo + exec <&- +fi + +if [ -z "$PUBLIC_KEY" ] || [ -z "$PRIVATE_KEY" ]; then + echo "Please setup Composer auth for repo.magento.com to continue." && exit 1 +fi + +# Output must be piped otherwise file descriptor errors occur. Carriage returns? +echo "composer config --global http-basic.repo.magento.com ${PUBLIC_KEY} ${PRIVATE_KEY}" | bin/clinotty bash - + +# Also make sure alternate auth.json is setup (Magento uses this internally) +bin/clinotty [ -d "./var/composer_home" ] && bin/clinotty cp /var/www/.composer/auth.json ./var/composer_home/auth.json + +echo "Composer auth has been set up." diff --git a/bin/setup-domain b/bin/setup-domain new file mode 100755 index 000000000..79d544abb --- /dev/null +++ b/bin/setup-domain @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -o errexit + +[ -z "$1" ] && echo "Please specify a domain name (ex. magento.test)" && exit + +DOMAIN=$1 + +if ! grep -q "$DOMAIN" /etc/hosts; then + echo "Your system password is needed to add an entry to /etc/hosts..." + echo "127.0.0.1 ::1 $DOMAIN" | sudo tee -a /etc/hosts +fi + +echo "Set https://${DOMAIN}/ to web/secure/base_url and web/unsecure/base_url" +bin/clinotty bin/magento config:set web/secure/base_url https://"$DOMAIN"/ +bin/clinotty bin/magento config:set web/unsecure/base_url https://"$DOMAIN"/ + +echo "Generating SSL certificate..." +bin/setup-ssl "$DOMAIN" diff --git a/bin/setup-grunt b/bin/setup-grunt new file mode 100755 index 000000000..b4b5ab1c6 --- /dev/null +++ b/bin/setup-grunt @@ -0,0 +1,64 @@ +#!/usr/bin/env bash +echo "Confirming n98-magerun2 is installed..." +bin/n98-magerun2 > /dev/null 2>&1 + +DEFAULT_THEME_ID="select value from core_config_data where path = 'design/theme/theme_id'" +THEME_PATH="select theme_path from theme where theme_id in ($DEFAULT_THEME_ID);" +VENDOR_THEME=$(bin/n98-magerun2 db:query "$THEME_PATH" | sed -n 2p | cut -d$'\r' -f1) +THEME=$(echo "$VENDOR_THEME" | cut -d'/' -f2) +LOCALE_CODE=$(bin/magento config:show general/locale/code | cut -d$'\r' -f1 | sed 's/ *$//g') + +# Generate local-theme.js for custom theme +read -r -d '' GEN_THEME_JS << EOM +var fs = require('fs'); +var util = require('util'); +var theme = require('./dev/tools/grunt/configs/themes'); + +theme['$THEME'] = { + area: 'frontend', + name: '$VENDOR_THEME', + locale: '$LOCALE_CODE', + files: [ + 'css/styles-m', + 'css/styles-l' + ], + dsl: 'less' +}; +fs.writeFileSync('./dev/tools/grunt/configs/local-themes.js', '"use strict"; module.exports = ' + util.inspect(theme), 'utf-8'); +EOM + +if [ -z "$VENDOR_THEME" ] || [ -z "$THEME" ]; then + echo "Using Magento/luma theme for grunt config" + THEME=luma + bin/clinotty cp ./dev/tools/grunt/configs/themes.js ./dev/tools/grunt/configs/local-themes.js +else + echo "Using $VENDOR_THEME theme for grunt config" + bin/node -e "$GEN_THEME_JS" +fi + +# Create files from sample files if they do not yet exist +test -f src/package.json || cp src/package.json.sample src/package.json +test -f src/Gruntfile.js || cp src/Gruntfile.js.sample src/Gruntfile.js +test -f src/grunt-config.json || cp src/grunt-config.json.sample src/grunt-config.json + +# Disable grunt-contrib-jasmine on ARM processors (incompatible) +if [ "$(uname -m)" == "arm64" ]; then + sed -e 's/"grunt-contrib-jasmine": "[~.0-9]*",//' src/package.json > package.json \ + && mv package.json src/package.json +fi + +# Enable these custom files on compose.dev.yaml so custom updates are persisted +sed -e 's/grunt-config.json.sample/grunt-config.json/' compose.dev.yaml > compose.dev.yaml.updated \ + && mv compose.dev.yaml.updated compose.dev.yaml +sed -e 's/Gruntfile.js.sample/Gruntfile.js/' compose.dev.yaml > compose.dev.yaml.updated \ + && mv compose.dev.yaml.updated compose.dev.yaml +sed -e 's/package.json.sample/package.json/' compose.dev.yaml > compose.dev.yaml.updated \ + && mv compose.dev.yaml.updated compose.dev.yaml +bin/restart app phpfpm + +bin/npm install ajv@^5.0.0 --save +bin/npm install +bin/magento cache:clean +bin/grunt clean +bin/grunt exec:"$THEME" +bin/grunt less:"$THEME" diff --git a/bin/setup-install b/bin/setup-install new file mode 100755 index 000000000..afc151768 --- /dev/null +++ b/bin/setup-install @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +set -o errexit + +DOMAIN=${1:-magento.test} + +# shellcheck source=../env/db.env +source env/db.env +# shellcheck source=../env/elasticsearch.env +source env/elasticsearch.env +# shellcheck source=../env/opensearch.env +source env/opensearch.env +# shellcheck source=../env/magento.env +source env/magento.env +# shellcheck source=../env/rabbitmq.env +source env/rabbitmq.env +# shellcheck source=../env/redis.env +source env/redis.env + +bin/clinotty bin/magento setup:install \ + --db-host="$MYSQL_HOST" \ + --db-name="$MYSQL_DATABASE" \ + --db-user="$MYSQL_USER" \ + --db-password="$MYSQL_PASSWORD" \ + --base-url=https://"$DOMAIN"/ \ + --base-url-secure=https://"$DOMAIN"/ \ + --backend-frontname="$MAGENTO_ADMIN_FRONTNAME" \ + --admin-firstname="$MAGENTO_ADMIN_FIRST_NAME" \ + --admin-lastname="$MAGENTO_ADMIN_LAST_NAME" \ + --admin-email="$MAGENTO_ADMIN_EMAIL" \ + --admin-user="$MAGENTO_ADMIN_USER" \ + --admin-password="$MAGENTO_ADMIN_PASSWORD" \ + --language="$MAGENTO_LOCALE" \ + --currency="$MAGENTO_CURRENCY" \ + --timezone="$MAGENTO_TIMEZONE" \ + --amqp-host="$RABBITMQ_HOST" \ + --amqp-port="$RABBITMQ_PORT" \ + --amqp-user="$RABBITMQ_DEFAULT_USER" \ + --amqp-password="$RABBITMQ_DEFAULT_PASS" \ + --amqp-virtualhost="$RABBITMQ_DEFAULT_VHOST" \ + --cache-backend=redis \ + --cache-backend-redis-server="$REDIS_CACHE_BACKEND_SERVER" \ + --cache-backend-redis-db="$REDIS_CACHE_BACKEND_DB" \ + --page-cache=redis \ + --page-cache-redis-server="$REDIS_PAGE_CACHE_SERVER" \ + --page-cache-redis-db="$REDIS_PAGE_CACHE_DB" \ + --session-save=redis \ + --session-save-redis-host="$REDIS_SESSION_SAVE_HOST" \ + --session-save-redis-log-level=4 \ + --session-save-redis-db=2 \ + --elasticsearch-host="$ES_HOST" \ + --elasticsearch-port="$ES_PORT" \ + --opensearch-host="$OPENSEARCH_HOST" \ + --opensearch-port="$OPENSEARCH_PORT" \ + --search-engine=opensearch \ + --use-rewrites=1 \ + --cleanup-database \ + --no-interaction diff --git a/bin/setup-integration-tests b/bin/setup-integration-tests new file mode 100755 index 000000000..07b57f697 --- /dev/null +++ b/bin/setup-integration-tests @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# shellcheck source=../env/db.env +source env/db.env + +MYSQL_INTEGRATION_CONFIG=dev/tests/integration/etc/install-config-mysql.php + +# If database doesn't exist, create it and add user permissions +bin/clinotty mysql -h"${MYSQL_INTEGRATION_HOST}" -uroot -p"${MYSQL_ROOT_PASSWORD}" "${MYSQL_INTEGRATION_DATABASE}" -e exit &> /dev/null || + bin/clinotty mysqladmin -h"${MYSQL_INTEGRATION_HOST}" -uroot -p"${MYSQL_ROOT_PASSWORD}" create "${MYSQL_INTEGRATION_DATABASE}" && + echo "Database ${MYSQL_INTEGRATION_DATABASE} created." && + bin/cli mysql -uroot -p"${MYSQL_ROOT_PASSWORD}" -h"${MYSQL_INTEGRATION_HOST}" \ + -e "GRANT ALL PRIVILEGES ON ${MYSQL_INTEGRATION_DATABASE}.* TO '${MYSQL_INTEGRATION_USER}'@'%';FLUSH PRIVILEGES;" + +if [[ ! -f "src/${MYSQL_INTEGRATION_CONFIG}" ]]; then + MAGENTO_MAJOR=$(bin/magento-version | cut -d'.' -f1,2) + cp template/"${MYSQL_INTEGRATION_CONFIG}"."${MAGENTO_MAJOR}".dist src/${MYSQL_INTEGRATION_CONFIG} +fi + +bin/copytocontainer ${MYSQL_INTEGRATION_CONFIG} diff --git a/bin/setup-pwa-studio b/bin/setup-pwa-studio index f893cddbb..f546ba7bf 100755 --- a/bin/setup-pwa-studio +++ b/bin/setup-pwa-studio @@ -1,4 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash +set -o errexit echo "Install NodeJS and Yarn on host machine, otherwise setup will fail" BASE_URL=${1:-master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud} diff --git a/bin/setup-pwa-studio-sampledata b/bin/setup-pwa-studio-sampledata new file mode 100755 index 000000000..ead888e42 --- /dev/null +++ b/bin/setup-pwa-studio-sampledata @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +set +e + +RED='\033[0;31m' +GREEN='\033[0;32m' +NC='\033[0m' + +BASE_URL=${1:-master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud} + +install_sampledata() { + echo -e "${GREEN}Setting up composer repository for Venia sample data.${NC}" + bin/composer config --no-interaction --ansi repositories.venia-sample-data composer https://repo.magento.com + + echo -e "${GREEN}Requiring Venia sample data metapackage.${NC}" + bin/composer require --no-interaction --ansi magento/venia-sample-data:* + + echo -e "${GREEN}Installing Venia sample data modules.${NC}" + bin/magento setup:upgrade + + echo -e "${GREEN}Reindexing the data from the modules.${NC}" + bin/magento indexer:reindex +} + +install_sampledata + +ENV_DIST_FILE="packages/venia-concept/.env.dist" +if [ -f "$ENV_DIST_FILE" ]; then + cp "$ENV_DIST_FILE" packages/venia-concept/.env +else + echo -e "${RED}.env.dist file not found. Continuing without copying.${NC}" +fi + +echo -e "${GREEN}Script completed successfully.${NC}" +echo "You may now access your Magento PWA Studio instance at https://${BASE_URL}/" diff --git a/bin/setup-ssl b/bin/setup-ssl index 30bebb2fd..9d8f29e3c 100755 --- a/bin/setup-ssl +++ b/bin/setup-ssl @@ -1,16 +1,17 @@ -#!/bin/bash +#!/usr/bin/env bash [ -z "$1" ] && echo "Please specify a domain (ex. mydomain.test)" && exit # Generate certificate authority if not already setup -if ! docker-compose exec -T -u root app cat /root/.local/share/mkcert/rootCA.pem | grep -q 'BEGIN CERTIFICATE'; then +if ! bin/docker-compose exec -T -u root app cat /root/.local/share/mkcert/rootCA.pem | grep -q 'BEGIN CERTIFICATE'; then bin/setup-ssl-ca fi # Generate the certificate for the specified domain -docker-compose exec -T -u root app mkcert -key-file nginx.key -cert-file nginx.crt "$@" +DOMAIN_WITHOUT_PORT=$(echo "$@" | cut -d ':' -f1) +bin/docker-compose exec -T -u root app mkcert -key-file nginx.key -cert-file nginx.crt "$DOMAIN_WITHOUT_PORT" echo "Moving key and cert to /etc/nginx/certs/..." -docker-compose exec -T -u root app chown app:app nginx.key nginx.crt -docker-compose exec -T -u root app mv nginx.key nginx.crt /etc/nginx/certs/ +bin/docker-compose exec -T -u root app chown app:app nginx.key nginx.crt +bin/docker-compose exec -T -u root app mv nginx.key nginx.crt /etc/nginx/certs/ # Restart nginx to apply the updates echo "Restarting containers to apply updates..." diff --git a/bin/setup-ssl-ca b/bin/setup-ssl-ca index dca8efbf8..91f48120f 100755 --- a/bin/setup-ssl-ca +++ b/bin/setup-ssl-ca @@ -1,6 +1,70 @@ -#!/bin/bash -docker-compose exec -T -u root app mkcert -install -docker cp $(docker-compose ps -q app|awk '{print $1}'):/root/.local/share/mkcert/rootCA.pem . +#!/usr/bin/env bash +set -o errexit +# Generate a new local CA "/root/.local/share/mkcert" +bin/docker-compose exec -T -u root app mkcert -install + +docker cp "$(bin/docker-compose ps -q app|awk '{print $1}')":/root/.local/share/mkcert/rootCA.pem . echo "System password requested to install certificate authority on host..." -sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain rootCA.pem -rm rootCA.pem + +if [ "$(uname)" == "Darwin" ]; then + sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain rootCA.pem + + ### Check if Firefox is installed + FFoxBin="/Applications/Firefox.app/Contents/MacOS/firefox-bin" + if [ -f "$FFoxBin" ]; then + echo "{\"policies\": {\"Certificates\": {\"ImportEnterpriseRoots\": true}}}" | sudo tee policies.json + + ### Check if distribution directory exists + DistDirectory="/Applications/Firefox.app/Contents/Resources/distribution" + if [ ! -d "$DistDirectory" ]; then + sudo mkdir -p "$DistDirectory" + fi + ### Move the newly created policies.json to the Certificates directory + sudo mv policies.json "$DistDirectory"/policies.json + + ### Check if Certificates directory exists + CertDirectory="/Library/Application Support/Mozilla/Certificates" + if [ ! -d "$CertDirectory" ]; then + sudo mkdir -p "$CertDirectory" + fi + + ### Move the newly created .pem to the Certificates directory + sudo mv rootCA.pem "$CertDirectory"/rootCA.pem + else + sudo rm rootCA.pem + fi + +else + + ### Requirement: apt install libnss3-tools + REQUIRED_PKG="libnss3-tools" + PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $REQUIRED_PKG|grep "install ok installed") + echo Checking for $REQUIRED_PKG: "$PKG_OK" + if [ "" = "$PKG_OK" ]; then + echo "No $REQUIRED_PKG found. Setting up $REQUIRED_PKG." + sudo apt-get --yes install $REQUIRED_PKG + fi + + ### CA file to install (CUSTOMIZE!) + certfile="rootCA.pem" + certname="Root CA" + + ### For cert8 (legacy - DBM) + find ~/ -name "cert8.db" -print0 | while read -r certDB + do + certdir=$(dirname "${certDB}"); + certutil -D -n "${certname}" -i ${certfile} -d dbm:"${certdir}" + certutil -A -n "${certname}" -t "TCu,Cu,Tu" -i ${certfile} -d dbm:"${certdir}" + done + + ### For cert9 (SQL) + find ~/ -name "cert9.db" -print0 | while read -r certDB + do + certdir=$(dirname "${certDB}"); + certutil -D -n "${certname}" -i ${certfile} -d sql:"${certdir}" + certutil -A -n "${certname}" -t "TCu,Cu,Tu" -i ${certfile} -d sql:"${certdir}" + done + + sudo mv rootCA.pem /usr/local/share/ca-certificates/rootCA.crt + sudo update-ca-certificates +fi diff --git a/bin/spx b/bin/spx new file mode 100755 index 000000000..df63ca610 --- /dev/null +++ b/bin/spx @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +S=$(bin/clinotty cat /usr/local/etc/php/php.ini | grep -iGc 'zlib.output_compression = 1'); + +spx_status() { + if [[ $S == 1 ]]; then + echo "Output compression is enabled, so you cannot currently debug with SPX." + else + echo "Output compression is disabled, so you can currently debug with SPX." + fi +} + +spx_toggle() { + if [[ $S == 1 ]]; then + spx_enable + else + spx_disable + fi +} + +spx_enable() { + if [[ $S == 1 ]]; then + bin/root sed -i -e 's/^zlib.output_compression = 1/zlib.output_compression = 0/g' /usr/local/etc/php/php.ini + sleep 1 + bin/restart phpfpm + echo "Output compression is now disabled, so you can start debugging with SPX." + else + echo "Output compression is already disabled, so you can start debugging with SPX." + fi +} + +spx_disable() { + if [[ $S == 0 ]]; then + bin/root sed -i -e 's/^zlib.output_compression = 0/zlib.output_compression = 1/g' /usr/local/etc/php/php.ini + sleep 1 + bin/restart phpfpm + echo "Output compression is now enabled, so you can no longer debug with SPX." + else + echo "Output compression is already enabled, so you can no longer debug with SPX." + fi +} + +firstArgLetter="$(echo "$1" | head -c 1)" + +if [[ $firstArgLetter == "d" ]]; then + spx_disable +elif [[ $firstArgLetter == "e" ]]; then + spx_enable +elif [[ $firstArgLetter == "t" ]]; then + spx_toggle +elif [[ $firstArgLetter == "s" ]]; then + spx_status +else + printf "Please specify either 'disable', 'enable', 'status' or 'toggle' as an argument.\nEx: bin/spx status\n" +fi diff --git a/bin/start b/bin/start index 9bd94f474..0c61421cc 100755 --- a/bin/start +++ b/bin/start @@ -1,9 +1,69 @@ -#!/bin/bash -docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --remove-orphans +#!/usr/bin/env bash +set -o errexit + +MEM=$(docker info | grep "Total Memory" | cut -d':' -f2 | xargs | sed s/GiB//) +# Docker reports RAM 0.2 less than what it is actually set to +(( $(echo "$MEM < 5.7" | bc -l) )) && echo "There must be at least 6GB of RAM allocated to Docker to continue." && exit + +if [ "$1" == "--no-dev" ]; then + bin/docker-compose --no-dev up -d --remove-orphans "${@:2}" + exit $? +fi + +# Ref: https://stackoverflow.com/a/51789677/9821321 +function parseYaml { + local s + local w + local fs + s='[[:space:]]*' + w='[a-zA-Z0-9_]*' + fs=$(echo @|tr @ '\034') + sed -ne "s|,$s\]$s\$|]|" \ + -e "s|^\($s\)\($w\)$s:$s\[$s\(.*\)$s\]|\1\2:\n\1 - \3|;p" "$1" | \ + sed -ne "s|,$s}$s\$|}|" \ + -e "s|^\($s\)-$s{$s\(.*\)$s}|\1-\n\1 \2|;p" | \ + sed -ne "s|^\($s\):|\1|" \ + -e "s|^\($s\)-$s{[\"']\(.*\)[\"']}$s\$|\1$fs$fs\2|p" \ + -e "s|^\($s\)-$s\(.*\)$s\$|\1$fs$fs\2|p" \ + -e "s|^\($s\)\($w\)$s:$s{[\"']\(.*\)[\"']}$s\$|\1$fs\2$fs\3|p" \ + -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" | \ + awk -F"$fs" '{ + indent = length($1)/2; + vname[indent] = $2; + for (i in vname) {if (i > indent) {delete vname[i]; idx[i]=0}} + if (length($2) == 0) {vname[indent] = ++idx[indent] }; + if (length($3) > 0) { + vn=""; for (i=0; i/dev/null || exit 1' + interval: 5s + timeout: 5s + retries: 30 + + #elasticsearch: + # healthcheck: + # test: 'curl --fail elasticsearch:9200/_cat/health >/dev/null || exit 1' + # interval: 5s + # timeout: 5s + # retries: 30 + + rabbitmq: + healthcheck: + test: 'rabbitmq-diagnostics -q ping' + interval: 5s + timeout: 5s + retries: 30 + + mailcatcher: + healthcheck: + test: 'wget --no-verbose --tries=1 --spider 127.0.0.1:1080 || exit 1' diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 000000000..82bcf4e54 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,148 @@ +## Mark Shust's Docker Configuration for Magento +## (https://github.com/markshust/docker-magento) +## +## Version 47.0.1 + +## To use SSH, see https://github.com/markshust/docker-magento#ssh +## Linux users, see https://github.com/markshust/docker-magento#linux + +## If you changed the default Docker network, you may need to replace +## 172.17.0.1 in this file with the result of: +## docker network inspect bridge --format='{{(index .IPAM.Config 0).Gateway}}' + +services: + app: + image: markoshust/magento-nginx:1.24-0 + ports: + - "80:8000" + - "443:8443" + volumes: &appvolumes + - ~/.composer:/var/www/.composer:cached + - ~/.ssh/id_rsa:/var/www/.ssh/id_rsa:cached + - ~/.ssh/known_hosts:/var/www/.ssh/known_hosts:cached + - appdata:/var/www/html + - sockdata:/sock + - ssldata:/etc/nginx/certs + #extra_hosts: &appextrahosts + ## Selenium support, replace "magento.test" with URL of your site + #- "magento.test:172.17.0.1" + ## Linux, uncomment for Xdebug capabilities: + #- "host.docker.internal:host-gateway" + + phpfpm: + image: markoshust/magento-php:8.3-fpm-2 + volumes: *appvolumes + env_file: env/phpfpm.env + #extra_hosts: *appextrahosts + + db: + image: mariadb:10.6 + command: + --max_allowed_packet=64M + --optimizer_use_condition_selectivity=1 + --optimizer_switch="rowid_filter=off" + ports: + - "3306:3306" + env_file: env/db.env + volumes: + - dbdata:/var/lib/mysql + + ## If you wish to use MySQL, comment out the mariadb db image above and + ## uncomment this block. + #db: + # image: mysql:8.0 + # command: + # --max_allowed_packet=64M + # --optimizer_use_condition_selectivity=1 + # --optimizer_switch="rowid_filter=off" + # ports: + # - "3306:3306" + # env_file: env/db.env + # volumes: + # - dbdata:/var/lib/mysql + + redis: + image: redis:7.2-alpine + ports: + - "6379:6379" + + opensearch: + image: markoshust/magento-opensearch:2.12-0 + ports: + - "9200:9200" + - "9300:9300" + env_file: env/opensearch.env + environment: + - "discovery.type=single-node" + ## Avoid test failures due to small disks + ## More info at https://github.com/markshust/docker-magento/issues/488 + - "cluster.routing.allocation.disk.threshold_enabled=false" + - "index.blocks.read_only_allow_delete" + ## Uncomment to set custom heap size to avoid memory errors + #- "OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g" + ## Uncomment to increase the virtual memory map count + #- "max_map_count=262144" + + ## If you wish to use Elasticsearch, comment out opensearch image above and + ## uncomment this block. Do the same in the composer.healthcheck.yaml file. + # Additionally, if you are performing the manual setup, you will need to + # update the bin/setup command to use the $ES_HOST variable as the value for + # the --elasticsearch-host argument passed to bin/magento setup:install. + #elasticsearch: + # image: markoshust/magento-elasticsearch:8.13-0 + # ports: + # - "9200:9200" + # - "9300:9300" + # env_file: env/elasticsearch.env + # environment: + # - "discovery.type=single-node" + # ## Avoid test failures due to small disks + # ## More info at https://github.com/markshust/docker-magento/issues/488 + # - "cluster.routing.allocation.disk.threshold_enabled=false" + # - "index.blocks.read_only_allow_delete" + # ## Uncomment to set custom heap size to avoid memory errors + # #- "ES_JAVA_OPTS=-Xms1g -Xmx1g" + # ## Uncomment to increase the virtual memory map count + # #- "max_map_count=262144" + + rabbitmq: + image: markoshust/magento-rabbitmq:3.12-0 + ports: + - "15672:15672" + - "5672:5672" + volumes: + - rabbitmqdata:/var/lib/rabbitmq + env_file: env/rabbitmq.env + + mailcatcher: + image: sj26/mailcatcher + ports: + - "1080:1080" + + ## Cloudflare tunnel support, uncomment to enable + #tunnel: + # container_name: cloudflared-tunnel + # image: cloudflare/cloudflared:latest + # command: tunnel run + # env_file: env/cloudflare.env + + ## Blackfire support, uncomment to enable + #blackfire: + # image: blackfire/blackfire:2 + # ports: + # - "8307" + # env_file: env/blackfire.env + + ## Selenium support, uncomment to enable + #selenium: + # image: selenium/standalone-chrome-debug:3.8.1 + # ports: + # - "5900:5900" + # extra_hosts: *appextrahosts + +volumes: + appdata: + dbdata: + rabbitmqdata: + sockdata: + ssldata: diff --git a/composer.json b/composer.json index 8f8bb4b42..35d414568 100644 --- a/composer.json +++ b/composer.json @@ -3,4 +3,4 @@ "squizlabs/php_codesniffer": "*", "magento/magento-coding-standard": "^6.0" } -} +} \ No newline at end of file diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml deleted file mode 100644 index a2a15c046..000000000 --- a/docker-compose.dev.yml +++ /dev/null @@ -1,37 +0,0 @@ -# Mark Shust's Docker Configuration for Magento -# (https://github.com/markshust/docker-magento) -# -# Version 30.0.2 - -version: "3" - -services: - app: - volumes: &appvolumes - # Host mounts with performance penalty, only put what is necessary here - - ./src/app/code:/var/www/html/app/code:delegated - # - ./src/app/design:/var/www/html/app/design:delegated - # - ./src/app/etc:/var/www/html/app/etc:delegated - # - ./src/composer.json:/var/www/html/composer.json:delegated - # - ./src/composer.lock:/var/www/html/composer.lock:delegated - - ./src/nginx.conf.sample:/var/www/html/nginx.conf:delegated - - ./.eslintrc:/var/www/html/.eslintrc:delegated - #- ./src/var/log:/var/www/html/var/log:delegated - #- ./src/var/report:/var/www/html/var/report:delegated - - phpfpm: - volumes: *appvolumes - # Linux only: host.docker.internal doesn't exist https://github.com/docker/for-linux/issues/264 - # Uncomment two lines below & replace IP with result of: docker run --rm alpine ip route | awk 'NR==1 {print $3}' - #extra_hosts: - # - "host.docker.internal:IP" - - mailhog: - image: mailhog/mailhog - ports: - - "1025" - - "8025:8025" - - # Disabling cron by default as it uses higher CPU, enable if needed - #cron: - # volumes: *appvolumes diff --git a/docker-compose.yml b/docker-compose.yml index 38f8afc19..5dbc65890 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,33 +1,41 @@ -# Mark Shust's Docker Configuration for Magento -# (https://github.com/markshust/docker-magento) -# -# Version 30.0.2 +## Mark Shust's Docker Configuration for Magento +## (https://github.com/markshust/docker-magento) +## +## Version 47.0.1 -version: "3" +## To use SSH, see https://github.com/markshust/docker-magento#ssh +## Linux users, see https://github.com/markshust/docker-magento#linux + +## If you changed the default Docker network, you may need to replace +## 172.17.0.1 in this file with the result of: +## docker network inspect bridge --format='{{(index .IPAM.Config 0).Gateway}}' services: app: - image: markoshust/magento-nginx:1.13-8 + image: markoshust/magento-nginx:1.24-0 ports: - "80:8000" - "443:8443" - links: - - db - - phpfpm volumes: &appvolumes - - ~/.composer:/var/www/.composer:delegated + - ~/.composer:/var/www/.composer:cached + - ~/.ssh/id_rsa:/var/www/.ssh/id_rsa:cached + - ~/.ssh/known_hosts:/var/www/.ssh/known_hosts:cached - appdata:/var/www/html - sockdata:/sock - ssldata:/etc/nginx/certs phpfpm: - build: . - links: - - db + image: markoshust/magento-php:8.3-fpm-2 volumes: *appvolumes + env_file: env/phpfpm.env + #extra_hosts: *appextrahosts db: - image: percona:5.7 + image: mariadb:10.6 + command: + --max_allowed_packet=64M + --optimizer_use_condition_selectivity=1 + --optimizer_switch="rowid_filter=off" ports: - "3306:3306" env_file: env/db.env @@ -35,21 +43,40 @@ services: - dbdata:/var/lib/mysql redis: - image: redis:5.0 + image: redis:7.2-alpine + ports: + - "6379:6379" - elasticsearch: - image: markoshust/magento-elasticsearch:6.5.4-0 + opensearch: + image: markoshust/magento-opensearch:2.12-0 ports: - "9200:9200" - "9300:9300" + env_file: env/opensearch.env + environment: + - "discovery.type=single-node" + ## Avoid test failures due to small disks + ## More info at https://github.com/markshust/docker-magento/issues/488 + - "cluster.routing.allocation.disk.threshold_enabled=false" + - "index.blocks.read_only_allow_delete" + ## Uncomment to set custom heap size to avoid memory errors + #- "OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g" + ## Uncomment to increase the virtual memory map count + #- "max_map_count=262144" rabbitmq: - image: rabbitmq:3.7-management + image: markoshust/magento-rabbitmq:3.12-0 ports: - "15672:15672" - "5672:5672" volumes: - rabbitmqdata:/var/lib/rabbitmq + env_file: env/rabbitmq.env + + mailcatcher: + image: sj26/mailcatcher + ports: + - "1080:1080" # Disabling cron by default as it uses higher CPU, enable if needed #cron: diff --git a/docker-conf/php-fpm.conf b/docker-conf/php-fpm.conf deleted file mode 100644 index 5e875011b..000000000 --- a/docker-conf/php-fpm.conf +++ /dev/null @@ -1,31 +0,0 @@ -; This file was initially adapated from the output of: (on PHP 5.6) -; grep -vE '^;|^ *$' /usr/local/etc/php-fpm.conf.default - -[global] - -error_log = /proc/self/fd/2 -daemonize = no - -[www] - -; if we send this to /proc/self/fd/1, it never appears -access.log = /proc/self/fd/2 - -;user = app -;group = app - -listen = /sock/docker.sock -listen.owner = app -listen.group = app -listen.mode = 0660 - -pm = dynamic -pm.max_children = 10 -pm.start_servers = 4 -pm.min_spare_servers = 2 -pm.max_spare_servers = 6 - -clear_env = no - -; Ensure worker stdout and stderr are sent to the main error log. -catch_workers_output = yes diff --git a/docker-conf/php.ini b/docker-conf/php.ini deleted file mode 100644 index ca4b67e98..000000000 --- a/docker-conf/php.ini +++ /dev/null @@ -1,16 +0,0 @@ -memory_limit = 4G -max_execution_time = 1800 -zlib.output_compression = On -cgi.fix_pathinfo = 0 -date.timezone = UTC - -xdebug.mode=debug -xdebug.client_host=host.docker.internal -xdebug.client_port=9001 -xdebug.idekey=PHPSTORM - -upload_max_filesize = 100M -post_max_size = 100M -max_input_vars = 10000 - -sendmail_path = "/usr/local/bin/mhsendmail --smtp-addr=mailhog:1025" diff --git a/docker-conf/www.conf b/docker-conf/www.conf deleted file mode 100644 index af0053704..000000000 --- a/docker-conf/www.conf +++ /dev/null @@ -1,413 +0,0 @@ -; Start a new pool named 'www'. -; the variable $pool can we used in any directive and will be replaced by the -; pool name ('www' here) -[www] - -; Per pool prefix -; It only applies on the following directives: -; - 'access.log' -; - 'slowlog' -; - 'listen' (unixsocket) -; - 'chroot' -; - 'chdir' -; - 'php_values' -; - 'php_admin_values' -; When not set, the global prefix (or NONE) applies instead. -; Note: This directive can also be relative to the global prefix. -; Default Value: none -;prefix = /path/to/pools/$pool - -; Unix user/group of processes -; Note: The user is mandatory. If the group is not set, the default user's group -; will be used. -user = app -group = app - -; The address on which to accept FastCGI requests. -; Valid syntaxes are: -; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on -; a specific port; -; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on -; a specific port; -; 'port' - to listen on a TCP socket to all addresses -; (IPv6 and IPv4-mapped) on a specific port; -; '/path/to/unix/socket' - to listen on a unix socket. -; Note: This value is mandatory. -listen = 127.0.0.1:9000 - -; Set listen(2) backlog. -; Default Value: 511 (-1 on FreeBSD and OpenBSD) -;listen.backlog = 511 - -; Set permissions for unix socket, if one is used. In Linux, read/write -; permissions must be set in order to allow connections from a web server. Many -; BSD-derived systems allow connections regardless of permissions. -; Default Values: user and group are set as the running user -; mode is set to 0660 -;listen.owner = www-data -;listen.group = www-data -;listen.mode = 0660 -; When POSIX Access Control Lists are supported you can set them using -; these options, value is a comma separated list of user/group names. -; When set, listen.owner and listen.group are ignored -;listen.acl_users = -;listen.acl_groups = - -; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. -; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original -; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address -; must be separated by a comma. If this value is left blank, connections will be -; accepted from any ip address. -; Default Value: any -;listen.allowed_clients = 127.0.0.1 - -; Specify the nice(2) priority to apply to the pool processes (only if set) -; The value can vary from -19 (highest priority) to 20 (lower priority) -; Note: - It will only work if the FPM master process is launched as root -; - The pool processes will inherit the master process priority -; unless it specified otherwise -; Default Value: no set -; process.priority = -19 - -; Choose how the process manager will control the number of child processes. -; Possible Values: -; static - a fixed number (pm.max_children) of child processes; -; dynamic - the number of child processes are set dynamically based on the -; following directives. With this process management, there will be -; always at least 1 children. -; pm.max_children - the maximum number of children that can -; be alive at the same time. -; pm.start_servers - the number of children created on startup. -; pm.min_spare_servers - the minimum number of children in 'idle' -; state (waiting to process). If the number -; of 'idle' processes is less than this -; number then some children will be created. -; pm.max_spare_servers - the maximum number of children in 'idle' -; state (waiting to process). If the number -; of 'idle' processes is greater than this -; number then some children will be killed. -; ondemand - no children are created at startup. Children will be forked when -; new requests will connect. The following parameter are used: -; pm.max_children - the maximum number of children that -; can be alive at the same time. -; pm.process_idle_timeout - The number of seconds after which -; an idle process will be killed. -; Note: This value is mandatory. -pm = dynamic - -; The number of child processes to be created when pm is set to 'static' and the -; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. -; This value sets the limit on the number of simultaneous requests that will be -; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. -; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP -; CGI. The below defaults are based on a server without much resources. Don't -; forget to tweak pm.* to fit your needs. -; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' -; Note: This value is mandatory. -pm.max_children = 5 - -; The number of child processes created on startup. -; Note: Used only when pm is set to 'dynamic' -; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 -pm.start_servers = 2 - -; The desired minimum number of idle server processes. -; Note: Used only when pm is set to 'dynamic' -; Note: Mandatory when pm is set to 'dynamic' -pm.min_spare_servers = 1 - -; The desired maximum number of idle server processes. -; Note: Used only when pm is set to 'dynamic' -; Note: Mandatory when pm is set to 'dynamic' -pm.max_spare_servers = 3 - -; The number of seconds after which an idle process will be killed. -; Note: Used only when pm is set to 'ondemand' -; Default Value: 10s -;pm.process_idle_timeout = 10s; - -; The number of requests each child process should execute before respawning. -; This can be useful to work around memory leaks in 3rd party libraries. For -; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. -; Default Value: 0 -;pm.max_requests = 500 - -; The URI to view the FPM status page. If this value is not set, no URI will be -; recognized as a status page. It shows the following informations: -; pool - the name of the pool; -; process manager - static, dynamic or ondemand; -; start time - the date and time FPM has started; -; start since - number of seconds since FPM has started; -; accepted conn - the number of request accepted by the pool; -; listen queue - the number of request in the queue of pending -; connections (see backlog in listen(2)); -; max listen queue - the maximum number of requests in the queue -; of pending connections since FPM has started; -; listen queue len - the size of the socket queue of pending connections; -; idle processes - the number of idle processes; -; active processes - the number of active processes; -; total processes - the number of idle + active processes; -; max active processes - the maximum number of active processes since FPM -; has started; -; max children reached - number of times, the process limit has been reached, -; when pm tries to start more children (works only for -; pm 'dynamic' and 'ondemand'); -; Value are updated in real time. -; Example output: -; pool: www -; process manager: static -; start time: 01/Jul/2011:17:53:49 +0200 -; start since: 62636 -; accepted conn: 190460 -; listen queue: 0 -; max listen queue: 1 -; listen queue len: 42 -; idle processes: 4 -; active processes: 11 -; total processes: 15 -; max active processes: 12 -; max children reached: 0 -; -; By default the status page output is formatted as text/plain. Passing either -; 'html', 'xml' or 'json' in the query string will return the corresponding -; output syntax. Example: -; http://www.foo.bar/status -; http://www.foo.bar/status?json -; http://www.foo.bar/status?html -; http://www.foo.bar/status?xml -; -; By default the status page only outputs short status. Passing 'full' in the -; query string will also return status for each pool process. -; Example: -; http://www.foo.bar/status?full -; http://www.foo.bar/status?json&full -; http://www.foo.bar/status?html&full -; http://www.foo.bar/status?xml&full -; The Full status returns for each process: -; pid - the PID of the process; -; state - the state of the process (Idle, Running, ...); -; start time - the date and time the process has started; -; start since - the number of seconds since the process has started; -; requests - the number of requests the process has served; -; request duration - the duration in µs of the requests; -; request method - the request method (GET, POST, ...); -; request URI - the request URI with the query string; -; content length - the content length of the request (only with POST); -; user - the user (PHP_AUTH_USER) (or '-' if not set); -; script - the main script called (or '-' if not set); -; last request cpu - the %cpu the last request consumed -; it's always 0 if the process is not in Idle state -; because CPU calculation is done when the request -; processing has terminated; -; last request memory - the max amount of memory the last request consumed -; it's always 0 if the process is not in Idle state -; because memory calculation is done when the request -; processing has terminated; -; If the process is in Idle state, then informations are related to the -; last request the process has served. Otherwise informations are related to -; the current request being served. -; Example output: -; ************************ -; pid: 31330 -; state: Running -; start time: 01/Jul/2011:17:53:49 +0200 -; start since: 63087 -; requests: 12808 -; request duration: 1250261 -; request method: GET -; request URI: /test_mem.php?N=10000 -; content length: 0 -; user: - -; script: /home/fat/web/docs/php/test_mem.php -; last request cpu: 0.00 -; last request memory: 0 -; -; Note: There is a real-time FPM status monitoring sample web page available -; It's available in: /usr/local/share/php/fpm/status.html -; -; Note: The value must start with a leading slash (/). The value can be -; anything, but it may not be a good idea to use the .php extension or it -; may conflict with a real PHP file. -; Default Value: not set -;pm.status_path = /status - -; The ping URI to call the monitoring page of FPM. If this value is not set, no -; URI will be recognized as a ping page. This could be used to test from outside -; that FPM is alive and responding, or to -; - create a graph of FPM availability (rrd or such); -; - remove a server from a group if it is not responding (load balancing); -; - trigger alerts for the operating team (24/7). -; Note: The value must start with a leading slash (/). The value can be -; anything, but it may not be a good idea to use the .php extension or it -; may conflict with a real PHP file. -; Default Value: not set -;ping.path = /ping - -; This directive may be used to customize the response of a ping request. The -; response is formatted as text/plain with a 200 response code. -; Default Value: pong -;ping.response = pong - -; The access log file -; Default: not set -;access.log = log/$pool.access.log - -; The access log format. -; The following syntax is allowed -; %%: the '%' character -; %C: %CPU used by the request -; it can accept the following format: -; - %{user}C for user CPU only -; - %{system}C for system CPU only -; - %{total}C for user + system CPU (default) -; %d: time taken to serve the request -; it can accept the following format: -; - %{seconds}d (default) -; - %{miliseconds}d -; - %{mili}d -; - %{microseconds}d -; - %{micro}d -; %e: an environment variable (same as $_ENV or $_SERVER) -; it must be associated with embraces to specify the name of the env -; variable. Some exemples: -; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e -; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e -; %f: script filename -; %l: content-length of the request (for POST request only) -; %m: request method -; %M: peak of memory allocated by PHP -; it can accept the following format: -; - %{bytes}M (default) -; - %{kilobytes}M -; - %{kilo}M -; - %{megabytes}M -; - %{mega}M -; %n: pool name -; %o: output header -; it must be associated with embraces to specify the name of the header: -; - %{Content-Type}o -; - %{X-Powered-By}o -; - %{Transfert-Encoding}o -; - .... -; %p: PID of the child that serviced the request -; %P: PID of the parent of the child that serviced the request -; %q: the query string -; %Q: the '?' character if query string exists -; %r: the request URI (without the query string, see %q and %Q) -; %R: remote IP address -; %s: status (response code) -; %t: server time the request was received -; it can accept a strftime(3) format: -; %d/%b/%Y:%H:%M:%S %z (default) -; The strftime(3) format must be encapsuled in a %{}t tag -; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t -; %T: time the log has been written (the request has finished) -; it can accept a strftime(3) format: -; %d/%b/%Y:%H:%M:%S %z (default) -; The strftime(3) format must be encapsuled in a %{}t tag -; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t -; %u: remote user -; -; Default: "%R - %u %t \"%m %r\" %s" -;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" - -; The log file for slow requests -; Default Value: not set -; Note: slowlog is mandatory if request_slowlog_timeout is set -;slowlog = log/$pool.log.slow - -; The timeout for serving a single request after which a PHP backtrace will be -; dumped to the 'slowlog' file. A value of '0s' means 'off'. -; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) -; Default Value: 0 -;request_slowlog_timeout = 0 - -; The timeout for serving a single request after which the worker process will -; be killed. This option should be used when the 'max_execution_time' ini option -; does not stop script execution for some reason. A value of '0' means 'off'. -; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) -; Default Value: 0 -;request_terminate_timeout = 0 - -; Set open file descriptor rlimit. -; Default Value: system defined value -;rlimit_files = 1024 - -; Set max core size rlimit. -; Possible Values: 'unlimited' or an integer greater or equal to 0 -; Default Value: system defined value -;rlimit_core = 0 - -; Chroot to this directory at the start. This value must be defined as an -; absolute path. When this value is not set, chroot is not used. -; Note: you can prefix with '$prefix' to chroot to the pool prefix or one -; of its subdirectories. If the pool prefix is not set, the global prefix -; will be used instead. -; Note: chrooting is a great security feature and should be used whenever -; possible. However, all PHP paths will be relative to the chroot -; (error_log, sessions.save_path, ...). -; Default Value: not set -;chroot = - -; Chdir to this directory at the start. -; Note: relative path can be used. -; Default Value: current directory or / when chroot -;chdir = /var/www - -; Redirect worker stdout and stderr into main error log. If not set, stdout and -; stderr will be redirected to /dev/null according to FastCGI specs. -; Note: on highloaded environement, this can cause some delay in the page -; process time (several ms). -; Default Value: no -;catch_workers_output = yes - -; Clear environment in FPM workers -; Prevents arbitrary environment variables from reaching FPM worker processes -; by clearing the environment in workers before env vars specified in this -; pool configuration are added. -; Setting to "no" will make all environment variables available to PHP code -; via getenv(), $_ENV and $_SERVER. -; Default Value: yes -;clear_env = no - -; Limits the extensions of the main script FPM will allow to parse. This can -; prevent configuration mistakes on the web server side. You should only limit -; FPM to .php extensions to prevent malicious users to use other extensions to -; exectute php code. -; Note: set an empty value to allow all extensions. -; Default Value: .php -;security.limit_extensions = .php .php3 .php4 .php5 .php7 - -; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from -; the current environment. -; Default Value: clean env -;env[HOSTNAME] = $HOSTNAME -;env[PATH] = /usr/local/bin:/usr/bin:/bin -;env[TMP] = /tmp -;env[TMPDIR] = /tmp -;env[TEMP] = /tmp - -; Additional php.ini defines, specific to this pool of workers. These settings -; overwrite the values previously defined in the php.ini. The directives are the -; same as the PHP SAPI: -; php_value/php_flag - you can set classic ini defines which can -; be overwritten from PHP call 'ini_set'. -; php_admin_value/php_admin_flag - these directives won't be overwritten by -; PHP call 'ini_set' -; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. - -; Defining 'extension' will load the corresponding shared extension from -; extension_dir. Defining 'disable_functions' or 'disable_classes' will not -; overwrite previously defined php.ini values, but will append the new value -; instead. - -; Note: path INI options can be relative and will be expanded with the prefix -; (pool, global or /usr/local) - -; Default Value: nothing is defined by default except the values in php.ini and -; specified at startup with the -d argument -;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com -;php_flag[display_errors] = off -;php_admin_value[error_log] = /var/log/fpm-php.www.log -;php_admin_flag[log_errors] = on -;php_admin_value[memory_limit] = 32M diff --git a/env/blackfire.env b/env/blackfire.env new file mode 100644 index 000000000..b5dd85e64 --- /dev/null +++ b/env/blackfire.env @@ -0,0 +1,4 @@ +BLACKFIRE_DISABLE_LEGACY_PORT=true +BLACKFIRE_LOG_LEVEL= +BLACKFIRE_SERVER_ID= +BLACKFIRE_SERVER_TOKEN= diff --git a/env/cloudflare.env b/env/cloudflare.env new file mode 100644 index 000000000..c56898475 --- /dev/null +++ b/env/cloudflare.env @@ -0,0 +1 @@ +TUNNEL_TOKEN= diff --git a/env/db.env b/env/db.env index 850b62f9e..50c9663bd 100644 --- a/env/db.env +++ b/env/db.env @@ -1,4 +1,11 @@ +MYSQL_HOST=db MYSQL_ROOT_PASSWORD=magento MYSQL_DATABASE=magento MYSQL_USER=magento MYSQL_PASSWORD=magento + +MYSQL_INTEGRATION_ROOT_PASSWORD=magento +MYSQL_INTEGRATION_DATABASE=magento_integration_tests +MYSQL_INTEGRATION_USER=magento +MYSQL_INTEGRATION_PASSWORD=magento +MYSQL_INTEGRATION_HOST=db diff --git a/env/elasticsearch.env b/env/elasticsearch.env new file mode 100644 index 000000000..5856225ce --- /dev/null +++ b/env/elasticsearch.env @@ -0,0 +1,2 @@ +ES_HOST=elasticsearch +ES_PORT=9200 diff --git a/env/magento.env b/env/magento.env new file mode 100644 index 000000000..d9262baf4 --- /dev/null +++ b/env/magento.env @@ -0,0 +1,9 @@ +MAGENTO_ADMIN_EMAIL=john.smith@gmail.com +MAGENTO_ADMIN_FIRST_NAME=john +MAGENTO_ADMIN_LAST_NAME=smith +MAGENTO_ADMIN_USER=john.smith +MAGENTO_ADMIN_PASSWORD=password123 +MAGENTO_ADMIN_FRONTNAME=admin +MAGENTO_LOCALE=en_US +MAGENTO_CURRENCY=USD +MAGENTO_TIMEZONE=America/New_York diff --git a/env/opensearch.env b/env/opensearch.env new file mode 100644 index 000000000..2a5680329 --- /dev/null +++ b/env/opensearch.env @@ -0,0 +1,5 @@ +OPENSEARCH_HOST=opensearch +OPENSEARCH_PORT=9200 + +# Prevent security patch conflicts with core M2 code +DISABLE_SECURITY_PLUGIN=true diff --git a/env/phpfpm.env b/env/phpfpm.env new file mode 100644 index 000000000..8d8d626d7 --- /dev/null +++ b/env/phpfpm.env @@ -0,0 +1,5 @@ +BLACKFIRE_CLIENT_ID= +BLACKFIRE_CLIENT_TOKEN= +COMPOSER_DISABLE_XDEBUG_WARN=1 +PHP_CS_FIXER_IGNORE_ENV=1 +PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true diff --git a/env/rabbitmq.env b/env/rabbitmq.env new file mode 100644 index 000000000..261ebbd61 --- /dev/null +++ b/env/rabbitmq.env @@ -0,0 +1,6 @@ +RABBITMQ_HOST=rabbitmq +RABBITMQ_PORT=5672 +RABBITMQ_MANAGEMENT_PORT=15672 +RABBITMQ_DEFAULT_USER=magento +RABBITMQ_DEFAULT_PASS=magento +RABBITMQ_DEFAULT_VHOST=/ diff --git a/env/redis.env b/env/redis.env new file mode 100644 index 000000000..bb7cc83dc --- /dev/null +++ b/env/redis.env @@ -0,0 +1,5 @@ +REDIS_CACHE_BACKEND_SERVER=redis +REDIS_CACHE_BACKEND_DB=0 +REDIS_PAGE_CACHE_SERVER=redis +REDIS_PAGE_CACHE_DB=1 +REDIS_SESSION_SAVE_HOST=redis diff --git a/index b/index new file mode 100755 index 000000000..5f746d4f9 --- /dev/null +++ b/index @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +bin/magento indexer:status +bin/magento indexer:reset +bin/magento indexer:reindex + diff --git a/removeAll b/removeAll new file mode 100755 index 000000000..e3853ad0e --- /dev/null +++ b/removeAll @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +bin/stop +bin/removeall \ No newline at end of file diff --git a/run b/run new file mode 100755 index 000000000..3a8a12622 --- /dev/null +++ b/run @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +bin/start \ No newline at end of file diff --git a/setup b/setup new file mode 100755 index 000000000..065f75933 --- /dev/null +++ b/setup @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +bin/download 2.4.7 community +bin/start --no-dev +bin/composer install +bin/setup magento.test +bin/magento setup:upgrade +bin/composer require markshust/magento2-module-disabletwofactorauth +bin/magento module:enable MarkShust_DisableTwoFactorAuth +bin/magento setup:upgrade \ No newline at end of file diff --git a/src/.editorconfig b/src/.editorconfig deleted file mode 100644 index 37cfad78c..000000000 --- a/src/.editorconfig +++ /dev/null @@ -1,12 +0,0 @@ -root = true - -[*] -charset = utf-8 -end_of_line = lf -indent_size = 4 -indent_style = space -insert_final_newline = true -trim_trailing_whitespace = true - -[*.md] -trim_trailing_whitespace = false diff --git a/src/.gitignore b/src/.gitignore deleted file mode 100644 index 23ef88728..000000000 --- a/src/.gitignore +++ /dev/null @@ -1,71 +0,0 @@ -/.buildpath -/.cache -/.metadata -/.project -/.settings -/.vscode -atlassian* -/nbproject -/robots.txt -/pub/robots.txt -/sitemap -/sitemap.xml -/pub/sitemap -/pub/sitemap.xml -/.idea -/.gitattributes -/app/config_sandbox -/app/etc/env.php -/app/code/Magento/TestModule* -/lib/internal/flex/uploader/.actionScriptProperties -/lib/internal/flex/uploader/.flexProperties -/lib/internal/flex/uploader/.project -/lib/internal/flex/uploader/.settings -/lib/internal/flex/varien/.actionScriptProperties -/lib/internal/flex/varien/.flexLibProperties -/lib/internal/flex/varien/.project -/lib/internal/flex/varien/.settings -/node_modules -/.grunt -/Gruntfile.js -/package.json -/.php_cs -/.php_cs.cache -/grunt-config.json -/pub/media/*.* -!/pub/media/.htaccess -/pub/media/attribute/* -!/pub/media/attribute/.htaccess -/pub/media/analytics/* -/pub/media/catalog/* -!/pub/media/catalog/.htaccess -/pub/media/customer/* -!/pub/media/customer/.htaccess -/pub/media/downloadable/* -!/pub/media/downloadable/.htaccess -/pub/media/favicon/* -/pub/media/import/* -!/pub/media/import/.htaccess -/pub/media/logo/* -/pub/media/custom_options/* -!/pub/media/custom_options/.htaccess -/pub/media/theme/* -/pub/media/theme_customization/* -!/pub/media/theme_customization/.htaccess -/pub/media/wysiwyg/* -!/pub/media/wysiwyg/.htaccess -/pub/media/tmp/* -!/pub/media/tmp/.htaccess -/pub/media/captcha/* -/pub/static/* -!/pub/static/.htaccess - -/var/* -!/var/.htaccess -/vendor/* -!/vendor/.htaccess -/generated/* -!/generated/.htaccess -.DS_Store - -app/code/**/vendor/ \ No newline at end of file diff --git a/src/nginx.conf.sample b/src/nginx.conf.sample deleted file mode 100644 index 979ac0be1..000000000 --- a/src/nginx.conf.sample +++ /dev/null @@ -1,215 +0,0 @@ -## Example configuration: -# upstream fastcgi_backend { -# # use tcp connection -# # server 127.0.0.1:9000; -# # or socket -# server unix:/var/run/php/php7.0-fpm.sock; -# } -# server { -# listen 80; -# server_name mage.dev; -# set $MAGE_ROOT /var/www/magento2; -# set $MAGE_DEBUG_SHOW_ARGS 1; -# include /vagrant/magento2/nginx.conf.sample; -# } -# -## Optional override of deployment mode. We recommend you use the -## command 'bin/magento deploy:mode:set' to switch modes instead. -## -## set $MAGE_MODE default; # or production or developer -## -## If you set MAGE_MODE in server config, you must pass the variable into the -## PHP entry point blocks, which are indicated below. You can pass -## it in using: -## -## fastcgi_param MAGE_MODE $MAGE_MODE; -## -## In production mode, you should uncomment the 'expires' directive in the /static/ location block - -root $MAGE_ROOT/pub; - -index index.php; -autoindex off; -charset UTF-8; -error_page 404 403 = /errors/404.php; -#add_header "X-UA-Compatible" "IE=Edge"; - - -# Deny access to sensitive files -location /.user.ini { - deny all; -} - -# PHP entry point for setup application -location ~* ^/setup($|/) { - root $MAGE_ROOT; - location ~ ^/setup/index.php { - fastcgi_pass fastcgi_backend; - - fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; - fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=600"; - fastcgi_read_timeout 600s; - fastcgi_connect_timeout 600s; - - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include fastcgi_params; - } - - location ~ ^/setup/(?!pub/). { - deny all; - } - - location ~ ^/setup/pub/ { - add_header X-Frame-Options "SAMEORIGIN"; - } -} - -# PHP entry point for update application -location ~* ^/update($|/) { - root $MAGE_ROOT; - - location ~ ^/update/index.php { - fastcgi_split_path_info ^(/update/index.php)(/.+)$; - fastcgi_pass fastcgi_backend; - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param PATH_INFO $fastcgi_path_info; - include fastcgi_params; - } - - # Deny everything but index.php - location ~ ^/update/(?!pub/). { - deny all; - } - - location ~ ^/update/pub/ { - add_header X-Frame-Options "SAMEORIGIN"; - } -} - -location / { - try_files $uri $uri/ /index.php$is_args$args; -} - -location /pub/ { - location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) { - deny all; - } - alias $MAGE_ROOT/pub/; - add_header X-Frame-Options "SAMEORIGIN"; -} - -location /static/ { - # Uncomment the following line in production mode - # expires max; - - # Remove signature of the static files that is used to overcome the browser cache - location ~ ^/static/version { - rewrite ^/static/(version\d*/)?(.*)$ /static/$2 last; - } - - location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|json)$ { - add_header Cache-Control "public"; - add_header X-Frame-Options "SAMEORIGIN"; - expires +1y; - - if (!-f $request_filename) { - rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; - } - } - location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { - add_header Cache-Control "no-store"; - add_header X-Frame-Options "SAMEORIGIN"; - expires off; - - if (!-f $request_filename) { - rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; - } - } - if (!-f $request_filename) { - rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last; - } - add_header X-Frame-Options "SAMEORIGIN"; -} - -location /media/ { - try_files $uri $uri/ /get.php$is_args$args; - - location ~ ^/media/theme_customization/.*\.xml { - deny all; - } - - location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ { - add_header Cache-Control "public"; - add_header X-Frame-Options "SAMEORIGIN"; - expires +1y; - try_files $uri $uri/ /get.php$is_args$args; - } - location ~* \.(zip|gz|gzip|bz2|csv|xml)$ { - add_header Cache-Control "no-store"; - add_header X-Frame-Options "SAMEORIGIN"; - expires off; - try_files $uri $uri/ /get.php$is_args$args; - } - add_header X-Frame-Options "SAMEORIGIN"; -} - -location /media/customer/ { - deny all; -} - -location /media/downloadable/ { - deny all; -} - -location /media/import/ { - deny all; -} -location /errors/ { - location ~* \.xml$ { - deny all; - } -} - -# PHP entry point for main application -location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ { - try_files $uri =404; - fastcgi_pass fastcgi_backend; - fastcgi_buffers 1024 4k; - - fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off"; - fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=18000"; - fastcgi_read_timeout 600s; - fastcgi_connect_timeout 600s; - - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include fastcgi_params; -} - -gzip on; -gzip_disable "msie6"; - -gzip_comp_level 6; -gzip_min_length 1100; -gzip_buffers 16 8k; -gzip_proxied any; -gzip_types - text/plain - text/css - text/js - text/xml - text/javascript - application/javascript - application/x-javascript - application/json - application/xml - application/xml+rss - image/svg+xml; -gzip_vary on; - -# Banned locations (only reached if the earlier PHP entry point regexes don't match) -location ~* (\.php$|\.phtml$|\.htaccess$|\.git) { - deny all; -}