From 913d0e48757013fc3a4143db5b7d249e9ca441ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Planchat?= Date: Sun, 19 Jul 2020 20:27:33 +0200 Subject: [PATCH] Added Middleware support Refactored the CommandBus in order to make the ParallelCommandRunner more reliable Added different PHP version constraints for experimental modes --- Makefile | 55 +++ README.md | 183 ++++++---- .../.docker/elasticsearch/elasticsearch.yml | 10 + .../.docker/nginx@1.15/config/options.conf | 4 + .../nginx@1.15/config/reverse-proxy.conf | 40 ++ .../.docker/nginx@1.15/config/vhost-dev.conf | 29 ++ .../.docker/nginx@1.15/config/vhost-prod.conf | 29 ++ .../nginx@1.15/config/vhost-xdebug.conf | 29 ++ .../.docker/postgres@9.6/sql/uuid-ossp.sql | 1 + .../ee/3.1/.docker/rabbitmq@3.6/Dockerfile | 16 + .../ee/3.1/.docker/redis@5/Dockerfile | 5 + .../ee/3.1/.docker/redis@5/redis.conf | 80 ++++ compose/oroplatform/ee/3.1/.env.dist | 15 + compose/oroplatform/ee/3.1/Makefile | 155 ++++++++ compose/oroplatform/ee/3.1/docker-compose.yml | 223 ++++++++++++ config/builds.php | 343 +++++++++++------- config/constraints.php | 4 +- docker-compose.yml | 1 + .../middleware/ce/1.0/php@7.4/Dockerfile | 34 ++ environments/middleware/ee/Dockerfile | 34 ++ src/Domain/Packaging/BuildableInterface.php | 8 +- .../Packaging/CommandBus/CommandBus.php | 81 ----- .../CommandBus/CommandBusInterface.php | 14 - src/Domain/Packaging/Config/Config.php | 34 ++ src/Domain/Packaging/DependencyTree/Node.php | 26 +- .../{ => Execution}/Command/Build.php | 2 +- .../{ => Execution}/Command/BuildFrom.php | 2 +- .../Command/CommandInterface.php | 2 +- .../{ => Execution}/Command/ForceBuild.php | 2 +- .../Command/ForceBuildFrom.php | 2 +- .../{ => Execution}/Command/Pull.php | 2 +- .../{ => Execution}/Command/Push.php | 2 +- .../Execution/CommandBus/CommandBus.php | 75 ++++ .../CommandBus/CommandBusInterface.php | 14 + .../CommandBus/CommandRunnerInterface.php | 2 +- .../CommandBus/SequentialCommandRunner.php | 23 +- .../Packaging/Execution/CommandBus/Task.php | 41 +++ src/Domain/Packaging/Native/Package.php | 29 +- .../Packaging/Native/PackageVariation.php | 29 +- src/Domain/Packaging/Native/Tag.php | 24 +- src/Domain/Packaging/Native/TagVariation.php | 16 +- .../Packaging/Platform/Edition/Edition.php | 9 +- .../Platform/Edition/EditionDependency.php | 2 +- .../Platform/Edition/EditionInterface.php | 1 + .../MarelloCommunityEditionRepository.php | 13 +- .../MarelloEnterpriseEditionRepository.php | 13 +- .../MiddlewareCommunityEditionRepository.php | 22 ++ .../MiddlewareEnterpriseEditionRepository.php | 22 ++ .../OroCRMCommunityEditionRepository.php | 18 +- .../OroCRMEnterpriseEditionRepository.php | 18 +- .../OroCommerceCommunityEditionRepository.php | 18 +- ...OroCommerceEnterpriseEditionRepository.php | 18 +- .../OroPlatformCommunityEditionRepository.php | 6 +- ...OroPlatformEnterpriseEditionRepository.php | 6 +- src/Domain/Packaging/Platform/Package.php | 33 +- src/Domain/Packaging/Platform/Tag.php | 16 +- src/Domain/Stack/DTO/Context.php | 6 +- .../Console/Command/Images/BuildCommand.php | 40 +- .../Console/Command/Images/ListCommand.php | 17 +- .../Console/Command/Images/PullCommand.php | 35 +- .../Console/Command/Images/PushCommand.php | 35 +- .../Console/Command/Images/TestCommand.php | 19 +- .../Console/Command/Images/TreeCommand.php | 22 +- .../Console/Command/Stack/InitCommand.php | 9 +- .../Console/Command/Stack/UpgradeCommand.php | 8 +- src/Platform/Console/ContextWizard.php | 243 ++++--------- .../Context/CallableContextGuesser.php | 27 -- .../Context/ComposerPackageGuesser.php | 103 ++++++ ...mposerPackageDelegatedGuesserInterface.php | 11 + .../MarelloCommunity.php | 5 +- .../MarelloEnterprise.php | 5 +- .../MiddlewareCommunity.php | 31 ++ .../MiddlewareEnterprise.php | 31 ++ .../OroCRMCommunity.php | 5 +- .../OroCRMEnterprise.php | 5 +- .../OroCommerceCommunity.php | 5 +- .../OroCommerceEnterprise.php | 5 +- .../OroPlatformCommunity.php | 5 +- .../OroPlatformEnterprise.php | 5 +- .../ConsoleOptionContextGuesserInterface.php | 10 + src/Platform/Context/ContextGuesser.php | 46 --- src/Platform/Context/ContextGuesserFacade.php | 41 +++ .../Context/ContextGuesserInterface.php | 9 +- src/Platform/Context/NoPossibleGuess.php | 5 + src/Platform/Context/OroContextGuesser.php | 37 -- .../PHPVersionConsoleGuesser/Marello.php | 47 +++ .../PHPVersionConsoleGuesser/Middleware.php | 35 ++ .../PHPVersionConsoleGuesser/OroCRM.php | 47 +++ .../PHPVersionConsoleGuesser/OroCommerce.php | 46 +++ .../PHPVersionConsoleGuesser/OroPlatform.php | 47 +++ ...ersionConsoleDelegatedGuesserInterface.php | 13 + .../PHPVersionConsoleOptionGuesser.php | 108 ++++++ 92 files changed, 2279 insertions(+), 824 deletions(-) create mode 100644 Makefile create mode 100644 compose/oroplatform/ee/3.1/.docker/elasticsearch/elasticsearch.yml create mode 100644 compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/options.conf create mode 100644 compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/reverse-proxy.conf create mode 100644 compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/vhost-dev.conf create mode 100644 compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/vhost-prod.conf create mode 100644 compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/vhost-xdebug.conf create mode 100644 compose/oroplatform/ee/3.1/.docker/postgres@9.6/sql/uuid-ossp.sql create mode 100644 compose/oroplatform/ee/3.1/.docker/rabbitmq@3.6/Dockerfile create mode 100644 compose/oroplatform/ee/3.1/.docker/redis@5/Dockerfile create mode 100644 compose/oroplatform/ee/3.1/.docker/redis@5/redis.conf create mode 100644 compose/oroplatform/ee/3.1/.env.dist create mode 100644 compose/oroplatform/ee/3.1/Makefile create mode 100644 compose/oroplatform/ee/3.1/docker-compose.yml create mode 100644 environments/middleware/ce/1.0/php@7.4/Dockerfile create mode 100644 environments/middleware/ee/Dockerfile delete mode 100644 src/Domain/Packaging/CommandBus/CommandBus.php delete mode 100644 src/Domain/Packaging/CommandBus/CommandBusInterface.php create mode 100644 src/Domain/Packaging/Config/Config.php rename src/Domain/Packaging/{ => Execution}/Command/Build.php (95%) rename src/Domain/Packaging/{ => Execution}/Command/BuildFrom.php (96%) rename src/Domain/Packaging/{ => Execution}/Command/CommandInterface.php (75%) rename src/Domain/Packaging/{ => Execution}/Command/ForceBuild.php (95%) rename src/Domain/Packaging/{ => Execution}/Command/ForceBuildFrom.php (96%) rename src/Domain/Packaging/{ => Execution}/Command/Pull.php (93%) rename src/Domain/Packaging/{ => Execution}/Command/Push.php (93%) create mode 100644 src/Domain/Packaging/Execution/CommandBus/CommandBus.php create mode 100644 src/Domain/Packaging/Execution/CommandBus/CommandBusInterface.php rename src/Domain/Packaging/{ => Execution}/CommandBus/CommandRunnerInterface.php (66%) rename src/Domain/Packaging/{ => Execution}/CommandBus/SequentialCommandRunner.php (59%) create mode 100644 src/Domain/Packaging/Execution/CommandBus/Task.php create mode 100644 src/Domain/Packaging/Platform/Edition/MiddlewareCommunityEditionRepository.php create mode 100644 src/Domain/Packaging/Platform/Edition/MiddlewareEnterpriseEditionRepository.php delete mode 100644 src/Platform/Context/CallableContextGuesser.php create mode 100644 src/Platform/Context/ComposerPackageGuesser.php create mode 100644 src/Platform/Context/ComposerPackageGuesser/ComposerPackageDelegatedGuesserInterface.php rename src/Platform/Context/{Guesser => ComposerPackageGuesser}/MarelloCommunity.php (88%) rename src/Platform/Context/{Guesser => ComposerPackageGuesser}/MarelloEnterprise.php (88%) create mode 100644 src/Platform/Context/ComposerPackageGuesser/MiddlewareCommunity.php create mode 100644 src/Platform/Context/ComposerPackageGuesser/MiddlewareEnterprise.php rename src/Platform/Context/{Guesser => ComposerPackageGuesser}/OroCRMCommunity.php (86%) rename src/Platform/Context/{Guesser => ComposerPackageGuesser}/OroCRMEnterprise.php (86%) rename src/Platform/Context/{Guesser => ComposerPackageGuesser}/OroCommerceCommunity.php (86%) rename src/Platform/Context/{Guesser => ComposerPackageGuesser}/OroCommerceEnterprise.php (86%) rename src/Platform/Context/{Guesser => ComposerPackageGuesser}/OroPlatformCommunity.php (89%) rename src/Platform/Context/{Guesser => ComposerPackageGuesser}/OroPlatformEnterprise.php (89%) create mode 100644 src/Platform/Context/ConsoleOptionContextGuesserInterface.php delete mode 100644 src/Platform/Context/ContextGuesser.php create mode 100644 src/Platform/Context/ContextGuesserFacade.php delete mode 100644 src/Platform/Context/OroContextGuesser.php create mode 100644 src/Platform/Context/PHPVersionConsoleGuesser/Marello.php create mode 100644 src/Platform/Context/PHPVersionConsoleGuesser/Middleware.php create mode 100644 src/Platform/Context/PHPVersionConsoleGuesser/OroCRM.php create mode 100644 src/Platform/Context/PHPVersionConsoleGuesser/OroCommerce.php create mode 100644 src/Platform/Context/PHPVersionConsoleGuesser/OroPlatform.php create mode 100644 src/Platform/Context/PHPVersionConsoleGuesser/PHPVersionConsoleDelegatedGuesserInterface.php create mode 100644 src/Platform/Context/PHPVersionConsoleOptionGuesser.php diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..affc2a1 --- /dev/null +++ b/Makefile @@ -0,0 +1,55 @@ + +RED=033[31m +GREEN=033[32m +YELLOW=033[33m +BLUE=033[34m +PURPLE=033[35m +CYAN=033[36m +GREY=033[37m +NC=033[0m + +KLOUD=docker-compose exec sh php bin/kloud + +#build/kloud.phar: +# bin/build + +#.PHONY: build +#build: build/kloud.phar + +.PHONY: php-5.6 +php-5.6: ## Build all possible images for PHP 5.6 +php-5.6: + $(KLOUD) build --regex='/^5\.6-/' --force-all --push + +.PHONY: php-7.1 +php-7.1: ## Build all possible images for PHP 7.1 +php-7.1: + $(KLOUD) build --regex='/^7\.1-/' --force-all --push + +.PHONY: php-7.2 +php-7.2: ## Build all possible images for PHP 7.2 +php-7.2: + $(KLOUD) build --regex='/^7\.2-/' --force-all --push + +.PHONY: php-7.3 +php-7.3: ## Build all possible images for PHP 7.3 +php-7.3: + $(KLOUD) build --regex='/^7\.3-/' --force-all --push + +.PHONY: php-7.4 +php-7.4: ## Build all possible images for PHP 7.4 +php-7.4: + $(KLOUD) build --regex='/^7\.4-/' --force-all --push + +.PHONY: all +all: ## Build all possible images +all: + $(KLOUD) build --regex='/^\d+\.\d+/' --force-all --push + +.DEFAULT_GOAL := help + +.PHONY: help +help: ## Show this help +help: + @echo "\n\${BLUE}usage: make \${GREEN}target [ ...target ]\${NC}" + @grep -E '(^[a-zA-Z0-9_.-]+:.*?##.*$$)|(^##)' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf "\${GREEN}%-30s\${NC} %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/' diff --git a/README.md b/README.md index 19a54ec..80dd849 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,12 @@ This project aims at building your Docker stack for [OroCommerce](https://oroinc * [Installation](#installation) * [Usage](#usage) -* [Tags](#tags) +* [Supported versions and flavors](#supported-versions-and-flavours) + * [OroPlatform](#oroplatform) + * [OroCRM](#orocrm) + * [OroCommerce](#orocommerce) + * [Marello](#marello) + * [Middleware](#middleware) Installation --- @@ -17,8 +22,8 @@ Installation While installing system-wide, you will need administrator privilleges to install the command inside `/usr/local/bin/` directory. ``` -sudo curl -o /usr/local/bin/kloud https://github.com/kiboko-labs/docker-images/releases/download/1.0.2/kloud.phar -sudo curl -o /usr/local/bin/kloud.pubkey https://github.com/kiboko-labs/docker-images/releases/download/1.0.2/kloud.phar.pubkey +sudo curl -L -o /usr/local/bin/kloud https://github.com/kiboko-labs/docker-images/releases/download/1.0.2/kloud.phar +sudo curl -L -o /usr/local/bin/kloud.pubkey https://github.com/kiboko-labs/docker-images/releases/download/1.0.2/kloud.phar.pubkey sudo chmod +x /usr/local/bin/kloud ``` @@ -27,8 +32,8 @@ sudo chmod +x /usr/local/bin/kloud While installing in your project, no administrator privilege is required, the phar package will be available in the `bin/` directory. ``` -curl -o bin/kloud.phar https://github.com/kiboko-labs/docker-images/releases/download/1.0.2/kloud.phar -curl -o bin/kloud.phar.pubkey https://github.com/kiboko-labs/docker-images/releases/download/1.0.2/kloud.phar.pubkey +curl -L -o bin/kloud.phar https://github.com/kiboko-labs/docker-images/releases/download/1.0.2/kloud.phar +curl -L -o bin/kloud.phar.pubkey https://github.com/kiboko-labs/docker-images/releases/download/1.0.2/kloud.phar.pubkey chmod +x bin/kloud.phar ``` @@ -38,7 +43,12 @@ We also recommend to add both files to your `.gitignore` file. If you do not want to install the command on your machine, a Docker image is ready for one-shot usages and can be executed this way: -`docker run --rm -ti -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/.docker:/opt/docker/.docker -v $PWD:/app kiboko/kloud ` +``` +docker run --rm -ti -v /var/run/docker.sock:/var/run/docker.sock \ + -v $HOME/.docker:/opt/docker/.docker \ + -v $PWD:/app \ + kiboko/kloud +``` Usage --- @@ -72,70 +82,97 @@ If you need to test if the images you are using are following every constraint y Supported versions and flavours --- -### With MySQL database backend - -| Application | Version | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 | PHP 8.0 | -| -------------- | ------- | --------------- | ------------ | --------------- | --------------- | --------------- | -| OroPlatform CE | ^2.6.0 | ⚠️ discontinued | ❌ | ❌ | ❌️ | ❌ | -| | ^3.1.0 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^4.1.0 | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | -| OroPlatform EE | ^2.6.0 | ⚠️ discontinued | ❌ | ❌ | ❌️ | ❌ | -| | ^3.1.0 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^4.1.0 | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | -| OroCRM CE | ^2.6.0 | ⚠️ discontinued | ❌ | ❌️ | ❌️ | ❌ | -| | ^3.1.0 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^4.1.0 | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | -| OroCRM EE | ^2.6.0 | ⚠️ discontinued | ❌ | ❌️ | ❌️ | ❌ | -| | ^3.1.0 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^4.1.0 | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | -| OroCommerce CE | ^1.6.0 | ⚠️ discontinued | ❌ | ❌️ | ❌️ | ❌ | -| | ^3.1.0 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^4.1.0 | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | -| OroCommerce EE | ^1.6.0 | ⚠️ discontinued | ❌ | ❌️ | ❌️ | ❌ | -| | ^3.1.0 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^4.1.0 | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | -| Marello CE | ^1.5.0 | ⚠️ discontinued | ❌ | ❌️ | ❌️ | ❌ | -| | ^1.6.0 | ⚠️ discontinued | ❌ | ❌️ | ❌️ | ❌ | -| | ^2.0 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^2.1 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^2.2 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^3.0 | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | -| Marello EE | ^1.3.0 | ⚠️ discontinued | ❌ | ❌️ | ❌️ | ❌ | -| | ^2.0 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^2.1 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^2.2 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^3.0 | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | - -### With PostgreSQL database backend - -| Application | Version | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 | PHP 8.0 | -| -------------- | ------- | --------------- | ------------ | --------------- | --------------- | --------------- | -| OroPlatform CE | ^2.6.0 | ⚠️ discontinued | ❌ | ❌ | ❌️ | ❌ | -| | ^3.1.0 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^4.1.0 | ❌ | ❌ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| OroPlatform EE | ^2.6.0 | ⚠️ discontinued | ❌ | ❌ | ❌️ | ❌ | -| | ^3.1.0 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^4.1.0 | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | -| OroCRM CE | ^2.6.0 | ⚠️ discontinued | ❌ | ❌️ | ❌️ | ❌ | -| | ^3.1.0 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^4.1.0 | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | -| OroCRM EE | ^2.6.0 | ⚠️ discontinued | ❌ | ❌️ | ❌️ | ❌ | -| | ^3.1.0 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^4.1.0 | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | -| OroCommerce CE | ^1.6.0 | ⚠️ discontinued | ❌ | ❌️ | ❌️ | ❌ | -| | ^3.1.0 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^4.1.0 | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | -| OroCommerce EE | ^1.6.0 | ⚠️ discontinued | ❌ | ❌️ | ❌️ | ❌ | -| | ^3.1.0 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^4.1.0 | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | -| Marello CE | ^1.5.0 | ⚠️ discontinued | ❌ | ❌️ | ❌️ | ❌ | -| | ^1.6.0 | ⚠️ discontinued | ❌ | ❌️ | ❌️ | ❌ | -| | ^2.0 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^2.1 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^2.2 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^3.0 | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | -| Marello EE | ^1.3.0 | ⚠️ discontinued | ❌ | ❌️ | ❌️ | ❌ | -| | ^2.0 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^2.1 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^2.2 | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | -| | ^3.0 | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | +### OroPlatform + +#### Community Edition + +| Version | PHP 5.6 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 | PHP 8.0 | +| ------- | --------------- | --------------- | ------------ | --------------- | --------------- | --------------- | +| ^1.8 | 🌅️ discontinued | ❌ | ❌ | ❌ | ❌️ | ❌ | +| ^1.10 | 🌅️ discontinued | ❌ | ❌ | ❌ | ❌️ | ❌ | +| ^2.6 | 🌅️ discontinued | 🌅️ discontinued | ❌ | ❌ | ❌️ | ❌ | +| ^3.1 | ❌ | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | +| ^4.1 | ❌ | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | + +#### Enterprise Edition + +| Version | PHP 5.6 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 | PHP 8.0 | +| ------- | --------------- | --------------- | ------------ | --------------- | --------------- | --------------- | +| ^1.12 | 🌅️ discontinued | ❌ | ❌ | ❌ | ❌️ | ❌ | +| ^2.6 | 🌅️ discontinued | 🌅️ discontinued | ❌ | ❌ | ❌️ | ❌ | +| ^3.1 | ❌ | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | +| ^4.1 | ❌ | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | + +### OroCRM + +#### Community Edition + +| Version | PHP 5.6 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 | PHP 8.0 | +| ------- | --------------- | --------------- | ------------ | --------------- | --------------- | --------------- | +| ^2.6 | 🌅️ discontinued | 🌅️ discontinued | ❌ | ❌️ | ❌️ | ❌ | +| ^3.1 | ❌ | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | +| ^4.1 | ❌ | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | + +#### Enterprise Edition + +| Version | PHP 5.6 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 | PHP 8.0 | +| ------- | --------------- | --------------- | ------------ | --------------- | --------------- | --------------- | +| ^2.6 | 🌅️ discontinued | 🌅️ discontinued | ❌ | ❌️ | ❌️ | ❌ | +| ^3.1 | ❌ | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | +| ^4.1 | ❌ | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | + +### OroCommerce + +#### Community Edition + +| Version | PHP 5.6 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 | PHP 8.0 | +| ------- | --------------- | --------------- | ------------ | --------------- | --------------- | --------------- | +| ^1.6 | 🌅️ discontinued | 🌅️ discontinued | ❌ | ❌️ | ❌️ | ❌ | +| ^3.1 | ❌ | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | +| ^4.1 | ❌ | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | + +#### Enterprise Edition + +| Version | PHP 5.6 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 | PHP 8.0 | +| ------- | --------------- | --------------- | ------------ | --------------- | --------------- | --------------- | +| ^1.6 | 🌅️ discontinued | 🌅️ discontinued | ❌ | ❌️ | ❌️ | ❌ | +| ^3.1 | ❌ | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | +| ^4.1 | ❌ | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | + +### Marello + +#### Community Edition + +| Version | PHP 5.6 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 | PHP 8.0 | +| ------- | --------------- | --------------- | ------------ | --------------- | --------------- | --------------- | +| ^1.5 | 🌅️ discontinued | 🌅️ discontinued | ❌ | ❌️ | ❌️ | ❌ | +| ^1.6 | 🌅️ discontinued | 🌅️ discontinued | ❌ | ❌️ | ❌️ | ❌ | +| ^2.0 | ❌ | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | +| ^2.1 | ❌ | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | +| ^2.2 | ❌ | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | +| ^3.0 | ❌ | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | + +#### Enterprise Edition + +| Version | PHP 5.6 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 | PHP 8.0 | +| ------- | --------------- | --------------- | ------------ | --------------- | --------------- | --------------- | +| ^1.2 | 🌅️ discontinued | 🌅️ discontinued | ❌ | ❌️ | ❌️ | ❌ | +| ^1.3 | 🌅️ discontinued | 🌅️ discontinued | ❌ | ❌️ | ❌️ | ❌ | +| ^2.0 | ❌ | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | +| ^2.1 | ❌ | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | +| ^2.2 | ❌ | ✅ | ✅ | ⚠️ experimental | ⚠️ experimental | ⚠️ experimental | +| ^3.0 | ❌ | ❌ | ❌ | ✅️ | ✅️ | ⚠️ experimental | + +### Middleware + +#### Community Edition + +| Version | PHP 5.6 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 | PHP 8.0 | +| ------- | --------------- | --------------- | ------------ | --------------- | --------------- | --------------- | +| ^1.0 | ❌ | ❌ | ❌ | ❌️ | ✅️ | ⚠️ experimental | + +#### Enterprise Edition + +| Version | PHP 5.6 | PHP 7.1 | PHP 7.2 | PHP 7.3 | PHP 7.4 | PHP 8.0 | +| ------- | --------------- | --------------- | ------------ | --------------- | --------------- | --------------- | +| ^1.0 | ❌ | ❌ | ❌ | ❌️ | ✅️ | ⚠️ experimental | diff --git a/compose/oroplatform/ee/3.1/.docker/elasticsearch/elasticsearch.yml b/compose/oroplatform/ee/3.1/.docker/elasticsearch/elasticsearch.yml new file mode 100644 index 0000000..b4cf8a8 --- /dev/null +++ b/compose/oroplatform/ee/3.1/.docker/elasticsearch/elasticsearch.yml @@ -0,0 +1,10 @@ +http.host: 0.0.0.0 + +# Uncomment the following lines for a production cluster deployment +#transport.host: 0.0.0.0 +#discovery.zen.minimum_master_nodes: 1 +http.cors.enabled : true +http.cors.allow-origin : "*" +http.cors.allow-methods : OPTIONS, HEAD, GET, POST, PUT, DELETE +http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type, Content-Length +cluster.routing.allocation.disk.threshold_enabled: false \ No newline at end of file diff --git a/compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/options.conf b/compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/options.conf new file mode 100644 index 0000000..e6e069f --- /dev/null +++ b/compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/options.conf @@ -0,0 +1,4 @@ +client_header_timeout 10m; +client_body_timeout 10m; +send_timeout 10m; +real_ip_header X-Forwarded-For; diff --git a/compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/reverse-proxy.conf b/compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/reverse-proxy.conf new file mode 100644 index 0000000..7670056 --- /dev/null +++ b/compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/reverse-proxy.conf @@ -0,0 +1,40 @@ + +upstream prod-app { + server http-worker-prod:80; +} + +upstream dev-app { + server http-worker-dev:80; +} + +upstream xdebug-app { + server http-worker-xdebug:80; +} + +map $http_x_symfony_env $pool { + default "dev-app"; + prod "prod-app"; + dev "dev-app"; + xdebug "xdebug-app"; +} + +server { + listen 80; + server_name _; + location / { + proxy_pass http://$pool; + + #standard proxy settings + proxy_set_header X-Real-IP $remote_addr; + proxy_redirect off; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_redirect off; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-NginX-Proxy true; + proxy_connect_timeout 600; + proxy_send_timeout 600; + proxy_read_timeout 600; + send_timeout 600; + } +} diff --git a/compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/vhost-dev.conf b/compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/vhost-dev.conf new file mode 100644 index 0000000..a039c78 --- /dev/null +++ b/compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/vhost-dev.conf @@ -0,0 +1,29 @@ +server { + server_name _; + root /var/www/html/public; + + index index_dev.php; + + access_log /var/log/nginx/access_log; + error_log /var/log/nginx/error_log info; + + try_files $uri $uri/ @rewrite; + + location @rewrite { + rewrite ^/(.*)$ /index_dev.php/$1; + } + + location ~ [^/].php(/|$) { + fastcgi_split_path_info ^(.+?.php)(/.*)$; + + if (!-f $document_root$fastcgi_script_name) { + return 404; + } + + fastcgi_index index_dev.php; + fastcgi_read_timeout 10m; + fastcgi_pass fpm:9000; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} diff --git a/compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/vhost-prod.conf b/compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/vhost-prod.conf new file mode 100644 index 0000000..9ac6388 --- /dev/null +++ b/compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/vhost-prod.conf @@ -0,0 +1,29 @@ +server { + server_name _; + root /var/www/html/public; + + index index.php; + + access_log /var/log/nginx/access_log; + error_log /var/log/nginx/error_log info; + + try_files $uri $uri/ @rewrite; + + location @rewrite { + rewrite ^/(.*)$ /index.php/$1; + } + + location ~ [^/].php(/|$) { + fastcgi_split_path_info ^(.+?.php)(/.*)$; + + if (!-f $document_root$fastcgi_script_name) { + return 404; + } + + fastcgi_index index.php; + fastcgi_read_timeout 10m; + fastcgi_pass fpm:9000; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} diff --git a/compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/vhost-xdebug.conf b/compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/vhost-xdebug.conf new file mode 100644 index 0000000..9d25ab5 --- /dev/null +++ b/compose/oroplatform/ee/3.1/.docker/nginx@1.15/config/vhost-xdebug.conf @@ -0,0 +1,29 @@ +server { + server_name _; + root /var/www/html/public; + + index index_dev.php; + + access_log /var/log/nginx/access_log; + error_log /var/log/nginx/error_log info; + + try_files $uri $uri/ @rewrite; + + location @rewrite { + rewrite ^/(.*)$ /index_dev.php/$1; + } + + location ~ [^/].php(/|$) { + fastcgi_split_path_info ^(.+?.php)(/.*)$; + + if (!-f $document_root$fastcgi_script_name) { + return 404; + } + + fastcgi_index index_dev.php; + fastcgi_read_timeout 10m; + fastcgi_pass fpm-xdebug:9000; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} diff --git a/compose/oroplatform/ee/3.1/.docker/postgres@9.6/sql/uuid-ossp.sql b/compose/oroplatform/ee/3.1/.docker/postgres@9.6/sql/uuid-ossp.sql new file mode 100644 index 0000000..d159cc5 --- /dev/null +++ b/compose/oroplatform/ee/3.1/.docker/postgres@9.6/sql/uuid-ossp.sql @@ -0,0 +1 @@ +CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; diff --git a/compose/oroplatform/ee/3.1/.docker/rabbitmq@3.6/Dockerfile b/compose/oroplatform/ee/3.1/.docker/rabbitmq@3.6/Dockerfile new file mode 100644 index 0000000..9e6288f --- /dev/null +++ b/compose/oroplatform/ee/3.1/.docker/rabbitmq@3.6/Dockerfile @@ -0,0 +1,16 @@ +FROM rabbitmq:3.7-management-alpine + +RUN set -ex\ + && apk update \ + && apk upgrade \ + && apk add --no-cache --virtual .build-deps \ + zip \ + curl \ + && curl https://dl.bintray.com/rabbitmq/community-plugins/3.7.x/rabbitmq_delayed_message_exchange/rabbitmq_delayed_message_exchange-20171201-3.7.x.zip > $RABBITMQ_HOME/plugins/rabbitmq_delayed_message_exchange-20171201-3.7.x.zip \ + && unzip $RABBITMQ_HOME/plugins/rabbitmq_delayed_message_exchange-20171201-3.7.x.zip -d $RABBITMQ_HOME/plugins \ + && rm $RABBITMQ_HOME/plugins/rabbitmq_delayed_message_exchange-20171201-3.7.x.zip \ + && apk del .build-deps + +RUN rabbitmq-plugins enable --offline rabbitmq_delayed_message_exchange +RUN rabbitmq-plugins enable --offline rabbitmq_consistent_hash_exchange + diff --git a/compose/oroplatform/ee/3.1/.docker/redis@5/Dockerfile b/compose/oroplatform/ee/3.1/.docker/redis@5/Dockerfile new file mode 100644 index 0000000..7b13bbd --- /dev/null +++ b/compose/oroplatform/ee/3.1/.docker/redis@5/Dockerfile @@ -0,0 +1,5 @@ +FROM redis:5-alpine + +COPY redis.conf /usr/local/etc/redis/redis.conf + +CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ] \ No newline at end of file diff --git a/compose/oroplatform/ee/3.1/.docker/redis@5/redis.conf b/compose/oroplatform/ee/3.1/.docker/redis@5/redis.conf new file mode 100644 index 0000000..2d53b10 --- /dev/null +++ b/compose/oroplatform/ee/3.1/.docker/redis@5/redis.conf @@ -0,0 +1,80 @@ +bind 0.0.0.0 +port 6379 + +protected-mode yes + +tcp-backlog 511 +timeout 0 +tcp-keepalive 300 + +daemonize no +supervised upstart + +pidfile /var/run/redis_6379.pid + +loglevel notice +logfile "" + +databases 16 + +always-show-logo yes + +save 900 1 +save 300 10 +save 60 10000 + +stop-writes-on-bgsave-error yes +rdbcompression yes +rdbchecksum yes +dbfilename dump.rdb + +dir ./ + +replica-serve-stale-data yes +replica-read-only yes +repl-diskless-sync no +repl-diskless-sync-delay 5 +repl-disable-tcp-nodelay no +replica-priority 100 + +lazyfree-lazy-eviction no +lazyfree-lazy-expire no +lazyfree-lazy-server-del no +replica-lazy-flush no + +appendonly no +appendfilename "appendonly.aof" +appendfsync everysec +no-appendfsync-on-rewrite no +auto-aof-rewrite-percentage 100 +auto-aof-rewrite-min-size 64mb +aof-load-truncated yes +aof-use-rdb-preamble yes + +lua-time-limit 5000 + +slowlog-log-slower-than 10000 +slowlog-max-len 128 + +latency-monitor-threshold 0 + +notify-keyspace-events "" + +hash-max-ziplist-entries 512 +hash-max-ziplist-value 64 +list-max-ziplist-size -2 +list-compress-depth 0 +set-max-intset-entries 512 +zset-max-ziplist-entries 128 +zset-max-ziplist-value 64 +hll-sparse-max-bytes 3000 +stream-node-max-bytes 4096 +stream-node-max-entries 100 +activerehashing yes +client-output-buffer-limit normal 0 0 0 +client-output-buffer-limit replica 256mb 64mb 60 +client-output-buffer-limit pubsub 32mb 8mb 60 +hz 10 +dynamic-hz yes +aof-rewrite-incremental-fsync yes +rdb-save-incremental-fsync yes diff --git a/compose/oroplatform/ee/3.1/.env.dist b/compose/oroplatform/ee/3.1/.env.dist new file mode 100644 index 0000000..0961019 --- /dev/null +++ b/compose/oroplatform/ee/3.1/.env.dist @@ -0,0 +1,15 @@ +BLACKFIRE_SERVER_ID=0000000000000000000000000000000000000000 +BLACKFIRE_SERVER_TOKEN=0000000000000000000000000000000000000000 +BLACKFIRE_CLIENT_ID=0000000000000000000000000000000000000000 +BLACKFIRE_CLIENT_TOKEN=0000000000000000000000000000000000000000 +APPLICATION_DOMAIN=localhost +COMPOSER_AUTH={"github-oauth":{"github.com":"0000000000000000000000000000000000000000"},"bitbucket-oauth":{"bitbucket.org":{"consumer-key":"0000000000000000000000000000000000000000","consumer-secret":"0000000000000000000000000000000000000000"}}} +COMPOSER_PROCESS_TIMEOUT=3000 +HTTP_PORT=10000 +MAILCATCHER_PORT=10083 +SQL_PORT=10432 +WEBSOCKET_PORT=10088 +RABBITMQ_PORT=10673 +REDIS_PORT=10379 +ELASTICSEARCH_PORT=10200 +DEJAVU_PORT=10358 \ No newline at end of file diff --git a/compose/oroplatform/ee/3.1/Makefile b/compose/oroplatform/ee/3.1/Makefile new file mode 100644 index 0000000..fe50486 --- /dev/null +++ b/compose/oroplatform/ee/3.1/Makefile @@ -0,0 +1,155 @@ +## +## Makefile +## +include .env +export + +RED=033[31m +GREEN=033[32m +YELLOW=033[33m +BLUE=033[34m +PURPLE=033[35m +CYAN=033[36m +GREY=033[37m +NC=033[0m + +DOCKER-COMPOSE=docker-compose + +DOCKER-EXEC=$(DOCKER-COMPOSE) exec + +SH=$(DOCKER-EXEC) sh /bin/sh +CONSOLE=$(DOCKER-EXEC) sh bin/console +COMPOSER=$(DOCKER-EXEC) sh composer +SERVICES=elasticsearch dejavu sql amqp redis http http-worker-prod http-worker-dev http-worker-xdebug mail fpm fpm-xdebug sh sh-xdebug + +.env: + cp .env.dist .env + +update-containers: ## Pull last images and launch +update-containers: .env pull start + +.PHONY: start +start: ## Launch docker services +start: .env + @echo "\${BLUE}- Lauching docker\${NC}" + $(DOCKER-COMPOSE) up -d $(SERVICES) + +.PHONY: start-mq +start-mq: ## Launch docker MQ worker service +start-mq: .env + @echo "\${BLUE}- Lauching docker\${NC}" + $(DOCKER-COMPOSE) up -d mq + $(MAKE) amqp-management + +.PHONY: start-ws +start-ws: ## Launch docker WS service +start-ws: .env + @echo "\${BLUE}- Lauching docker\${NC}" + $(DOCKER-COMPOSE) up -d ws + +.PHONY: stop +stop: ## Stop docker services +stop: .env + @echo "\${BLUE}- Stopping docker\${NC}" + $(DOCKER-COMPOSE) stop + +.PHONY: pull +pull: ## Pull latest images for docker services +pull: .env + $(DOCKER-COMPOSE) pull + +.PHONY: clean +clean: ## Clean project. +clean: .env start + @echo "\${BLUE}- Cleaning project\${NC}" + $(SH) -c "/usr/bin/env rm -Rf app/cache vendor composer.lock && git checkout composer.lock" + +platform-update: ## Execute platform application update commands and init platform assets. +platform-update: .env start + @echo "\${BLUE}- Executing platform application update\${NC}" + $(CONSOLE) oro:platform:update --force --symlink --env=prod -vvv --timeout=0 + +.PHONY: cache-clear +cache-clear: ## Clear cache +cache-clear: + @echo "\${YELLOW}- Clearing PROD cache\${NC}" + $(CONSOLE) cache:clear --env=prod + +.PHONY: cache-clear-dev +cache-clear-dev: ## Clear cache +cache-clear-dev: + @echo "\${YELLOW}- Clearing DEV cache\${NC}" + $(CONSOLE) cache:clear --env=dev + +.PHONY: cache-warmup +cache-warmup: ## Warmup cache +cache-warmup: + @echo "\${YELLOW}- Warming up PROD cache\${NC}" + $(CONSOLE) cache:warmup --env=prod + +.PHONY: cache-warmup-dev +cache-warmup-dev: ## Warmup cache +cache-warmup-dev: + @echo "\${YELLOW}- Warming up DEV cache\${NC}" + $(CONSOLE) cache:warmup --env=dev + +.PHONY: install +install: ## Install OroCommerce +install: vendor start + @echo "\${YELLOW}- Installing OroCommerce\${NC}" + $(CONSOLE) oro:install \ + --application-url=http://127.0.0.1:8000 \ + --env=prod \ + --organization-name="Kiboko" \ + --user-name=admin \ + --user-email=hello@kiboko.fr \ + --user-firstname=Hippo \ + --user-lastname=Potamus \ + --user-password=password \ + --language=en \ + --formatting-code=en \ + --symlink \ + --timeout=0 + +.PHONY: uninstall +uninstall: ## Uninstall OroCommerce +uninstall: start + @echo "\${YELLOW}- Uninstalling OroCommercd\${NC}" + $(SH) -c "rm -rf var/cache/*" + $(SH) -c "php -r \"use Symfony\Component\Yaml\Yaml;require 'vendor/autoload.php';\$$data = Yaml::parseFile('config/parameters.yml');\$$data['parameters']['installed'] = null;file_put_contents('config/parameters.yml', Yaml::dump(\$$data));\" + +.PHONY: reinstall +reinstall: ## Reinstall OroCommerce +reinstall: vendor uninstall start + @echo "\${YELLOW}- Reinstalling OroCommercd\${NC}" + $(CONSOLE) oro:install \ + --application-url=http://127.0.0.1:8000 \ + --env=prod \ + --organization-name="Kiboko" \ + --user-name=admin \ + --user-email=hello@kiboko.fr \ + --user-firstname=Hippo \ + --user-lastname=Potamus \ + --user-password=password \ + --language=en \ + --formatting-code=en \ + --symlink \ + --timeout=0 \ + --drop-database + +vendor: composer.json composer.lock start + @echo "\${BLUE}- Installing composer dependencies\${NC}" + $(COMPOSER) install + +.PHONY: amqp-management +amqp-management: + @echo "\${BLUE}- Enabling RabbitMQ manager\${NC}" + $(DOCKER-EXEC) amqp rabbitmq-plugins enable rabbitmq_management + +.DEFAULT_GOAL := help + +.PHONY: help +help: ## Show this help +help: + @echo "\n\${BLUE}usage: make \${GREEN}command [...command]\${NC}" + @grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/' diff --git a/compose/oroplatform/ee/3.1/docker-compose.yml b/compose/oroplatform/ee/3.1/docker-compose.yml new file mode 100644 index 0000000..1e2916d --- /dev/null +++ b/compose/oroplatform/ee/3.1/docker-compose.yml @@ -0,0 +1,223 @@ +version: '2' + +services: + mail: + image: schickling/mailcatcher:latest + ports: + - ${MAILCATCHER_PORT}:1080 + + amqp: + build: + context: .docker/rabbitmq@3.6 + ports: + - ${RABBITMQ_PORT}:15672 + environment: + - RABBITMQ_DEFAULT_USER=kiboko + - RABBITMQ_DEFAULT_PASS=password + restart: on-failure + + redis: + build: + context: .docker/redis@5/ + restart: on-failure + ports: + - ${REDIS_PORT}:6379 + + sql: + image: postgres:9.6-alpine + ports: + - ${SQL_PORT}:5432 + environment: + - "POSTGRES_USER=kiboko" + - "POSTGRES_DB=kiboko" + - "POSTGRES_PASSWORD=password" + - "POSTGRES_ROOT_PASSWORD=password" + volumes: + - ./.docker/postgres@9.6/sql/uuid-ossp.sql:/docker-entrypoint-initdb.d/00-uuid-ossp.sql:ro + - ./.docker/postgres@9.6/custom-sql/:/docker-entrypoint-initdb.d/custom-sql/ + - database:/var/lib/postgresql/data + restart: on-failure + + http: + image: nginx:alpine + volumes: + - ./.docker/nginx@1.15/config/options.conf:/etc/nginx/conf.d/000-options.conf + - ./.docker/nginx@1.15/config/reverse-proxy.conf:/etc/nginx/conf.d/default.conf + - ./:/var/www/html + - cache:/var/www/html/var/cache:ro + - assets:/var/www/html/public/bundles:ro + restart: on-failure + ports: + - ${HTTP_PORT}:80 + depends_on: + - http-worker-prod + - http-worker-dev + - http-worker-xdebug + + http-worker-prod: + image: nginx:alpine + volumes: + - ./.docker/nginx@1.15/config/options.conf:/etc/nginx/conf.d/000-options.conf + - ./.docker/nginx@1.15/config/vhost-prod.conf:/etc/nginx/conf.d/default.conf + - ./:/var/www/html + - cache:/var/www/html/var/cache:delegated + - assets:/var/www/html/public/bundles:delegated + restart: on-failure + depends_on: + - fpm + + http-worker-dev: + image: nginx:alpine + volumes: + - ./.docker/nginx@1.15/config/options.conf:/etc/nginx/conf.d/000-options.conf + - ./.docker/nginx@1.15/config/vhost-dev.conf:/etc/nginx/conf.d/default.conf + - ./:/var/www/html + - cache:/var/www/html/var/cache:ro + - assets:/var/www/html/public/bundles:ro + restart: on-failure + depends_on: + - fpm + + http-worker-xdebug: + image: nginx:alpine + volumes: + - ./.docker/nginx@1.15/config/options.conf:/etc/nginx/conf.d/000-options.conf + - ./.docker/nginx@1.15/config/vhost-xdebug.conf:/etc/nginx/conf.d/default.conf + - ./:/var/www/html + - cache:/var/www/html/var/cache:ro + - assets:/var/www/html/public/bundles:ro + restart: on-failure + depends_on: + - fpm-xdebug + + elasticsearch: + image: 'docker.elastic.co/elasticsearch/elasticsearch-oss:6.5.4' + environment: + - cluster.name=docker-cluster + - bootstrap.memory_lock=true + - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + - discovery.type=single-node + - http.port=9200 + - http.cors.allow-origin=http://${APPLICATION_DOMAIN}:${DEJAVU_PORT} + - http.cors.enabled=true + - http.cors.allow-headers=X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization + - http.cors.allow-credentials=true + ports: + - ${ELASTICSEARCH_PORT}:9200 + volumes: + - elasticsearch:/usr/share/elasticsearch/data + - ./.docker/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml + restart: on-failure + + dejavu: + image: appbaseio/dejavu + ports: + - ${DEJAVU_PORT}:1358 + + fpm: + image: kiboko/php:7.2-fpm-blackfire-oroplatform-ce-3.1 + user: docker:docker + volumes: + - ./:/var/www/html + - cache:/var/www/html/var/cache + - assets:/var/www/html/public/bundles + environment: + - "I_AM_DEVELOPER_DISABLE_INDEX_IP_CHECK=" + - BLACKFIRE_CLIENT_ID + - BLACKFIRE_CLIENT_TOKEN + restart: on-failure + + fpm-xdebug: + image: kiboko/php:7.2-fpm-xdebug-orocommerce-ee-3.1 + user: docker:docker + volumes: + - ./:/var/www/html + - cache:/var/www/html/var/cache + - assets:/var/www/html/public/bundles + environment: + - "I_AM_DEVELOPER_DISABLE_INDEX_IP_CHECK=" + restart: on-failure + + blackfire: + image: blackfire/blackfire + environment: + - BLACKFIRE_SERVER_ID + - BLACKFIRE_SERVER_TOKEN + + sh: + image: kiboko/php:7.2-cli-blackfire-orocommerce-ee-3.1 + user: docker:docker + volumes: + - $HOME/.ssh:/opt/docker/.ssh:cached + - ./:/var/www/html + - cache:/var/www/html/var/cache + - assets:/var/www/html/public/bundles + - composer:/opt/docker/.composer/:cached + environment: + - COMPOSER_AUTH + - COMPOSER_PROCESS_TIMEOUT + - BLACKFIRE_CLIENT_ID + - BLACKFIRE_CLIENT_TOKEN + command: [ "sleep", "31536000" ] + restart: "always" + + sh-xdebug: + image: kiboko/php:7.2-cli-xdebug-orocommerce-ee-3.1 + user: docker:docker + volumes: + - $HOME/.ssh:/opt/docker/.ssh:cached + - ./:/var/www/html + - cache:/var/www/html/var/cache + - assets:/var/www/html/public/bundles + - composer:/opt/docker/.composer/ + environment: + - COMPOSER_AUTH + - COMPOSER_PROCESS_TIMEOUT + command: [ "sleep", "31536000" ] + restart: "always" + + mq: + image: kiboko/php:7.1-cli-blackfire-orocommerce-ee-3.1 + user: docker:docker + volumes: + - ./:/var/www/html + - cache:/var/www/html/var/cache + - assets:/var/www/html/public/bundles + command: [ "bin/console", "oro:message-queue:consume", "--env=prod", "-vv" ] + restart: "always" + + ws: + image: kiboko/php:7.1-cli-blackfire-orocommerce-ee-3.1 + user: docker:docker + volumes: + - ./:/var/www/html + - cache:/var/www/html/var/cache + - assets:/var/www/html/public/bundles + command: [ "bin/console", "gos:websocket:server", "--env=prod", "-vv" ] + ports: + - ${WEBSOCKET_PORT}:8080 + restart: "always" + +volumes: + database: + driver: local + elasticsearch: + driver: local + composer: + driver: local + driver_opts: + type: tmpfs + device: tmpfs + o: "size=2048m,uid=1000,gid=1000" + assets: + driver: local + driver_opts: + type: tmpfs + device: tmpfs + o: "size=2048m,uid=1000,gid=1000" + cache: + driver: local + driver_opts: + type: tmpfs + device: tmpfs + o: "size=2048m,uid=1000,gid=1000" diff --git a/config/builds.php b/config/builds.php index f8c5317..68e45d4 100644 --- a/config/builds.php +++ b/config/builds.php @@ -2,402 +2,465 @@ use Kiboko\Cloud\Domain\Packaging; -$repository = new Packaging\Repository('kiboko/php'); +return function(bool $withExperimental): iterable { + $repository = new Packaging\Repository('kiboko/php'); -return [ - new Packaging\Native\Package( + yield new Packaging\Native\Package( $repository, '5.6', new Packaging\Placeholder('native/php@%php.version%/%php.flavor%/'), - new Packaging\Native\Flavor\StandardFlavorRepository() - ), + new Packaging\Native\Flavor\StandardFlavorRepository(), + $withExperimental + ); - new Packaging\Native\Package( + yield new Packaging\Native\Package( $repository, '7.1', new Packaging\Placeholder('native/php@%php.version%/%php.flavor%/'), - new Packaging\Native\Flavor\StandardFlavorRepository() - ), + new Packaging\Native\Flavor\StandardFlavorRepository(), + $withExperimental + ); - new Packaging\Native\Package( + yield new Packaging\Native\Package( $repository, '7.2', new Packaging\Placeholder('native/php@%php.version%/%php.flavor%/'), - new Packaging\Native\Flavor\StandardFlavorRepository() - ), + new Packaging\Native\Flavor\StandardFlavorRepository(), + $withExperimental + ); - new Packaging\Native\Package( + yield new Packaging\Native\Package( $repository, '7.3', new Packaging\Placeholder('native/php@%php.version%/%php.flavor%/'), - new Packaging\Native\Flavor\StandardFlavorRepository() - ), + new Packaging\Native\Flavor\StandardFlavorRepository(), + $withExperimental + ); - new Packaging\Native\Package( + yield new Packaging\Native\Package( $repository, '7.4', new Packaging\Placeholder('native/php@%php.version%/%php.flavor%/'), - new Packaging\Native\Flavor\StandardFlavorRepository() - ), + new Packaging\Native\Flavor\StandardFlavorRepository(), + $withExperimental + ); - new Packaging\Native\Package( + yield new Packaging\Native\Package( $repository, '8.0', new Packaging\Placeholder('native/php@%php.version%/%php.flavor%/'), - new Packaging\Native\Flavor\ExperimentalFlavorRepository() - ), + new Packaging\Native\Flavor\ExperimentalFlavorRepository(), + $withExperimental + ); - new Packaging\Native\PackageVariation( + yield new Packaging\Native\PackageVariation( $repository, '5.6', new Packaging\Placeholder('%package.variation%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), - new Packaging\Native\Variation\StandardVariationRepository() - ), + new Packaging\Native\Variation\StandardVariationRepository(), + $withExperimental + ); - new Packaging\Native\PackageVariation( + yield new Packaging\Native\PackageVariation( $repository, '7.1', new Packaging\Placeholder('%package.variation%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), - new Packaging\Native\Variation\StandardVariationRepository() - ), + new Packaging\Native\Variation\StandardVariationRepository(), + $withExperimental + ); - new Packaging\Native\PackageVariation( + yield new Packaging\Native\PackageVariation( $repository, '7.2', new Packaging\Placeholder('%package.variation%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), - new Packaging\Native\Variation\StandardVariationRepository() - ), + new Packaging\Native\Variation\StandardVariationRepository(), + $withExperimental + ); - new Packaging\Native\PackageVariation( + yield new Packaging\Native\PackageVariation( $repository, '7.3', new Packaging\Placeholder('%package.variation%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), - new Packaging\Native\Variation\StandardVariationRepository() - ), + new Packaging\Native\Variation\StandardVariationRepository(), + $withExperimental + ); - new Packaging\Native\PackageVariation( + yield new Packaging\Native\PackageVariation( $repository, '7.4', new Packaging\Placeholder('%package.variation%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), - new Packaging\Native\Variation\StandardVariationRepository() - ), + new Packaging\Native\Variation\StandardVariationRepository(), + $withExperimental + ); - new Packaging\Native\PackageVariation( + yield new Packaging\Native\PackageVariation( $repository, '8.0', new Packaging\Placeholder('%package.variation%/'), new Packaging\Native\Flavor\ExperimentalFlavorRepository(), - new Packaging\Native\Variation\StandardVariationRepository() - ), + new Packaging\Native\Variation\StandardVariationRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '5.6', new Packaging\Placeholder('oroplatform/%package.edition%/%package.version%/php@%php.version%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroPlatformCommunityEditionRepository() - ), + new Packaging\Platform\Edition\OroPlatformCommunityEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.1', new Packaging\Placeholder('oroplatform/%package.edition%/%package.version%/php@%php.version%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroPlatformCommunityEditionRepository() - ), + new Packaging\Platform\Edition\OroPlatformCommunityEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.2', new Packaging\Placeholder('oroplatform/%package.edition%/%package.version%/php@%php.version%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroPlatformCommunityEditionRepository() - ), + new Packaging\Platform\Edition\OroPlatformCommunityEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.3', new Packaging\Placeholder('oroplatform/%package.edition%/%package.version%/php@%php.version%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroPlatformCommunityEditionRepository() - ), + new Packaging\Platform\Edition\OroPlatformCommunityEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.4', new Packaging\Placeholder('oroplatform/%package.edition%/%package.version%/php@%php.version%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroPlatformCommunityEditionRepository() - ), + new Packaging\Platform\Edition\OroPlatformCommunityEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '5.6', new Packaging\Placeholder('oroplatform/%package.edition%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroPlatformEnterpriseEditionRepository() - ), + new Packaging\Platform\Edition\OroPlatformEnterpriseEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.1', new Packaging\Placeholder('oroplatform/%package.edition%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroPlatformEnterpriseEditionRepository() - ), + new Packaging\Platform\Edition\OroPlatformEnterpriseEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.2', new Packaging\Placeholder('oroplatform/%package.edition%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroPlatformEnterpriseEditionRepository() - ), + new Packaging\Platform\Edition\OroPlatformEnterpriseEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.3', new Packaging\Placeholder('oroplatform/%package.edition%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroPlatformEnterpriseEditionRepository() - ), + new Packaging\Platform\Edition\OroPlatformEnterpriseEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.4', new Packaging\Placeholder('oroplatform/%package.edition%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroPlatformEnterpriseEditionRepository() - ), + new Packaging\Platform\Edition\OroPlatformEnterpriseEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.1', new Packaging\Placeholder('orocommerce/%package.edition%/%package.version%/php@%php.version%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroCommerceCommunityEditionRepository() - ), + new Packaging\Platform\Edition\OroCommerceCommunityEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.2', new Packaging\Placeholder('orocommerce/%package.edition%/%package.version%/php@%php.version%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroCommerceCommunityEditionRepository() - ), + new Packaging\Platform\Edition\OroCommerceCommunityEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.3', new Packaging\Placeholder('orocommerce/%package.edition%/%package.version%/php@%php.version%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroCommerceCommunityEditionRepository() - ), + new Packaging\Platform\Edition\OroCommerceCommunityEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.4', new Packaging\Placeholder('orocommerce/%package.edition%/%package.version%/php@%php.version%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroCommerceCommunityEditionRepository() - ), + new Packaging\Platform\Edition\OroCommerceCommunityEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.1', new Packaging\Placeholder('orocommerce/%package.edition%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroCommerceEnterpriseEditionRepository() - ), + new Packaging\Platform\Edition\OroCommerceEnterpriseEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.2', new Packaging\Placeholder('orocommerce/%package.edition%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroCommerceEnterpriseEditionRepository() - ), + new Packaging\Platform\Edition\OroCommerceEnterpriseEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.3', new Packaging\Placeholder('orocommerce/%package.edition%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroCommerceEnterpriseEditionRepository() - ), + new Packaging\Platform\Edition\OroCommerceEnterpriseEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.4', new Packaging\Placeholder('orocommerce/%package.edition%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroCommerceEnterpriseEditionRepository() - ), + new Packaging\Platform\Edition\OroCommerceEnterpriseEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.1', new Packaging\Placeholder('orocrm/%package.edition%/%package.version%/php@%php.version%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroCRMCommunityEditionRepository() - ), + new Packaging\Platform\Edition\OroCRMCommunityEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.2', new Packaging\Placeholder('orocrm/%package.edition%/%package.version%/php@%php.version%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroCRMCommunityEditionRepository() - ), + new Packaging\Platform\Edition\OroCRMCommunityEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.3', new Packaging\Placeholder('orocrm/%package.edition%/%package.version%/php@%php.version%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroCRMCommunityEditionRepository() - ), + new Packaging\Platform\Edition\OroCRMCommunityEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.4', new Packaging\Placeholder('orocrm/%package.edition%/%package.version%/php@%php.version%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroCRMCommunityEditionRepository() - ), + new Packaging\Platform\Edition\OroCRMCommunityEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.1', new Packaging\Placeholder('orocrm/%package.edition%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroCRMEnterpriseEditionRepository() - ), + new Packaging\Platform\Edition\OroCRMEnterpriseEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.2', new Packaging\Placeholder('orocrm/%package.edition%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroCRMEnterpriseEditionRepository() - ), + new Packaging\Platform\Edition\OroCRMEnterpriseEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.3', new Packaging\Placeholder('orocrm/%package.edition%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroCRMEnterpriseEditionRepository() - ), + new Packaging\Platform\Edition\OroCRMEnterpriseEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.4', new Packaging\Placeholder('orocrm/%package.edition%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\OroCRMEnterpriseEditionRepository() - ), + new Packaging\Platform\Edition\OroCRMEnterpriseEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.1', new Packaging\Placeholder('marello/%package.edition%/%package.version%/php@%php.version%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\MarelloCommunityEditionRepository() - ), + new Packaging\Platform\Edition\MarelloCommunityEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.2', new Packaging\Placeholder('marello/%package.edition%/%package.version%/php@%php.version%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\MarelloCommunityEditionRepository() - ), + new Packaging\Platform\Edition\MarelloCommunityEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.3', new Packaging\Placeholder('marello/%package.edition%/%package.version%/php@%php.version%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\MarelloCommunityEditionRepository() - ), + new Packaging\Platform\Edition\MarelloCommunityEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.4', new Packaging\Placeholder('marello/%package.edition%/%package.version%/php@%php.version%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), new Packaging\Platform\Edition\MarelloCommunityEditionRepository() - ), + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.1', new Packaging\Placeholder('marello/%package.edition%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\MarelloEnterpriseEditionRepository() - ), + new Packaging\Platform\Edition\MarelloEnterpriseEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.2', new Packaging\Placeholder('marello/%package.edition%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\MarelloEnterpriseEditionRepository() - ), + new Packaging\Platform\Edition\MarelloEnterpriseEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.3', new Packaging\Placeholder('marello/%package.edition%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\MarelloEnterpriseEditionRepository() - ), + new Packaging\Platform\Edition\MarelloEnterpriseEditionRepository(), + $withExperimental + ); - new Packaging\Platform\Package( + yield new Packaging\Platform\Package( $repository, '7.4', new Packaging\Placeholder('marello/%package.edition%/'), new Packaging\Native\Flavor\StandardFlavorRepository(), new Packaging\Native\Variation\StandardVariationRepository(), - new Packaging\Platform\Edition\MarelloEnterpriseEditionRepository() - ), -]; \ No newline at end of file + new Packaging\Platform\Edition\MarelloEnterpriseEditionRepository(), + $withExperimental + ); + + yield new Packaging\Platform\Package( + $repository, + '7.4', + new Packaging\Placeholder('middleware/%package.edition%/%package.version%/php@%php.version%/'), + new Packaging\Native\Flavor\StandardFlavorRepository(), + new Packaging\Native\Variation\StandardVariationRepository(), + new Packaging\Platform\Edition\MiddlewareCommunityEditionRepository() + ); + + yield new Packaging\Platform\Package( + $repository, + '7.4', + new Packaging\Placeholder('middleware/%package.edition%/'), + new Packaging\Native\Flavor\StandardFlavorRepository(), + new Packaging\Native\Variation\StandardVariationRepository(), + new Packaging\Platform\Edition\MiddlewareEnterpriseEditionRepository() + ); +}; \ No newline at end of file diff --git a/config/constraints.php b/config/constraints.php index ca830c1..e16e134 100644 --- a/config/constraints.php +++ b/config/constraints.php @@ -59,7 +59,9 @@ new Assert\PHPExtensionVersion($repository, 'xml', '*', '/-[ce]e-\d+\.\d+-/'), new Assert\PHPExtensionVersion($repository, 'zip', '*', '/-[ce]e-\d+\.\d+-/'), new Assert\PHPExtensionVersion($repository, 'imap', '*', '/-[ce]e-\d+\.\d+-/'), - new Assert\PHPExtensionVersion($repository, 'pcntl', '*', '/(?:(?:oroplatform|orocommerce|orocrm)-[ce]e-4\.\d+-|marello-[ce]e-3\.\d+)/'), + new Assert\PHPExtensionVersion($repository, 'pcntl', '*', '/(?:(?:oroplatform|orocommerce|orocrm)-[ce]e-4\.\d+-|marello-[ce]e-3\.\d+|middleware-[ce]e-1\.\d+)/'), + new Assert\PHPExtensionVersion($repository, 'zmq', '*', '/(?:middleware-[ce]e-1\.\d+-)/'), + new Assert\PHPExtensionVersion($repository, 'rdkafka', '*', '/(?:middleware-[ce]e-1\.\d+-)/'), new Assert\ICUVersion($repository, '>=4.4', '/-[ce]e-\d+\.\d+-/'), ]; diff --git a/docker-compose.yml b/docker-compose.yml index 31083f6..a09d290 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,6 +11,7 @@ services: - ./environments:/environments - ./compose:/compose - /var/run/docker.sock:/var/run/docker.sock + - $HOME/.docker:/opt/docker/.docker environment: - 'PHP_IDE_CONFIG=serverName=Docker' command: [ "sleep", "31536000" ] \ No newline at end of file diff --git a/environments/middleware/ce/1.0/php@7.4/Dockerfile b/environments/middleware/ce/1.0/php@7.4/Dockerfile new file mode 100644 index 0000000..09a9fe6 --- /dev/null +++ b/environments/middleware/ce/1.0/php@7.4/Dockerfile @@ -0,0 +1,34 @@ +ARG SOURCE_VARIATION + +FROM kiboko/php:${SOURCE_VARIATION} + +LABEL maintainer="Grégory Planchat " + +RUN set -ex\ + && apk add --virtual .build-deps \ + autoconf \ + bash \ + binutils \ + expat \ + file \ + g++ \ + gcc \ + m4 \ + make \ + librdkafka-dev \ + git \ + && apk add \ + librdkafka \ + && ( \ + git clone https://github.com/arnaud-lb/php-rdkafka.git \ + && cd php-rdkafka \ + && phpize \ + && autoconf \ + && ./configure \ + && make all -j5 \ + && make install \ + && cd - \ + && echo "extension=rdkafka.so" > /usr/local/etc/php/conf.d/rdkafka.ini \ + ) \ + && apk del .build-deps \ + && rm -rf /tmp/* /var/cache/apk/* diff --git a/environments/middleware/ee/Dockerfile b/environments/middleware/ee/Dockerfile new file mode 100644 index 0000000..09a9fe6 --- /dev/null +++ b/environments/middleware/ee/Dockerfile @@ -0,0 +1,34 @@ +ARG SOURCE_VARIATION + +FROM kiboko/php:${SOURCE_VARIATION} + +LABEL maintainer="Grégory Planchat " + +RUN set -ex\ + && apk add --virtual .build-deps \ + autoconf \ + bash \ + binutils \ + expat \ + file \ + g++ \ + gcc \ + m4 \ + make \ + librdkafka-dev \ + git \ + && apk add \ + librdkafka \ + && ( \ + git clone https://github.com/arnaud-lb/php-rdkafka.git \ + && cd php-rdkafka \ + && phpize \ + && autoconf \ + && ./configure \ + && make all -j5 \ + && make install \ + && cd - \ + && echo "extension=rdkafka.so" > /usr/local/etc/php/conf.d/rdkafka.ini \ + ) \ + && apk del .build-deps \ + && rm -rf /tmp/* /var/cache/apk/* diff --git a/src/Domain/Packaging/BuildableInterface.php b/src/Domain/Packaging/BuildableInterface.php index a6fa0d9..cad7df3 100644 --- a/src/Domain/Packaging/BuildableInterface.php +++ b/src/Domain/Packaging/BuildableInterface.php @@ -6,8 +6,8 @@ interface BuildableInterface { - public function pull(Packaging\CommandBus\CommandBusInterface $commands): void; - public function push(Packaging\CommandBus\CommandBusInterface $commands): void; - public function build(Packaging\CommandBus\CommandBusInterface $commands): void; - public function forceBuild(Packaging\CommandBus\CommandBusInterface $commands): void; + public function pull(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task; + public function push(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task; + public function build(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task; + public function forceBuild(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task; } diff --git a/src/Domain/Packaging/CommandBus/CommandBus.php b/src/Domain/Packaging/CommandBus/CommandBus.php deleted file mode 100644 index f84df5f..0000000 --- a/src/Domain/Packaging/CommandBus/CommandBus.php +++ /dev/null @@ -1,81 +0,0 @@ -commands = $commands; - $this->iterator = new \ArrayIterator($this->commands); - } - - public function __toString() - { - return sprintf('command bus( %d )', count($this)); - } - - public function add(Packaging\Command\CommandInterface ...$commands): void - { - array_push($this->commands, ...$commands); - $this->iterator = new \ArrayIterator($this->commands); - } - - public function __invoke(string $rootPath): void - { - foreach ($this->commands as $command) { - $command($rootPath); - } - } - - public function count() - { - return count($this->commands); - } - - public function current() - { - return $this->iterator->current(); - } - - public function next() - { - $this->iterator->next(); - } - - public function key() - { - return $this->iterator->key(); - } - - public function valid() - { - return $this->iterator->valid(); - } - - public function rewind() - { - $this->iterator->rewind(); - } - - public function hasChildren() - { - return $this->iterator->current() instanceof CommandBusInterface; - } - - public function getChildren() - { - if ($this->iterator->current() instanceof CommandBusInterface) { - return $this->iterator->current(); - } - - return new \RecursiveArrayIterator([]); - } -} diff --git a/src/Domain/Packaging/CommandBus/CommandBusInterface.php b/src/Domain/Packaging/CommandBus/CommandBusInterface.php deleted file mode 100644 index 6f69678..0000000 --- a/src/Domain/Packaging/CommandBus/CommandBusInterface.php +++ /dev/null @@ -1,14 +0,0 @@ -withExperimental = $withExperimental; + } + + /** @return Packaging\PackageInterface[] */ + public static function builds(string $configPath, bool $withExperimental = false): iterable + { + $config = new self($withExperimental); + + return $config->walkBuilds(require $configPath.'/builds.php'); + } + + /** @return Packaging\PackageInterface[] */ + public function walkBuilds(callable $callback): iterable + { + return new \ArrayIterator( +// new \NoRewindIterator( + iterator_to_array($callback($this->withExperimental)), +// ), + \CachingIterator::FULL_CACHE + ); + } +} \ No newline at end of file diff --git a/src/Domain/Packaging/DependencyTree/Node.php b/src/Domain/Packaging/DependencyTree/Node.php index 88d342e..2d30a6e 100644 --- a/src/Domain/Packaging/DependencyTree/Node.php +++ b/src/Domain/Packaging/DependencyTree/Node.php @@ -4,7 +4,7 @@ namespace Kiboko\Cloud\Domain\Packaging\DependencyTree; -use Kiboko\Cloud\Domain\Packaging\CommandBus; +use Kiboko\Cloud\Domain\Packaging\Execution\CommandBus; use Kiboko\Cloud\Domain\Packaging; use Kiboko\Cloud\Domain\Packaging\Placeholder; @@ -45,24 +45,32 @@ public function getIterator() return new \ArrayIterator($this->edges); } - public function pull(CommandBus\CommandBusInterface $commands): void + public function pull(CommandBus\Task $task): CommandBus\Task { - $this->tag->pull($commands); + $this->tag->pull($task); + + return $task; } - public function push(CommandBus\CommandBusInterface $commands): void + public function push(CommandBus\Task $task): CommandBus\Task { - $this->tag->push($commands); + $this->tag->push($task); + + return $task; } - public function build(CommandBus\CommandBusInterface $commands): void + public function build(CommandBus\Task $task): CommandBus\Task { - $this->tag->build($commands); + $this->tag->build($task); + + return $task; } - public function forceBuild(CommandBus\CommandBusInterface $commands): void + public function forceBuild(CommandBus\Task $task): CommandBus\Task { - $this->tag->forceBuild($commands); + $this->tag->forceBuild($task); + + return $task; } public function add(NodeInterface ...$edges): void diff --git a/src/Domain/Packaging/Command/Build.php b/src/Domain/Packaging/Execution/Command/Build.php similarity index 95% rename from src/Domain/Packaging/Command/Build.php rename to src/Domain/Packaging/Execution/Command/Build.php index 75e5be5..1101feb 100644 --- a/src/Domain/Packaging/Command/Build.php +++ b/src/Domain/Packaging/Execution/Command/Build.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Kiboko\Cloud\Domain\Packaging\Command; +namespace Kiboko\Cloud\Domain\Packaging\Execution\Command; use Kiboko\Cloud\Domain\Packaging; use Psr\Log\LoggerAwareInterface; diff --git a/src/Domain/Packaging/Command/BuildFrom.php b/src/Domain/Packaging/Execution/Command/BuildFrom.php similarity index 96% rename from src/Domain/Packaging/Command/BuildFrom.php rename to src/Domain/Packaging/Execution/Command/BuildFrom.php index 928156b..2066949 100644 --- a/src/Domain/Packaging/Command/BuildFrom.php +++ b/src/Domain/Packaging/Execution/Command/BuildFrom.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Kiboko\Cloud\Domain\Packaging\Command; +namespace Kiboko\Cloud\Domain\Packaging\Execution\Command; use Kiboko\Cloud\Domain\Packaging; use Psr\Log\LoggerAwareInterface; diff --git a/src/Domain/Packaging/Command/CommandInterface.php b/src/Domain/Packaging/Execution/Command/CommandInterface.php similarity index 75% rename from src/Domain/Packaging/Command/CommandInterface.php rename to src/Domain/Packaging/Execution/Command/CommandInterface.php index 10c48df..e37fb2c 100644 --- a/src/Domain/Packaging/Command/CommandInterface.php +++ b/src/Domain/Packaging/Execution/Command/CommandInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Kiboko\Cloud\Domain\Packaging\Command; +namespace Kiboko\Cloud\Domain\Packaging\Execution\Command; use Symfony\Component\Process\Process; diff --git a/src/Domain/Packaging/Command/ForceBuild.php b/src/Domain/Packaging/Execution/Command/ForceBuild.php similarity index 95% rename from src/Domain/Packaging/Command/ForceBuild.php rename to src/Domain/Packaging/Execution/Command/ForceBuild.php index 4c776fb..3b6ab65 100644 --- a/src/Domain/Packaging/Command/ForceBuild.php +++ b/src/Domain/Packaging/Execution/Command/ForceBuild.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Kiboko\Cloud\Domain\Packaging\Command; +namespace Kiboko\Cloud\Domain\Packaging\Execution\Command; use Kiboko\Cloud\Domain\Packaging; use Psr\Log\LoggerAwareInterface; diff --git a/src/Domain/Packaging/Command/ForceBuildFrom.php b/src/Domain/Packaging/Execution/Command/ForceBuildFrom.php similarity index 96% rename from src/Domain/Packaging/Command/ForceBuildFrom.php rename to src/Domain/Packaging/Execution/Command/ForceBuildFrom.php index eeb6267..f94c4f9 100644 --- a/src/Domain/Packaging/Command/ForceBuildFrom.php +++ b/src/Domain/Packaging/Execution/Command/ForceBuildFrom.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Kiboko\Cloud\Domain\Packaging\Command; +namespace Kiboko\Cloud\Domain\Packaging\Execution\Command; use Kiboko\Cloud\Domain\Packaging; use Psr\Log\LoggerAwareInterface; diff --git a/src/Domain/Packaging/Command/Pull.php b/src/Domain/Packaging/Execution/Command/Pull.php similarity index 93% rename from src/Domain/Packaging/Command/Pull.php rename to src/Domain/Packaging/Execution/Command/Pull.php index 468dba8..4767a94 100644 --- a/src/Domain/Packaging/Command/Pull.php +++ b/src/Domain/Packaging/Execution/Command/Pull.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Kiboko\Cloud\Domain\Packaging\Command; +namespace Kiboko\Cloud\Domain\Packaging\Execution\Command; use Kiboko\Cloud\Domain\Packaging; use Psr\Log\LoggerAwareInterface; diff --git a/src/Domain/Packaging/Command/Push.php b/src/Domain/Packaging/Execution/Command/Push.php similarity index 93% rename from src/Domain/Packaging/Command/Push.php rename to src/Domain/Packaging/Execution/Command/Push.php index 93c78c3..4c913c3 100644 --- a/src/Domain/Packaging/Command/Push.php +++ b/src/Domain/Packaging/Execution/Command/Push.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Kiboko\Cloud\Domain\Packaging\Command; +namespace Kiboko\Cloud\Domain\Packaging\Execution\Command; use Kiboko\Cloud\Domain\Packaging; use Psr\Log\LoggerAwareInterface; diff --git a/src/Domain/Packaging/Execution/CommandBus/CommandBus.php b/src/Domain/Packaging/Execution/CommandBus/CommandBus.php new file mode 100644 index 0000000..e3d28f2 --- /dev/null +++ b/src/Domain/Packaging/Execution/CommandBus/CommandBus.php @@ -0,0 +1,75 @@ +tasks = new \ArrayIterator([new Task(...$commands)]); + } + + public function __toString() + { + return sprintf('command bus( %d )', count($this)); + } + + public function task(): Task + { + $this->tasks->append($task = new Task()); + + return $task; + } + + public function add(Packaging\Execution\Command\CommandInterface ...$commands): Task + { + $this->tasks->append($task = new Task(...$commands)); + + return $task; + } + + public function countProcesses(): int + { + $sum = 0; + foreach ($this->tasks as $task) { + $sum += count($task); + } + return $sum; + } + + public function count() + { + return count($this->tasks); + } + + public function current() + { + return $this->tasks->current(); + } + + public function next() + { + $this->tasks->next(); + } + + public function key() + { + return $this->tasks->key(); + } + + public function valid() + { + return $this->tasks->valid(); + } + + public function rewind() + { + $this->tasks->rewind(); + } +} diff --git a/src/Domain/Packaging/Execution/CommandBus/CommandBusInterface.php b/src/Domain/Packaging/Execution/CommandBus/CommandBusInterface.php new file mode 100644 index 0000000..7a5235d --- /dev/null +++ b/src/Domain/Packaging/Execution/CommandBus/CommandBusInterface.php @@ -0,0 +1,14 @@ +output->section()); $section = $this->output->section(); - /** @var Packaging\Command\CommandInterface $command */ - foreach ($progressBar->iterate($iterator, iterator_count($iterator)) as $command) { - $section->overwrite(sprintf('Running: %s', (string) $command)); - $process = $command($rootPath); + /** @var Task $task */ + foreach ($progressBar->iterate($commandBus, count($commandBus)) as $task) { + /** @var CommandInterface $command */ + foreach ($task as $command) { + $section->overwrite(sprintf('Running: %s', (string)$task)); + $process = $command($rootPath); - $process->run(); + $process->run(); - if (!$process->isSuccessful()) { - throw new ProcessFailedException($process); + if (!$process->isSuccessful()) { + throw new ProcessFailedException($process); + } } } $section->overwrite('Finished!'); diff --git a/src/Domain/Packaging/Execution/CommandBus/Task.php b/src/Domain/Packaging/Execution/CommandBus/Task.php new file mode 100644 index 0000000..3fa180a --- /dev/null +++ b/src/Domain/Packaging/Execution/CommandBus/Task.php @@ -0,0 +1,41 @@ +commands = $commands; + } + + public function then(CommandInterface ...$commands): self + { + array_push($this->commands, ...$commands); + + return $this; + } + + public function getIterator() + { + yield from $this->commands; + } + + public function count() + { + return count($this->commands); + } + + public function __toString() + { + return implode(', ', array_map(function (CommandInterface $command): string { + return (string) $command; + }, $this->commands)); + } +} \ No newline at end of file diff --git a/src/Domain/Packaging/Native/Package.php b/src/Domain/Packaging/Native/Package.php index 1edb152..902caf0 100644 --- a/src/Domain/Packaging/Native/Package.php +++ b/src/Domain/Packaging/Native/Package.php @@ -11,17 +11,20 @@ final class Package implements \IteratorAggregate, Packaging\PackageInterface, P public string $number; private Packaging\Placeholder $path; private Native\Flavor\FlavorRepositoryInterface $flavors; + private bool $withExperimental; public function __construct( Packaging\RepositoryInterface $repository, string $number, Packaging\Placeholder $path, - Native\Flavor\FlavorRepositoryInterface $flavors + Native\Flavor\FlavorRepositoryInterface $flavors, + bool $withExperimental = false ) { $this->repository = $repository; $this->number = $number; $this->path = $path; $this->flavors = $flavors; + $this->withExperimental = $withExperimental; } public function __invoke(): \Traversable @@ -46,35 +49,43 @@ public function getIterator() } } - public function pull(Packaging\CommandBus\CommandBusInterface $commands): void + public function pull(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { /** @var Packaging\Tag\TagBuildInterface $tag */ foreach ($this as $tag) { - $tag->pull($commands); + $tag->pull($task); } + + return $task; } - public function push(Packaging\CommandBus\CommandBusInterface $commands): void + public function push(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { /** @var Packaging\Tag\TagBuildInterface $tag */ foreach ($this as $tag) { - $tag->push($commands); + $tag->push($task); } + + return $task; } - public function build(Packaging\CommandBus\CommandBusInterface $commands): void + public function build(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { /** @var Packaging\Tag\TagBuildInterface $tag */ foreach ($this as $tag) { - $tag->build($commands); + $tag->build($task); } + + return $task; } - public function forceBuild(Packaging\CommandBus\CommandBusInterface $commands): void + public function forceBuild(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { /** @var Packaging\Tag\TagBuildInterface $tag */ foreach ($this as $tag) { - $tag->forceBuild($commands); + $tag->forceBuild($task); } + + return $task; } } \ No newline at end of file diff --git a/src/Domain/Packaging/Native/PackageVariation.php b/src/Domain/Packaging/Native/PackageVariation.php index b522bc6..c9f23c8 100644 --- a/src/Domain/Packaging/Native/PackageVariation.php +++ b/src/Domain/Packaging/Native/PackageVariation.php @@ -13,19 +13,22 @@ final class PackageVariation implements \IteratorAggregate, Packaging\PackageInt private Packaging\Placeholder $path; private Native\Flavor\FlavorRepositoryInterface $flavors; private Native\Variation\PackageVariationInterface $variations; + private bool $withExperimental; public function __construct( Packaging\RepositoryInterface $repository, string $number, Packaging\Placeholder $path, Native\Flavor\FlavorRepositoryInterface $flavors, - Native\Variation\PackageVariationInterface $variations + Native\Variation\PackageVariationInterface $variations, + bool $withExperimental = false ) { $this->repository = $repository; $this->number = $number; $this->path = $path; $this->flavors = $flavors; $this->variations = $variations; + $this->withExperimental = $withExperimental; } public function __invoke(): \Traversable @@ -53,35 +56,43 @@ public function getIterator() } } - public function pull(Packaging\CommandBus\CommandBusInterface $commands): void + public function pull(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { /** @var Packaging\Tag\TagBuildInterface $tag */ foreach ($this as $tag) { - $tag->pull($commands); + $tag->pull($task); } + + return $task; } - public function push(Packaging\CommandBus\CommandBusInterface $commands): void + public function push(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { /** @var Packaging\Tag\TagBuildInterface $tag */ foreach ($this as $tag) { - $tag->push($commands); + $tag->push($task); } + + return $task; } - public function build(Packaging\CommandBus\CommandBusInterface $commands): void + public function build(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { /** @var Packaging\Tag\TagBuildInterface $tag */ foreach ($this as $tag) { - $tag->build($commands); + $tag->build($task); } + + return $task; } - public function forceBuild(Packaging\CommandBus\CommandBusInterface $commands): void + public function forceBuild(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { /** @var Packaging\Tag\TagBuildInterface $tag */ foreach ($this as $tag) { - $tag->forceBuild($commands); + $tag->forceBuild($task); } + + return $task; } } \ No newline at end of file diff --git a/src/Domain/Packaging/Native/Tag.php b/src/Domain/Packaging/Native/Tag.php index ed2f9f1..77c5ec9 100644 --- a/src/Domain/Packaging/Native/Tag.php +++ b/src/Domain/Packaging/Native/Tag.php @@ -34,23 +34,31 @@ public function getRepository(): Packaging\RepositoryInterface return $this->repository; } - public function pull(Packaging\CommandBus\CommandBusInterface $commands): void + public function pull(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { - $commands->add(new Packaging\Command\Pull($this)); + $task->then(new Packaging\Execution\Command\Pull($this)); + + return $task; } - public function push(Packaging\CommandBus\CommandBusInterface $commands): void + public function push(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { - $commands->add(new Packaging\Command\Push($this)); + $task->then(new Packaging\Execution\Command\Push($this)); + + return $task; } - public function build(Packaging\CommandBus\CommandBusInterface $commands): void + public function build(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { - $commands->add(new Packaging\Command\Build($this, $this->context)); + $task->then(new Packaging\Execution\Command\Build($this, $this->context)); + + return $task; } - public function forceBuild(Packaging\CommandBus\CommandBusInterface $commands): void + public function forceBuild(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { - $commands->add(new Packaging\Command\ForceBuild($this, $this->context)); + $task->then(new Packaging\Execution\Command\ForceBuild($this, $this->context)); + + return $task; } } \ No newline at end of file diff --git a/src/Domain/Packaging/Native/TagVariation.php b/src/Domain/Packaging/Native/TagVariation.php index 6bfcada..683dde9 100644 --- a/src/Domain/Packaging/Native/TagVariation.php +++ b/src/Domain/Packaging/Native/TagVariation.php @@ -42,23 +42,23 @@ public function getRepository(): Packaging\RepositoryInterface return $this->repository; } - public function pull(Packaging\CommandBus\CommandBusInterface $commands): void + public function pull(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { - $commands->add(new Packaging\Command\Pull($this)); + return $task->then(new Packaging\Execution\Command\Pull($this)); } - public function push(Packaging\CommandBus\CommandBusInterface $commands): void + public function push(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { - $commands->add(new Packaging\Command\Push($this)); + return $task->then(new Packaging\Execution\Command\Push($this)); } - public function build(Packaging\CommandBus\CommandBusInterface $commands): void + public function build(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { - $commands->add(new Packaging\Command\BuildFrom($this, $this->from, $this->context)); + return $task->then(new Packaging\Execution\Command\BuildFrom($this, $this->from, $this->context)); } - public function forceBuild(Packaging\CommandBus\CommandBusInterface $commands): void + public function forceBuild(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { - $commands->add(new Packaging\Command\ForceBuildFrom($this, $this->from, $this->context)); + return $task->then(new Packaging\Execution\Command\ForceBuildFrom($this, $this->from, $this->context)); } } \ No newline at end of file diff --git a/src/Domain/Packaging/Platform/Edition/Edition.php b/src/Domain/Packaging/Platform/Edition/Edition.php index 4ff5b3b..99a6ad8 100644 --- a/src/Domain/Packaging/Platform/Edition/Edition.php +++ b/src/Domain/Packaging/Platform/Edition/Edition.php @@ -8,13 +8,15 @@ class Edition implements EditionInterface private string $version; private string $edition; private string $phpConstraint; + private string $phpExperimentalConstraint; - public function __construct(string $package, string $version, string $edition, string $phpConstraint = '*') + public function __construct(string $package, string $version, string $edition, string $phpConstraint = '*', ?string $phpExperimentalConstraint = null) { $this->package = $package; $this->version = $version; $this->edition = $edition; $this->phpConstraint = $phpConstraint; + $this->phpExperimentalConstraint = $phpExperimentalConstraint ?? $phpConstraint; } public function getPackage(): string @@ -36,4 +38,9 @@ public function getPhpConstraint(): string { return $this->phpConstraint; } + + public function getPhpExperimentalConstraint(): string + { + return $this->phpExperimentalConstraint; + } } \ No newline at end of file diff --git a/src/Domain/Packaging/Platform/Edition/EditionDependency.php b/src/Domain/Packaging/Platform/Edition/EditionDependency.php index bd0138e..1a2efcc 100644 --- a/src/Domain/Packaging/Platform/Edition/EditionDependency.php +++ b/src/Domain/Packaging/Platform/Edition/EditionDependency.php @@ -8,7 +8,7 @@ class EditionDependency extends Edition implements EditionDependencyInterface public function __construct(string $package, string $version, string $edition, Edition $parent) { - parent::__construct($package, $version, $edition, $parent->getPhpConstraint()); + parent::__construct($package, $version, $edition, $parent->getPhpConstraint(), $parent->getPhpExperimentalConstraint()); $this->parent = $parent; } diff --git a/src/Domain/Packaging/Platform/Edition/EditionInterface.php b/src/Domain/Packaging/Platform/Edition/EditionInterface.php index 9ba08bd..8f28283 100644 --- a/src/Domain/Packaging/Platform/Edition/EditionInterface.php +++ b/src/Domain/Packaging/Platform/Edition/EditionInterface.php @@ -8,4 +8,5 @@ public function getPackage(): string; public function getVersion(): string; public function getEdition(): string; public function getPhpConstraint(): string; + public function getPhpExperimentalConstraint(): string; } \ No newline at end of file diff --git a/src/Domain/Packaging/Platform/Edition/MarelloCommunityEditionRepository.php b/src/Domain/Packaging/Platform/Edition/MarelloCommunityEditionRepository.php index cf674c9..41b76bc 100644 --- a/src/Domain/Packaging/Platform/Edition/MarelloCommunityEditionRepository.php +++ b/src/Domain/Packaging/Platform/Edition/MarelloCommunityEditionRepository.php @@ -17,6 +17,7 @@ public function getIterator() '>=5.6 <7.2' ) ); + yield new EditionDependency( 'marello', '1.6', @@ -37,7 +38,8 @@ public function getIterator() 'oroplatform', '3.1', 'ce', - '>=7.1 <8.1' + '>=7.1 <7.3', + '>=7.1 <=8.0' ) ); @@ -49,7 +51,8 @@ public function getIterator() 'oroplatform', '3.1', 'ce', - '>=7.1 <8.1' + '>=7.1 <7.3', + '>=7.1 <=8.0' ) ); @@ -61,7 +64,8 @@ public function getIterator() 'oroplatform', '3.1', 'ce', - '>=7.1 <8.1' + '>=7.1 <7.3', + '>=7.1 <=8.0' ) ); @@ -73,7 +77,8 @@ public function getIterator() 'oroplatform', '4.1', 'ce', - '>=7.3 <9.0' + '>=7.3 <8.0', + '>=7.3 <=8.0' ) ); } diff --git a/src/Domain/Packaging/Platform/Edition/MarelloEnterpriseEditionRepository.php b/src/Domain/Packaging/Platform/Edition/MarelloEnterpriseEditionRepository.php index 4c8c2f0..1b7c38a 100644 --- a/src/Domain/Packaging/Platform/Edition/MarelloEnterpriseEditionRepository.php +++ b/src/Domain/Packaging/Platform/Edition/MarelloEnterpriseEditionRepository.php @@ -17,6 +17,7 @@ public function getIterator() '>=5.6 <7.2' ) ); + yield new EditionDependency( 'marello', '1.3', @@ -37,7 +38,8 @@ public function getIterator() 'oroplatform', '3.1', 'ee', - '>=7.1 <8.1' + '>=7.1 <7.3', + '>=7.1 <=8.0' ) ); @@ -49,7 +51,8 @@ public function getIterator() 'oroplatform', '3.1', 'ee', - '>=7.1 <8.1' + '>=7.1 <7.3', + '>=7.1 <=8.0' ) ); @@ -61,7 +64,8 @@ public function getIterator() 'oroplatform', '3.1', 'ee', - '>=7.1 <8.1' + '>=7.1 <7.3', + '>=7.1 <=8.0' ) ); @@ -73,7 +77,8 @@ public function getIterator() 'oroplatform', '4.1', 'ee', - '>=7.3 <9.0' + '>=7.3 <8.0', + '>=7.3 <=8.0' ) ); } diff --git a/src/Domain/Packaging/Platform/Edition/MiddlewareCommunityEditionRepository.php b/src/Domain/Packaging/Platform/Edition/MiddlewareCommunityEditionRepository.php new file mode 100644 index 0000000..3ed9d5f --- /dev/null +++ b/src/Domain/Packaging/Platform/Edition/MiddlewareCommunityEditionRepository.php @@ -0,0 +1,22 @@ +=7.4 <8.0', + '>=7.4 <=8.0' + ) + ); + } +} \ No newline at end of file diff --git a/src/Domain/Packaging/Platform/Edition/MiddlewareEnterpriseEditionRepository.php b/src/Domain/Packaging/Platform/Edition/MiddlewareEnterpriseEditionRepository.php new file mode 100644 index 0000000..100e30c --- /dev/null +++ b/src/Domain/Packaging/Platform/Edition/MiddlewareEnterpriseEditionRepository.php @@ -0,0 +1,22 @@ +=7.4 <8.0', + '>=7.4 <=8.0' + ) + ); + } +} \ No newline at end of file diff --git a/src/Domain/Packaging/Platform/Edition/OroCRMCommunityEditionRepository.php b/src/Domain/Packaging/Platform/Edition/OroCRMCommunityEditionRepository.php index a556209..764d53b 100644 --- a/src/Domain/Packaging/Platform/Edition/OroCRMCommunityEditionRepository.php +++ b/src/Domain/Packaging/Platform/Edition/OroCRMCommunityEditionRepository.php @@ -6,6 +6,18 @@ final class OroCRMCommunityEditionRepository implements EditionRepositoryInterfa { public function getIterator() { + yield new EditionDependency( + 'orocrm', + '2.6', + 'ce', + new Edition( + 'oroplatform', + '2.6', + 'ce', + '>=5.6 <7.2' + ) + ); + yield new EditionDependency( 'orocrm', '3.1', @@ -14,7 +26,8 @@ public function getIterator() 'oroplatform', '3.1', 'ce', - '>=7.1 <8.1' + '>=7.1 <7.3', + '>=7.1 <=8.0', ) ); @@ -26,7 +39,8 @@ public function getIterator() 'oroplatform', '4.1', 'ce', - '>=7.3 <9.0' + '>=7.3 <8.0', + '>=7.3 <=8.0', ) ); } diff --git a/src/Domain/Packaging/Platform/Edition/OroCRMEnterpriseEditionRepository.php b/src/Domain/Packaging/Platform/Edition/OroCRMEnterpriseEditionRepository.php index db38a89..213b980 100644 --- a/src/Domain/Packaging/Platform/Edition/OroCRMEnterpriseEditionRepository.php +++ b/src/Domain/Packaging/Platform/Edition/OroCRMEnterpriseEditionRepository.php @@ -6,6 +6,18 @@ final class OroCRMEnterpriseEditionRepository implements EditionRepositoryInterf { public function getIterator() { + yield new EditionDependency( + 'orocrm', + '2.6', + 'ee', + new Edition( + 'oroplatform', + '2.6', + 'ee', + '>=5.6 <7.2' + ) + ); + yield new EditionDependency( 'orocrm', '3.1', @@ -14,7 +26,8 @@ public function getIterator() 'oroplatform', '3.1', 'ee', - '>=7.1 <8.1' + '>=7.1 <7.3', + '>=7.1 <=8.0', ) ); @@ -26,7 +39,8 @@ public function getIterator() 'oroplatform', '4.1', 'ee', - '>=7.3 <9.0' + '>=7.3 <8.0', + '>=7.3 <=8.0', ) ); } diff --git a/src/Domain/Packaging/Platform/Edition/OroCommerceCommunityEditionRepository.php b/src/Domain/Packaging/Platform/Edition/OroCommerceCommunityEditionRepository.php index 3c5f27f..b147249 100644 --- a/src/Domain/Packaging/Platform/Edition/OroCommerceCommunityEditionRepository.php +++ b/src/Domain/Packaging/Platform/Edition/OroCommerceCommunityEditionRepository.php @@ -6,6 +6,18 @@ final class OroCommerceCommunityEditionRepository implements EditionRepositoryIn { public function getIterator() { + yield new EditionDependency( + 'orocommerce', + '1.6', + 'ce', + new Edition( + 'oroplatform', + '2.6', + 'ce', + '>=5.6 <7.2' + ) + ); + yield new EditionDependency( 'orocommerce', '3.1', @@ -14,7 +26,8 @@ public function getIterator() 'oroplatform', '3.1', 'ce', - '>=7.1 <8.1' + '>=7.1 <7.3', + '>=7.1 <=8.0', ) ); @@ -26,7 +39,8 @@ public function getIterator() 'oroplatform', '4.1', 'ce', - '>=7.3 <9.0' + '>=7.3 <8.0', + '>=7.3 <=8.0', ) ); } diff --git a/src/Domain/Packaging/Platform/Edition/OroCommerceEnterpriseEditionRepository.php b/src/Domain/Packaging/Platform/Edition/OroCommerceEnterpriseEditionRepository.php index bdec2b2..1c845a7 100644 --- a/src/Domain/Packaging/Platform/Edition/OroCommerceEnterpriseEditionRepository.php +++ b/src/Domain/Packaging/Platform/Edition/OroCommerceEnterpriseEditionRepository.php @@ -6,6 +6,18 @@ final class OroCommerceEnterpriseEditionRepository implements EditionRepositoryI { public function getIterator() { + yield new EditionDependency( + 'orocommerce', + '1.6', + 'ee', + new Edition( + 'orocommerce', + '1.6', + 'ce', + '>=5.6 <7.2' + ) + ); + yield new EditionDependency( 'orocommerce', '3.1', @@ -14,7 +26,8 @@ public function getIterator() 'orocommerce', '3.1', 'ce', - '>=7.1 <8.1' + '>=7.1 <7.3', + '>=7.1 <=8.0', ) ); @@ -26,7 +39,8 @@ public function getIterator() 'orocommerce', '4.1', 'ce', - '>=7.3 <9.0' + '>=7.3 <8.0', + '>=7.3 <=8.0', ) ); } diff --git a/src/Domain/Packaging/Platform/Edition/OroPlatformCommunityEditionRepository.php b/src/Domain/Packaging/Platform/Edition/OroPlatformCommunityEditionRepository.php index a5900ab..854e3fd 100644 --- a/src/Domain/Packaging/Platform/Edition/OroPlatformCommunityEditionRepository.php +++ b/src/Domain/Packaging/Platform/Edition/OroPlatformCommunityEditionRepository.php @@ -31,14 +31,16 @@ public function getIterator() 'oroplatform', '3.1', 'ce', - '>=7.1 <8.1' + '>=7.1 <7.3', + '>=7.1 <=8.0', ); yield new Edition( 'oroplatform', '4.1', 'ce', - '>=7.3 <9.0' + '>=7.3 <8.0', + '>=7.3 <=8.0', ); } } \ No newline at end of file diff --git a/src/Domain/Packaging/Platform/Edition/OroPlatformEnterpriseEditionRepository.php b/src/Domain/Packaging/Platform/Edition/OroPlatformEnterpriseEditionRepository.php index 9456c82..df75d0f 100644 --- a/src/Domain/Packaging/Platform/Edition/OroPlatformEnterpriseEditionRepository.php +++ b/src/Domain/Packaging/Platform/Edition/OroPlatformEnterpriseEditionRepository.php @@ -38,7 +38,8 @@ public function getIterator() 'oroplatform', '3.1', 'ce', - '>=7.1 <8.1' + '>=7.1 <7.3', + '>=7.1 <=8.0' ) ); @@ -50,7 +51,8 @@ public function getIterator() 'oroplatform', '4.1', 'ce', - '>=7.3 <9.0' + '>=7.3 <8.0', + '>=7.3 <=8.0' ) ); } diff --git a/src/Domain/Packaging/Platform/Package.php b/src/Domain/Packaging/Platform/Package.php index 0c0e47f..a5bb8ad 100644 --- a/src/Domain/Packaging/Platform/Package.php +++ b/src/Domain/Packaging/Platform/Package.php @@ -14,6 +14,7 @@ final class Package implements \IteratorAggregate, Packaging\PackageInterface, P private Native\Flavor\FlavorRepositoryInterface $flavors; private Native\Variation\PackageVariationInterface $variations; private Edition\EditionRepositoryInterface $editions; + private bool $withExperimental; public function __construct( Packaging\RepositoryInterface $repository, @@ -21,7 +22,8 @@ public function __construct( Packaging\Placeholder $path, Native\Flavor\FlavorRepositoryInterface $flavors, Native\Variation\PackageVariationInterface $variations, - Edition\EditionRepositoryInterface $editions + Edition\EditionRepositoryInterface $editions, + bool $withExperimental = false ) { $this->repository = $repository; $this->number = $number; @@ -29,6 +31,7 @@ public function __construct( $this->flavors = $flavors; $this->variations = $variations; $this->editions = $editions; + $this->withExperimental = $withExperimental; } public function __invoke(): \Traversable @@ -37,7 +40,9 @@ public function __invoke(): \Traversable foreach ($this->variations as $variation) { /** @var Packaging\Platform\Edition\Edition $edition */ foreach ($this->editions as $edition) { - if (!Semver::satisfies($this->number, $edition->getPhpConstraint())) { + if ((!$this->withExperimental && !Semver::satisfies($this->number, $edition->getPhpConstraint())) + || ($this->withExperimental && !Semver::satisfies($this->number, $edition->getPhpExperimentalConstraint())) + ) { continue; } @@ -85,35 +90,43 @@ public function getIterator() } } - public function pull(Packaging\CommandBus\CommandBusInterface $commands): void + public function pull(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { /** @var Packaging\Tag\TagBuildInterface $tag */ foreach ($this as $tag) { - $tag->pull($commands); + $tag->pull($task); } + + return $task; } - public function push(Packaging\CommandBus\CommandBusInterface $commands): void + public function push(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { /** @var Packaging\Tag\TagBuildInterface $tag */ foreach ($this as $tag) { - $tag->push($commands); + $tag->push($task); } + + return $task; } - public function build(Packaging\CommandBus\CommandBusInterface $commands): void + public function build(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { /** @var Packaging\Tag\TagBuildInterface $tag */ foreach ($this as $tag) { - $tag->build($commands); + $tag->build($task); } + + return $task; } - public function forceBuild(Packaging\CommandBus\CommandBusInterface $commands): void + public function forceBuild(Packaging\Execution\CommandBus\Task $task): Packaging\Execution\CommandBus\Task { /** @var Packaging\Tag\TagBuildInterface $tag */ foreach ($this as $tag) { - $tag->forceBuild($commands); + $tag->forceBuild($task); } + + return $task; } } \ No newline at end of file diff --git a/src/Domain/Packaging/Platform/Tag.php b/src/Domain/Packaging/Platform/Tag.php index 45240fd..0cc9cf5 100644 --- a/src/Domain/Packaging/Platform/Tag.php +++ b/src/Domain/Packaging/Platform/Tag.php @@ -42,23 +42,23 @@ public function getRepository(): Packaging\RepositoryInterface return $this->repository; } - public function pull(Packaging\CommandBus\CommandBusInterface $commands): void + public function pull(Packaging\Execution\CommandBus\Task $commands): Packaging\Execution\CommandBus\Task { - $commands->add(new Packaging\Command\Pull($this)); + return $commands->then(new Packaging\Execution\Command\Pull($this)); } - public function push(Packaging\CommandBus\CommandBusInterface $commands): void + public function push(Packaging\Execution\CommandBus\Task $commands): Packaging\Execution\CommandBus\Task { - $commands->add(new Packaging\Command\Push($this)); + return $commands->then(new Packaging\Execution\Command\Push($this)); } - public function build(Packaging\CommandBus\CommandBusInterface $commands): void + public function build(Packaging\Execution\CommandBus\Task $commands): Packaging\Execution\CommandBus\Task { - $commands->add(new Packaging\Command\BuildFrom($this, $this->from, $this->context)); + return $commands->then(new Packaging\Execution\Command\BuildFrom($this, $this->from, $this->context)); } - public function forceBuild(Packaging\CommandBus\CommandBusInterface $commands): void + public function forceBuild(Packaging\Execution\CommandBus\Task $commands): Packaging\Execution\CommandBus\Task { - $commands->add(new Packaging\Command\ForceBuildFrom($this, $this->from, $this->context)); + return $commands->then(new Packaging\Execution\Command\ForceBuildFrom($this, $this->from, $this->context)); } } \ No newline at end of file diff --git a/src/Domain/Stack/DTO/Context.php b/src/Domain/Stack/DTO/Context.php index c6ded10..bcbc74d 100644 --- a/src/Domain/Stack/DTO/Context.php +++ b/src/Domain/Stack/DTO/Context.php @@ -17,8 +17,8 @@ final class Context public function __construct( string $phpVersion, - ?string $application, - ?string $applicationVersion, + ?string $application = null, + ?string $applicationVersion = null, ?string $dbms = self::DBMS_POSTGRESQL, ?bool $withBlackfire = null, ?bool $withXdebug = null, @@ -45,7 +45,7 @@ public function getImagesRegex(): string $variations = ''; } - if (empty($this->application)) { + if (empty($this->application) || empty($this->applicationVersion)) { if (empty($this->dbms)) { return sprintf( '/^%s-(?:cli|fpm)%s$/', diff --git a/src/Platform/Console/Command/Images/BuildCommand.php b/src/Platform/Console/Command/Images/BuildCommand.php index 21ec13f..7d2b92f 100644 --- a/src/Platform/Console/Command/Images/BuildCommand.php +++ b/src/Platform/Console/Command/Images/BuildCommand.php @@ -18,12 +18,14 @@ final class BuildCommand extends Command private string $configPath; private string $environmentsPath; + private ContextWizard $wizard; public function __construct(?string $name, string $configPath, string $environmentsPath) { - parent::__construct($name); $this->configPath = $configPath; $this->environmentsPath = $environmentsPath; + $this->wizard = new ContextWizard(); + parent::__construct($name); } protected function configure() @@ -34,28 +36,25 @@ protected function configure() $this->addOption('force', 'f', InputOption::VALUE_NONE, 'Force the build for matching images only.'); $this->addOption('force-all', 'a', InputOption::VALUE_NONE, 'Force the build for all matching images and dependencies.'); - $this->addOption('parallel', 'P', InputOption::VALUE_OPTIONAL, '[EXPERIMENTAL] Run the build commands in parallel', 'no'); + $this->addOption('parallel', 'P', InputOption::VALUE_OPTIONAL, '[EXPERIMENTAL] Run the Docker commands in parallel', 'no'); $this->addOption('push', 'p', InputOption::VALUE_NONE, 'Push images to Docker Hub (requires authentication).'); - $this->addOption('working-directory', 'd', InputOption::VALUE_OPTIONAL); + $this->addOption('with-experimental', 'E', InputOption::VALUE_NONE, 'Enable Experimental images and PHP versions.'); + + $this->wizard->configureConsoleCommand($this); } protected function execute(InputInterface $input, OutputInterface $output) { - $workingDirectory = $input->getOption('working-directory') ?: getcwd(); - if (empty($pattern = $input->getOption('regex'))) { - $pattern = (new ContextWizard($workingDirectory))($input, $output)->getImagesRegex(); + $pattern = ($this->wizard)($input, $output)->getImagesRegex(); } $format = new SymfonyStyle($input, $output); $format->note(sprintf('Building all images matching the following pattern: %s', $pattern)); - /** @var Packaging\PackageInterface[] $packages */ - $packages = new \CachingIterator(new \ArrayIterator(array_merge( - require $this->configPath.'/builds.php', - )), \CachingIterator::FULL_CACHE); + $packages = Packaging\Config\Config::builds($this->configPath, (bool) $input->getOption('with-experimental')); $format->table(['tag', 'parent', 'path'], iterator_to_array((function () use ($pattern, $packages) { /** @var Packaging\PackageInterface $package */ @@ -94,9 +93,10 @@ protected function execute(InputInterface $input, OutputInterface $output) $force = ((bool) $input->getOption('force')) ?? false; $forceAll = ((bool) $input->getOption('force-all')) ?? false; - $commandBus = new Packaging\CommandBus\CommandBus(); + $commandBus = new Packaging\Execution\CommandBus\CommandBus(); /** @var Packaging\DependencyTree\NodeInterface $node */ foreach ($tree->resolve(...$nodes) as $node) { + $task = $commandBus->task(); if ($force && preg_match($pattern, (string) $node) > 0 || $forceAll) { if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) { $format->writeln(strtr('Found %tagName%, at path %path% (force build).', ['%tagName%' => (string) $node, '%path%' => $node->getPath()])); @@ -104,7 +104,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $format->writeln(strtr('Found %tagName% (force build).', ['%tagName%' => (string) $node])); } - $node->forceBuild($commandBus); + $node->forceBuild($task); } else { if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) { $format->writeln(strtr('Found %tagName%, at path %path%.', ['%tagName%' => (string) $node, '%path%' => $node->getPath()])); @@ -112,20 +112,20 @@ protected function execute(InputInterface $input, OutputInterface $output) $format->writeln(strtr('Found %tagName%.', ['%tagName%' => (string) $node])); } - $node->build($commandBus); + $node->build($task); } if ($input->getOption('push')) { - $node->push($commandBus); + $node->push($task); } } - if ('no' === $input->getOption('parallel') || 1 === (int) $input->getOption('parallel')) { - (new Packaging\CommandBus\SequentialCommandRunner($input, $output))->run($commandBus, $this->environmentsPath); - } else { - $parallel = (int) $input->getOption('parallel'); - (new Packaging\CommandBus\ParallelCommandRunner($input, $output, $parallel > 0 ? $parallel : 12))->run($commandBus, $this->environmentsPath); - } +// if ('no' === $input->getOption('parallel') || 1 === (int) $input->getOption('parallel')) { + (new Packaging\Execution\CommandBus\SequentialCommandRunner($input, $output))->run($commandBus, $this->environmentsPath); +// } else { +// $parallel = (int) $input->getOption('parallel'); +// (new Packaging\Execution\CommandBus\ParallelCommandRunner($input, $output, $parallel > 0 ? $parallel : 12))->run($commandBus, $this->environmentsPath); +// } return 0; } diff --git a/src/Platform/Console/Command/Images/ListCommand.php b/src/Platform/Console/Command/Images/ListCommand.php index f4fcea4..1f33d6b 100644 --- a/src/Platform/Console/Command/Images/ListCommand.php +++ b/src/Platform/Console/Command/Images/ListCommand.php @@ -17,11 +17,13 @@ final class ListCommand extends Command public static $defaultName = 'images:list'; private string $configPath; + private ContextWizard $wizard; public function __construct(?string $name, string $configPath) { - parent::__construct($name); $this->configPath = $configPath; + $this->wizard = new ContextWizard(); + parent::__construct($name); } protected function configure() @@ -30,23 +32,20 @@ protected function configure() $this->addOption('regex', 'x', InputOption::VALUE_REQUIRED); - $this->addOption('working-directory', 'd', InputOption::VALUE_OPTIONAL); + $this->addOption('with-experimental', 'E', InputOption::VALUE_NONE, 'Enable Experimental images and PHP versions.'); + + $this->wizard->configureConsoleCommand($this); } protected function execute(InputInterface $input, OutputInterface $output) { - $workingDirectory = $input->getOption('working-directory') ?: getcwd(); - if (empty($pattern = $input->getOption('regex'))) { - $pattern = (new ContextWizard($workingDirectory))($input, $output)->getImagesRegex(); + $pattern = ($this->wizard)($input, $output)->getImagesRegex(); } $format = new SymfonyStyle($input, $output); - /** @var Packaging\PackageInterface[] $packages */ - $packages = new \CachingIterator(new \ArrayIterator(array_merge( - require $this->configPath.'/builds.php', - )), \CachingIterator::FULL_CACHE); + $packages = Packaging\Config\Config::builds($this->configPath, (bool) $input->getOption('with-experimental')); $format->table(['tag', 'parent', 'path'], iterator_to_array((function () use ($pattern, $packages) { /** @var Packaging\PackageInterface $package */ diff --git a/src/Platform/Console/Command/Images/PullCommand.php b/src/Platform/Console/Command/Images/PullCommand.php index cb610fd..8a7c930 100644 --- a/src/Platform/Console/Command/Images/PullCommand.php +++ b/src/Platform/Console/Command/Images/PullCommand.php @@ -18,12 +18,14 @@ final class PullCommand extends Command private string $configPath; private string $environmentsPath; + private ContextWizard $wizard; public function __construct(?string $name, string $configPath, string $environmentsPath) { - parent::__construct($name); $this->configPath = $configPath; $this->environmentsPath = $environmentsPath; + $this->wizard = new ContextWizard(); + parent::__construct($name); } protected function configure() @@ -32,27 +34,24 @@ protected function configure() $this->addOption('regex', 'x', InputOption::VALUE_REQUIRED); - $this->addOption('parallel', 'P', InputOption::VALUE_OPTIONAL, '[EXPERIMENTAL] Run the build commands in parallel', 'no'); + $this->addOption('parallel', 'P', InputOption::VALUE_OPTIONAL, '[DEPRECATED] Run the Docker commands in parallel', 'no'); + + $this->addOption('with-experimental', 'E', InputOption::VALUE_NONE, 'Enable Experimental images and PHP versions.'); - $this->addOption('working-directory', 'd', InputOption::VALUE_OPTIONAL); + $this->wizard->configureConsoleCommand($this); } protected function execute(InputInterface $input, OutputInterface $output) { - $workingDirectory = $input->getOption('working-directory') ?: getcwd(); - if (empty($pattern = $input->getOption('regex'))) { - $pattern = (new ContextWizard($workingDirectory))($input, $output)->getImagesRegex(); + $pattern = ($this->wizard)($input, $output)->getImagesRegex(); } $format = new SymfonyStyle($input, $output); $format->note(sprintf('Pulling all images matching the following pattern: %s', $pattern)); - /** @var Packaging\PackageInterface[] $packages */ - $packages = new \CachingIterator(new \ArrayIterator(array_merge( - require $this->configPath.'/builds.php', - )), \CachingIterator::FULL_CACHE); + $packages = Packaging\Config\Config::builds($this->configPath, (bool) $input->getOption('with-experimental')); $format->table(['tag', 'parent', 'path'], iterator_to_array((function () use ($pattern, $packages) { /** @var Packaging\PackageInterface $package */ @@ -88,22 +87,22 @@ protected function execute(InputInterface $input, OutputInterface $output) }); } - $commandBus = new Packaging\CommandBus\CommandBus(); + $commandBus = new Packaging\Execution\CommandBus\CommandBus(); /** @var Packaging\DependencyTree\NodeInterface $node */ foreach ($tree->resolve(...$nodes) as $node) { if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $format->writeln(strtr('Found %tagName%.', ['%tagName%' => (string) $node])); } - $node->pull($commandBus); + $node->pull($commandBus->task()); } - if ('no' === $input->getOption('parallel') || 1 === (int) $input->getOption('parallel')) { - (new Packaging\CommandBus\SequentialCommandRunner($input, $output))->run($commandBus, $this->environmentsPath); - } else { - $parallel = (int) $input->getOption('parallel'); - (new Packaging\CommandBus\ParallelCommandRunner($input, $output, $parallel > 0 ? $parallel : 12))->run($commandBus, $this->environmentsPath); - } +// if ('no' === $input->getOption('parallel') || 1 === (int) $input->getOption('parallel')) { + (new Packaging\Execution\CommandBus\SequentialCommandRunner($input, $output))->run($commandBus, $this->environmentsPath); +// } else { +// $parallel = (int) $input->getOption('parallel'); +// (new Packaging\Execution\CommandBus\ParallelCommandRunner($input, $output, $parallel > 0 ? $parallel : 12))->run($commandBus, $this->environmentsPath); +// } return 0; } diff --git a/src/Platform/Console/Command/Images/PushCommand.php b/src/Platform/Console/Command/Images/PushCommand.php index b4ee9a4..75b851b 100644 --- a/src/Platform/Console/Command/Images/PushCommand.php +++ b/src/Platform/Console/Command/Images/PushCommand.php @@ -18,12 +18,14 @@ final class PushCommand extends Command private string $configPath; private string $environmentsPath; + private ContextWizard $wizard; public function __construct(?string $name, string $configPath, string $environmentsPath) { - parent::__construct($name); $this->configPath = $configPath; $this->environmentsPath = $environmentsPath; + $this->wizard = new ContextWizard(); + parent::__construct($name); } protected function configure() @@ -32,27 +34,24 @@ protected function configure() $this->addOption('regex', 'x', InputOption::VALUE_REQUIRED); - $this->addOption('parallel', 'P', InputOption::VALUE_OPTIONAL, '[EXPERIMENTAL] Run the build commands in parallel', 'no'); + $this->addOption('parallel', 'P', InputOption::VALUE_OPTIONAL, '[DEPRECATED] Run the Docker commands in parallel', 'no'); + + $this->addOption('with-experimental', 'E', InputOption::VALUE_NONE, 'Enable Experimental images and PHP versions.'); - $this->addOption('working-directory', 'd', InputOption::VALUE_OPTIONAL); + $this->wizard->configureConsoleCommand($this); } protected function execute(InputInterface $input, OutputInterface $output) { - $workingDirectory = $input->getOption('working-directory') ?: getcwd(); - if (empty($pattern = $input->getOption('regex'))) { - $pattern = (new ContextWizard($workingDirectory))($input, $output)->getImagesRegex(); + $pattern = ($this->wizard)($input, $output)->getImagesRegex(); } $format = new SymfonyStyle($input, $output); $format->note(sprintf('Pushing all images matching the following pattern: %s', $pattern)); - /** @var Packaging\PackageInterface[] $packages */ - $packages = new \CachingIterator(new \ArrayIterator(array_merge( - require $this->configPath.'/builds.php', - )), \CachingIterator::FULL_CACHE); + $packages = Packaging\Config\Config::builds($this->configPath, (bool) $input->getOption('with-experimental')); $format->table(['tag', 'parent', 'path'], iterator_to_array((function () use ($pattern, $packages) { /** @var Packaging\PackageInterface $package */ @@ -88,22 +87,22 @@ protected function execute(InputInterface $input, OutputInterface $output) }); } - $commandBus = new Packaging\CommandBus\CommandBus(); + $commandBus = new Packaging\Execution\CommandBus\CommandBus(); /** @var Packaging\DependencyTree\NodeInterface $node */ foreach ($tree->resolve(...$nodes) as $node) { if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { $format->writeln(strtr('Found %tagName%.', ['%tagName%' => (string) $node])); } - $node->push($commandBus); + $node->push($commandBus->task()); } - if ('no' === $input->getOption('parallel') || 1 === (int) $input->getOption('parallel')) { - (new Packaging\CommandBus\SequentialCommandRunner($input, $output))->run($commandBus, $this->environmentsPath); - } else { - $parallel = (int) $input->getOption('parallel'); - (new Packaging\CommandBus\ParallelCommandRunner($input, $output, $parallel > 0 ? $parallel : 12))->run($commandBus, $this->environmentsPath); - } +// if ('no' === $input->getOption('parallel') || 1 === (int) $input->getOption('parallel')) { + (new Packaging\Execution\CommandBus\SequentialCommandRunner($input, $output))->run($commandBus, $this->environmentsPath); +// } else { +// $parallel = (int) $input->getOption('parallel'); +// (new Packaging\Execution\CommandBus\ParallelCommandRunner($input, $output, $parallel > 0 ? $parallel : 12))->run($commandBus, $this->environmentsPath); +// } return 0; } diff --git a/src/Platform/Console/Command/Images/TestCommand.php b/src/Platform/Console/Command/Images/TestCommand.php index 01bc6e8..f593410 100644 --- a/src/Platform/Console/Command/Images/TestCommand.php +++ b/src/Platform/Console/Command/Images/TestCommand.php @@ -10,8 +10,8 @@ use Kiboko\Cloud\Domain\Assert\Result\AssertionSuccessInterface; use Kiboko\Cloud\Domain\Assert\Result\AssertionUnprocessableInterface; use Kiboko\Cloud\Domain\Assert\ResultBucket; -use Kiboko\Cloud\Platform\Console\ContextWizard; use Kiboko\Cloud\Domain\Packaging; +use Kiboko\Cloud\Platform\Console\ContextWizard; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -23,11 +23,13 @@ final class TestCommand extends Command public static $defaultName = 'images:test'; private string $configPath; + private ContextWizard $wizard; public function __construct(?string $name, string $configPath) { - parent::__construct($name); $this->configPath = $configPath; + $this->wizard = new ContextWizard(); + parent::__construct($name); } protected function configure() @@ -36,25 +38,22 @@ protected function configure() $this->addOption('regex', 'x', InputOption::VALUE_REQUIRED); - $this->addOption('working-directory', 'd', InputOption::VALUE_OPTIONAL); + $this->addOption('with-experimental', 'E', InputOption::VALUE_NONE, 'Enable Experimental images and PHP versions.'); + + $this->wizard->configureConsoleCommand($this); } protected function execute(InputInterface $input, OutputInterface $output) { - $workingDirectory = $input->getOption('working-directory') ?: getcwd(); - if (empty($pattern = $input->getOption('regex'))) { - $pattern = (new ContextWizard($workingDirectory))($input, $output)->getImagesRegex(); + $pattern = ($this->wizard)($input, $output)->getImagesRegex(); } $format = new SymfonyStyle($input, $output); $format->note(sprintf('Testing all images matching the following pattern: %s', $pattern)); - /** @var Packaging\PackageInterface[] $packages */ - $packages = new \CachingIterator(new \ArrayIterator(array_merge( - require $this->configPath.'/builds.php', - )), \CachingIterator::FULL_CACHE); + $packages = Packaging\Config\Config::builds($this->configPath, (bool) $input->getOption('with-experimental')); $format->table(['tag', 'parent', 'path'], iterator_to_array((function () use ($pattern, $packages) { /** @var Packaging\PackageInterface $package */ diff --git a/src/Platform/Console/Command/Images/TreeCommand.php b/src/Platform/Console/Command/Images/TreeCommand.php index b8336c4..1ae49b3 100644 --- a/src/Platform/Console/Command/Images/TreeCommand.php +++ b/src/Platform/Console/Command/Images/TreeCommand.php @@ -1,4 +1,6 @@ -configPath = $configPath; + $this->wizard = new ContextWizard(); + parent::__construct($name); } protected function configure() @@ -28,21 +32,19 @@ protected function configure() $this->addOption('regex', 'x', InputOption::VALUE_REQUIRED); - $this->addOption('working-directory', 'd', InputOption::VALUE_OPTIONAL); + $this->addOption('with-experimental', 'E', InputOption::VALUE_NONE, 'Enable Experimental images and PHP versions.'); + + $this->wizard->configureConsoleCommand($this); } protected function execute(InputInterface $input, OutputInterface $output) { - $workingDirectory = $input->getOption('working-directory') ?: getcwd(); - if (empty($pattern = $input->getOption('regex'))) { - $pattern = (new ContextWizard($workingDirectory))($input, $output)->getImagesRegex(); + $pattern = ($this->wizard)($input, $output)->getImagesRegex(); } - /** @var Packaging\PackageInterface[] $packages */ - $packages = new \CachingIterator(new \ArrayIterator(array_merge( - require $this->configPath.'/builds.php', - )), \CachingIterator::FULL_CACHE); + $packages = Packaging\Config\Config::builds($this->configPath, (bool) $input->getOption('with-experimental')); + $format = new SymfonyStyle($input, $output); $builder = new Packaging\DependencyTree\TreeBuilder(); diff --git a/src/Platform/Console/Command/Stack/InitCommand.php b/src/Platform/Console/Command/Stack/InitCommand.php index 32c2309..bdcf684 100644 --- a/src/Platform/Console/Command/Stack/InitCommand.php +++ b/src/Platform/Console/Command/Stack/InitCommand.php @@ -2,7 +2,6 @@ namespace Kiboko\Cloud\Platform\Console\Command\Stack; -use Kiboko\Cloud\Domain\Stack\DTO\Context; use Kiboko\Cloud\Domain\Stack\OroPlatform; use Kiboko\Cloud\Domain\Stack\StackBuilder; use Kiboko\Cloud\Platform\Console\ContextWizard; @@ -18,19 +17,21 @@ final class InitCommand extends Command private string $configPath; private string $stacksPath; + private ContextWizard $wizard; public function __construct(?string $name, string $configPath, string $stacksPath) { - parent::__construct($name); $this->configPath = $configPath; $this->stacksPath = $stacksPath; + $this->wizard = new ContextWizard(); + parent::__construct($name); } protected function configure() { $this->setDescription('Initialize the Docker stack in a project without Docker stack'); - $this->addOption('working-directory', 'd', InputOption::VALUE_OPTIONAL); + $this->wizard->configureConsoleCommand($this); } protected function execute(InputInterface $input, OutputInterface $output) @@ -44,7 +45,7 @@ protected function execute(InputInterface $input, OutputInterface $output) return 0; } - $context = (new ContextWizard($workingDirectory))($input, $output); + $context = ($this->wizard)($input, $output, $workingDirectory); $builder = new StackBuilder( new OroPlatform\Builder($this->stacksPath), diff --git a/src/Platform/Console/Command/Stack/UpgradeCommand.php b/src/Platform/Console/Command/Stack/UpgradeCommand.php index 0c32b9b..9b8a04b 100644 --- a/src/Platform/Console/Command/Stack/UpgradeCommand.php +++ b/src/Platform/Console/Command/Stack/UpgradeCommand.php @@ -25,19 +25,21 @@ final class UpgradeCommand extends Command private string $configPath; private string $stacksPath; + private ContextWizard $wizard; public function __construct(?string $name, string $configPath, string $stacksPath) { - parent::__construct($name); $this->configPath = $configPath; $this->stacksPath = $stacksPath; + $this->wizard = new ContextWizard(); + parent::__construct($name); } protected function configure() { $this->setDescription('Initialize the Docker stack in a project without Docker stack'); - $this->addOption('working-directory', 'd', InputOption::VALUE_OPTIONAL); + $this->wizard->configureConsoleCommand($this); } protected function execute(InputInterface $input, OutputInterface $output) @@ -75,7 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } if (empty($context)) { - $context = (new ContextWizard($workingDirectory))($input, $output); + $context = ($this->wizard)($input, $output, $workingDirectory); $format->note('Writing a new .kloud.yaml file.'); file_put_contents($workingDirectory . '/.kloud.yaml', $serializer->serialize($context, 'yaml')); diff --git a/src/Platform/Console/ContextWizard.php b/src/Platform/Console/ContextWizard.php index 4f4c78e..93fda17 100644 --- a/src/Platform/Console/ContextWizard.php +++ b/src/Platform/Console/ContextWizard.php @@ -5,211 +5,100 @@ namespace Kiboko\Cloud\Platform\Console; use Kiboko\Cloud\Domain\Stack; -use Kiboko\Cloud\Platform\Context\ContextGuesser; -use Kiboko\Cloud\Platform\Context\Guesser; -use Kiboko\Cloud\Platform\Context\NoPossibleGuess; -use Composer\Semver\Semver; +use Kiboko\Cloud\Platform\Context\ComposerPackageGuesser; +use Kiboko\Cloud\Platform\Context\ContextGuesserFacade; +use Kiboko\Cloud\Platform\Context\ContextGuesserInterface; +use Kiboko\Cloud\Platform\Context\PHPVersionConsoleGuesser; +use Kiboko\Cloud\Platform\Context\PHPVersionConsoleOptionGuesser; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Finder\SplFileInfo; final class ContextWizard { - private ?string $cwd; + private ContextGuesserInterface $guesser; - public function __construct(?string $cwd = null) + public function __construct() { - $this->cwd = $cwd; + $this->guesser = new ContextGuesserFacade( + new ComposerPackageGuesser( + new ComposerPackageGuesser\OroCommerceEnterprise('oro/commerce-enterprise'), + new ComposerPackageGuesser\OroCommerceCommunity('oro/commerce'), + new ComposerPackageGuesser\OroCRMEnterprise('oro/crm-enterprise'), + new ComposerPackageGuesser\OroCRMCommunity('oro/crm'), + new ComposerPackageGuesser\MarelloEnterprise('marellocommerce/marello-enterprise'), + new ComposerPackageGuesser\MarelloCommunity('marellocommerce/marello'), + new ComposerPackageGuesser\MiddlewareCommunity('kiboko/middleware'), + new ComposerPackageGuesser\OroPlatformEnterprise('oro/platform-enterprise'), + new ComposerPackageGuesser\OroPlatformCommunity('oro/platform'), + ), + new PHPVersionConsoleOptionGuesser( + new PHPVersionConsoleGuesser\OroPlatform(), + new PHPVersionConsoleGuesser\OroCRM(), + new PHPVersionConsoleGuesser\OroCommerce(), + new PHPVersionConsoleGuesser\Marello(), + new PHPVersionConsoleGuesser\Middleware(), + ), + ); } - private function buildFromComposer(SymfonyStyle $format): ?Stack\DTO\Context + public function configureConsoleCommand(Command $command) { - $finder = (new Finder()) - ->in($this->cwd) - ->files() - ->name('composer.lock'); - - if ($finder->hasResults()) { - /** @var SplFileInfo $file */ - foreach ($finder as $file) { - $json = \json_decode($file->getContents(), true); - break; - } - - $guesser = new ContextGuesser( - new Guesser\OroCommerceEnterprise('oro/commerce-enterprise'), - new Guesser\OroCommerceCommunity('oro/commerce'), - new Guesser\OroCRMEnterprise('oro/crm-enterprise'), - new Guesser\OroCRMCommunity('oro/crm'), - new Guesser\MarelloEnterprise('marellocommerce/marello-enterprise'), - new Guesser\MarelloCommunity('marellocommerce/marello'), - new Guesser\OroPlatformEnterprise('oro/platform-enterprise'), - new Guesser\OroPlatformCommunity('oro/platform'), - ); - - try { - $context = $guesser->guess($json['packages'] ?? []); - - if ($context->application === 'orocommerce' && $context->isEnterpriseEdition) { - $format->writeln(strtr('Found OroCommerce Enterprise Edition, version %version%.', ['%version%' => $context->applicationVersion])); - } else if ($context->application === 'orocommerce' && !$context->isEnterpriseEdition) { - $format->writeln(strtr('Found OroCommerce Community Edition, version %version%.', ['%version%' => $context->applicationVersion])); - } else if ($context->application === 'orocrm' && $context->isEnterpriseEdition) { - $format->writeln(strtr('Found OroCRM Enterprise Edition, version %version%.', ['%version%' => $context->applicationVersion])); - } else if ($context->application === 'orocrm' && !$context->isEnterpriseEdition) { - $format->writeln(strtr('Found OroCRM Community Edition, version %version%.', ['%version%' => $context->applicationVersion])); - } else if ($context->application === 'marello' && $context->isEnterpriseEdition) { - $format->writeln(strtr('Found Marello Enterprise Edition, version %version%.', ['%version%' => $context->applicationVersion])); - } else if ($context->application === 'marello' && !$context->isEnterpriseEdition) { - $format->writeln(strtr('Found Marello Community Edition, version %version%.', ['%version%' => $context->applicationVersion])); - } else if ($context->application === 'oroplatform' && $context->isEnterpriseEdition) { - $format->writeln(strtr('Found OroPlatform Enterprise Edition, version %version%.', ['%version%' => $context->applicationVersion])); - } else if ($context->application === 'oroplatform' && !$context->isEnterpriseEdition) { - $format->writeln(strtr('Found OroPlatform Community Edition, version %version%.', ['%version%' => $context->applicationVersion])); - } - } catch (NoPossibleGuess $exception) { - $format->warning('Could not guess any known application type.'); - - return null; - } - - return $context; - } - - return null; + $this->guesser->configure($command); + + $command->addOption('mysql', null, InputOption::VALUE_NONE, 'Set up the application to use MySQL.'); + $command->addOption('postgresql', null, InputOption::VALUE_NONE, 'Set up the application to use PostgreSQL.'); + $command->addOption('with-xdebug', null, InputOption::VALUE_NONE, 'Set up the application to use Xdebug.'); + $command->addOption('without-xdebug', null, InputOption::VALUE_NONE, 'Set up the application without Xdebug.'); + $command->addOption('with-blackfire', null, InputOption::VALUE_NONE, 'Set up the application to use Blackfire.'); + $command->addOption('without-blackfire', null, InputOption::VALUE_NONE, 'Set up the application without Blackfire.'); } - private function buildInteractively(SymfonyStyle $format): ?Stack\DTO\Context + public function __invoke(InputInterface $input, OutputInterface $output): Stack\DTO\Context { - $context = new Stack\DTO\Context( - $format->askQuestion( - (new ChoiceQuestion('Which PHP version are you using?', ['5.6', '7.1', '7.2', '7.3', '7.4', '8.0'], '7.2')) - ), - $format->askQuestion( - (new ChoiceQuestion('Which application are you using? (leave empty for native image)', ['orocommerce', 'oroplatform', 'orocrm', 'marello', ''], '')) - ), - null, - null - ); + $context = $this->guesser->guess($input, $output, null); - $context->applicationVersion = ''; - if ('orocommerce' === $context->application) { - if (Semver::satisfies($context->phpVersion, '>=5.6 <7.2')) { - $format->writeln(' Choosing automaticallly OroCommerce version 1.6.'); - $context->applicationVersion = '1.6'; - } else if (Semver::satisfies($context->phpVersion, '>=7.1 <7.3')) { - $context->applicationVersion = $format->askQuestion( - (new ChoiceQuestion('Which OroCommerce version are you using?', ['1.6', '3.1'], '3.1')) - ); - } else if (Semver::satisfies($context->phpVersion, '>=7.2 <7.4')) { - $context->applicationVersion = $format->askQuestion( - (new ChoiceQuestion('Which OroCommerce version are you using?', ['3.1', '4.1'], '3.1')) - ); - } else if (Semver::satisfies($context->phpVersion, '>=7.4')) { - $format->writeln(' Choosing automaticallly OroCommerce version 4.1.'); - $context->applicationVersion = '4.1'; - } - } elseif ('oroplatform' === $context->application) { - if (Semver::satisfies($context->phpVersion, '>=5.6 <7.2')) { - $context->applicationVersion = $format->askQuestion( - (new ChoiceQuestion('Which OroPlatform version are you using?', ['1.8', '2.6'], '2.6')) - ); - } else if (Semver::satisfies($context->phpVersion, '>=7.1 <7.3')) { - $context->applicationVersion = $format->askQuestion( - (new ChoiceQuestion('Which OroPlatform version are you using?', ['2.6', '3.1'], '3.1')) - ); - } else if (Semver::satisfies($context->phpVersion, '>=7.2 <7.4')) { - $context->applicationVersion = $format->askQuestion( - (new ChoiceQuestion('Which OroPlatform version are you using?', ['3.1', '4.1'], '3.1')) - ); - } else if (Semver::satisfies($context->phpVersion, '>=7.4')) { - $format->writeln(' Choosing automaticallly OroPlatform version 4.1.'); - $context->applicationVersion = '4.1'; - } - } elseif ('orocrm' === $context->application) { - if (Semver::satisfies($context->phpVersion, '>=5.6 <7.2')) { - $context->applicationVersion = $format->askQuestion( - (new ChoiceQuestion('Which OroPlatform version are you using?', ['1.8', '2.6'], '2.6')) - ); - } else if (Semver::satisfies($context->phpVersion, '>=7.1 <7.3')) { - $context->applicationVersion = $format->askQuestion( - (new ChoiceQuestion('Which OroCRM version are you using?', ['2.6', '3.1'], '3.1')) - ); - } else if (Semver::satisfies($context->phpVersion, '>=7.2 <7.4')) { - $context->applicationVersion = $format->askQuestion( - (new ChoiceQuestion('Which OroCRM version are you using?', ['3.1', '4.1'], '3.1')) - ); - } else if (Semver::satisfies($context->phpVersion, '>=7.4')) { - $format->writeln(' Choosing automaticallly OroCRM version 4.1.'); - $context->applicationVersion = '4.1'; - } - } elseif ('marello' === $context->application) { - if (Semver::satisfies($context->phpVersion, '>=5.6 <7.2')) { - $context->applicationVersion = $format->askQuestion( - (new ChoiceQuestion('Which Marello version are you using?', ['1.5', '1.6'], '1.6')) - ); - } else if (Semver::satisfies($context->phpVersion, '>=7.1 <7.3')) { - $context->applicationVersion = $format->askQuestion( - (new ChoiceQuestion('Which Marello version are you using?', ['1.5', '1.6', '2.0', '2.1', '2.2'], '2.2')) + $format = new SymfonyStyle($input, $output); + + if ($input->getOption('enterprise') === $input->getOption('community')) { + if (!empty($context->application)) { + $context->dbms = $format->askQuestion( + (new ChoiceQuestion( + 'Which database engine are you using?', + ['mysql', 'postgresql'], + $context->dbms ?? $context->isEnterpriseEdition ? 'postgresql' : 'mysql' + )) ); - } else if (Semver::satisfies($context->phpVersion, '>=7.2 <7.4')) { - $context->applicationVersion = $format->askQuestion( - (new ChoiceQuestion('Which Marello version are you using?', ['2.0', '2.1', '2.2', '3.0'], '2.2')) + } else { + $context->dbms = $format->askQuestion( + (new ChoiceQuestion('Which database engine are you using? (leave empty for none)', ['mysql', 'postgresql', ''], '')) ); - } elseif (Semver::satisfies($context->phpVersion, '>=7.4')) { - $format->writeln(' Choosing automaticallly Marello version 3.0.'); - $context->applicationVersion = '3.0'; } } - $context->isEnterpriseEdition = false; - if (!empty($context->application)) { - $context->isEnterpriseEdition = $format->askQuestion( - (new ConfirmationQuestion('Is it for Enterprise Edition?', false)) + if ($input->getOption('with-blackfire')) { + $context->withBlackfire = true; + } else if ($input->getOption('without-blackfire')) { + $context->withBlackfire = false; + } else { + $context->withBlackfire = $format->askQuestion( + (new ConfirmationQuestion('Include Blackfire?', $context->withBlackfire ?? false)) ); } - - return $context; - } - - public function __invoke(InputInterface $input, OutputInterface $output): Stack\DTO\Context - { - $format = new SymfonyStyle($input, $output); - - $context = null; - if ($this->cwd !== null) { - $context = $this->buildFromComposer($format); - } - - if ($context === null) { - $context = $this->buildInteractively($format); - } - - if (!empty($context->application)) { - $context->dbms = $format->askQuestion( - (new ChoiceQuestion( - 'Which database engine are you using?', - ['mysql', 'postgresql'], - $context->dbms ?? $context->isEnterpriseEdition ? 'postgresql' : 'mysql' - )) - ); + if ($input->getOption('with-xdebug')) { + $context->withXdebug = true; + } else if ($input->getOption('without-xdebug')) { + $context->withXdebug = false; } else { - $context->dbms = $format->askQuestion( - (new ChoiceQuestion('Which database engine are you using? (leave empty for none)', ['mysql', 'postgresql', ''], '')) + $context->withXdebug = $format->askQuestion( + (new ConfirmationQuestion('Include XDebug?', $context->withXdebug ?? false)) ); } - $context->withBlackfire = $format->askQuestion( - (new ConfirmationQuestion('Include Blackfire?', $context->withBlackfire ?? false)) - ); - $context->withXdebug = $format->askQuestion( - (new ConfirmationQuestion('Include XDebug?', $context->withXdebug ?? false)) - ); - $format->table( ['php', 'application', 'edition', 'version', 'database', 'blackfire', 'xdebug'], [[ diff --git a/src/Platform/Context/CallableContextGuesser.php b/src/Platform/Context/CallableContextGuesser.php deleted file mode 100644 index dd85aa6..0000000 --- a/src/Platform/Context/CallableContextGuesser.php +++ /dev/null @@ -1,27 +0,0 @@ -packageName = $packageName; - $this->callback = \Closure::fromCallable($callback); - } - - public function matches(array $package): bool - { - return $package['name'] === $this->packageName; - } - - public function guess(array $package): Stack\DTO\Context - { - return ($this->callback)($package); - } -} \ No newline at end of file diff --git a/src/Platform/Context/ComposerPackageGuesser.php b/src/Platform/Context/ComposerPackageGuesser.php new file mode 100644 index 0000000..50d2a5e --- /dev/null +++ b/src/Platform/Context/ComposerPackageGuesser.php @@ -0,0 +1,103 @@ +contextGuessers = $contextGuessers; + } + + public function configure(Command $command) + { + $command->addOption('working-directory', 'd', InputOption::VALUE_OPTIONAL, 'Change the working directory in which the stack will be guessed from and written.'); + } + + private function filterPackages(array $packages): array + { + return array_filter($packages, function (array $package) { + return array_reduce($this->contextGuessers, function (bool $carry, ComposerPackageDelegatedGuesserInterface $guesser) use ($package) { + return $carry || $guesser->matches($package); + }, false); + }); + } + + /** @throws NoPossibleGuess */ + public function guess(InputInterface $input, OutputInterface $output, ?Stack\DTO\Context $context = null): Stack\DTO\Context + { + $workingDirectory = $input->getOption('working-directory') ?: getcwd(); + + $finder = (new Finder()) + ->in($workingDirectory) + ->files() + ->name('composer.lock'); + + if (!$finder->hasResults()) { + throw NoPossibleGuess::packageIsNotMatchingAnyApplicationContext(); + } + + /** @var SplFileInfo $file */ + foreach ($finder as $file) { + $json = \json_decode($file->getContents(), true); + break; + } + + if (!isset($json)) { + throw NoPossibleGuess::packageIsNotMatchingAnyApplicationContext(); + } + + $packages = $this->filterPackages($json['packages']); + + $format = new SymfonyStyle($input, $output); + foreach ($this->contextGuessers as $guesser) { + try { + foreach ($packages as $package) { + if (!$guesser->matches($package)) { + continue; + } + + $context = $guesser->guess($package); + + if ($context->application === 'orocommerce' && $context->isEnterpriseEdition) { + $format->writeln(strtr('Found OroCommerce Enterprise Edition, version %version%.', ['%version%' => $context->applicationVersion])); + } else if ($context->application === 'orocommerce' && !$context->isEnterpriseEdition) { + $format->writeln(strtr('Found OroCommerce Community Edition, version %version%.', ['%version%' => $context->applicationVersion])); + } else if ($context->application === 'orocrm' && $context->isEnterpriseEdition) { + $format->writeln(strtr('Found OroCRM Enterprise Edition, version %version%.', ['%version%' => $context->applicationVersion])); + } else if ($context->application === 'orocrm' && !$context->isEnterpriseEdition) { + $format->writeln(strtr('Found OroCRM Community Edition, version %version%.', ['%version%' => $context->applicationVersion])); + } else if ($context->application === 'marello' && $context->isEnterpriseEdition) { + $format->writeln(strtr('Found Marello Enterprise Edition, version %version%.', ['%version%' => $context->applicationVersion])); + } else if ($context->application === 'marello' && !$context->isEnterpriseEdition) { + $format->writeln(strtr('Found Marello Community Edition, version %version%.', ['%version%' => $context->applicationVersion])); + } else if ($context->application === 'oroplatform' && $context->isEnterpriseEdition) { + $format->writeln(strtr('Found OroPlatform Enterprise Edition, version %version%.', ['%version%' => $context->applicationVersion])); + } else if ($context->application === 'oroplatform' && !$context->isEnterpriseEdition) { + $format->writeln(strtr('Found OroPlatform Community Edition, version %version%.', ['%version%' => $context->applicationVersion])); + } + + return $guesser->guess($package); + } + } catch (NoPossibleGuess $exception) { + $format->warning('Could not guess any known application type.'); + continue; + } + } + + throw NoPossibleGuess::packageIsNotMatchingAnyApplicationContext(); + } +} \ No newline at end of file diff --git a/src/Platform/Context/ComposerPackageGuesser/ComposerPackageDelegatedGuesserInterface.php b/src/Platform/Context/ComposerPackageGuesser/ComposerPackageDelegatedGuesserInterface.php new file mode 100644 index 0000000..5ed357e --- /dev/null +++ b/src/Platform/Context/ComposerPackageGuesser/ComposerPackageDelegatedGuesserInterface.php @@ -0,0 +1,11 @@ +packageName = $packageName; + } + + public function matches(array $package): bool + { + return $package['name'] === $this->packageName; + } + + public function guess(array $package): Stack\DTO\Context + { + if (Semver::satisfies($package['version'], '^1.0')) { + return new Stack\DTO\Context('7.4', 'middleware', '1.0', Stack\DTO\Context::DBMS_POSTGRESQL, true, true, false); + } + + throw NoPossibleGuess::noVersionMatching(); + } +} \ No newline at end of file diff --git a/src/Platform/Context/ComposerPackageGuesser/MiddlewareEnterprise.php b/src/Platform/Context/ComposerPackageGuesser/MiddlewareEnterprise.php new file mode 100644 index 0000000..19c9c50 --- /dev/null +++ b/src/Platform/Context/ComposerPackageGuesser/MiddlewareEnterprise.php @@ -0,0 +1,31 @@ +packageName = $packageName; + } + + public function matches(array $package): bool + { + return $package['name'] === $this->packageName; + } + + public function guess(array $package): Stack\DTO\Context + { + if (Semver::satisfies($package['version'], '^1.0')) { + return new Stack\DTO\Context('7.4', 'middleware', '1.0', Stack\DTO\Context::DBMS_POSTGRESQL, true, true, true); + } + + throw NoPossibleGuess::noVersionMatching(); + } +} \ No newline at end of file diff --git a/src/Platform/Context/Guesser/OroCRMCommunity.php b/src/Platform/Context/ComposerPackageGuesser/OroCRMCommunity.php similarity index 86% rename from src/Platform/Context/Guesser/OroCRMCommunity.php rename to src/Platform/Context/ComposerPackageGuesser/OroCRMCommunity.php index 5171cbc..fbe427f 100644 --- a/src/Platform/Context/Guesser/OroCRMCommunity.php +++ b/src/Platform/Context/ComposerPackageGuesser/OroCRMCommunity.php @@ -1,13 +1,12 @@ contextGuessers = $contextGuessers; - } - - private function filterPackages(array $packages): array - { - return array_filter($packages, function (array $package) { - return array_reduce($this->contextGuessers, function (bool $carry, ContextGuesserInterface $guesser) use ($package) { - return $carry || $guesser->matches($package); - }, false); - }); - } - - public function guess(array $packages): Stack\DTO\Context - { - $packages = $this->filterPackages($packages); - - foreach ($this->contextGuessers as $guesser) { - try { - foreach ($packages as $package) { - if (!$guesser->matches($package)) { - continue; - } - - return $guesser->guess($package); - } - } catch (NoPossibleGuess $exception) { - continue; - } - } - - throw NoPossibleGuess::packageIsNotMatchingAnyApplicationContext(); - } -} \ No newline at end of file diff --git a/src/Platform/Context/ContextGuesserFacade.php b/src/Platform/Context/ContextGuesserFacade.php new file mode 100644 index 0000000..ca7cd67 --- /dev/null +++ b/src/Platform/Context/ContextGuesserFacade.php @@ -0,0 +1,41 @@ +contextGuessers = $contextGuessers; + } + + public function guess(InputInterface $input, OutputInterface $output, ?Stack\DTO\Context $context = null): Stack\DTO\Context + { + foreach ($this->contextGuessers as $guesser) { + try { + return $guesser->guess($input, $output, $context); + } catch (NoPossibleGuess $exception) { + continue; + } + } + + throw NoPossibleGuess::noGuesserMatching(); + } + + public function configure(Command $command) + { + foreach ($this->contextGuessers as $contextGuesser) { + if ($contextGuesser instanceof ConsoleOptionContextGuesserInterface) { + $contextGuesser->configure($command); + } + } + } +} \ No newline at end of file diff --git a/src/Platform/Context/ContextGuesserInterface.php b/src/Platform/Context/ContextGuesserInterface.php index 99dbef1..fb78a09 100644 --- a/src/Platform/Context/ContextGuesserInterface.php +++ b/src/Platform/Context/ContextGuesserInterface.php @@ -2,9 +2,12 @@ namespace Kiboko\Cloud\Platform\Context; +use Kiboko\Cloud\Domain\Stack; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + interface ContextGuesserInterface { - public function matches(array $package): bool; - - public function guess(array $package); + /** @throws NoPossibleGuess */ + public function guess(InputInterface $input, OutputInterface $output, ?Stack\DTO\Context $context = null): Stack\DTO\Context; } \ No newline at end of file diff --git a/src/Platform/Context/NoPossibleGuess.php b/src/Platform/Context/NoPossibleGuess.php index 94d5ca6..ca33aaa 100644 --- a/src/Platform/Context/NoPossibleGuess.php +++ b/src/Platform/Context/NoPossibleGuess.php @@ -4,6 +4,11 @@ final class NoPossibleGuess extends \RuntimeException { + public static function noGuesserMatching() + { + return new self('No gessable context.'); + } + public static function noVersionMatching() { return new self('No gessable version matching for a new application context.'); diff --git a/src/Platform/Context/OroContextGuesser.php b/src/Platform/Context/OroContextGuesser.php deleted file mode 100644 index f91a144..0000000 --- a/src/Platform/Context/OroContextGuesser.php +++ /dev/null @@ -1,37 +0,0 @@ -packageName = $packageName; - } - - public function matches(): callable - { - return function(array $package): bool { - return $package['name'] === $this->packageName; - }; - } - - public function guess(array $packages): Stack\DTO\Context - { - foreach ($packages as $package) { - try { - $context = ($this->callback)($package); - } catch (NoPossibleGuess $exception) { - continue; - } - - return $context; - } - - throw NoPossibleGuess::noVersionMatching(); - } -} \ No newline at end of file diff --git a/src/Platform/Context/PHPVersionConsoleGuesser/Marello.php b/src/Platform/Context/PHPVersionConsoleGuesser/Marello.php new file mode 100644 index 0000000..9f35263 --- /dev/null +++ b/src/Platform/Context/PHPVersionConsoleGuesser/Marello.php @@ -0,0 +1,47 @@ +phpVersion, '>=5.6 <7.2')) { + $context->applicationVersion = $format->askQuestion( + (new ChoiceQuestion('Which Marello version are you using?', ['1.5', '1.6'], '1.6')) + ); + } else if (Semver::satisfies($context->phpVersion, '>=7.1 <7.3')) { + $context->applicationVersion = $format->askQuestion( + (new ChoiceQuestion('Which Marello version are you using?', ['1.5', '1.6', '2.0', '2.1', '2.2'], '2.2')) + ); + } else if (Semver::satisfies($context->phpVersion, '>=7.2 <7.4')) { + $context->applicationVersion = $format->askQuestion( + (new ChoiceQuestion('Which Marello version are you using?', ['2.0', '2.1', '2.2', '3.0'], '2.2')) + ); + } elseif (Semver::satisfies($context->phpVersion, '>=7.4')) { + $format->writeln(' Choosing automaticallly Marello version 3.0.'); + $context->applicationVersion = '3.0'; + } else { + throw NoPossibleGuess::noGuesserMatching(); + } + + return $context; + } +} \ No newline at end of file diff --git a/src/Platform/Context/PHPVersionConsoleGuesser/Middleware.php b/src/Platform/Context/PHPVersionConsoleGuesser/Middleware.php new file mode 100644 index 0000000..c7ae285 --- /dev/null +++ b/src/Platform/Context/PHPVersionConsoleGuesser/Middleware.php @@ -0,0 +1,35 @@ +phpVersion, '>=7.4')) { + $format->writeln(' Choosing automaticallly Middleware version 1.0.'); + $context->applicationVersion = '1.0'; + } else { + throw NoPossibleGuess::noGuesserMatching(); + } + + return $context; + } +} \ No newline at end of file diff --git a/src/Platform/Context/PHPVersionConsoleGuesser/OroCRM.php b/src/Platform/Context/PHPVersionConsoleGuesser/OroCRM.php new file mode 100644 index 0000000..9dfa7d2 --- /dev/null +++ b/src/Platform/Context/PHPVersionConsoleGuesser/OroCRM.php @@ -0,0 +1,47 @@ +phpVersion, '>=5.6 <7.2')) { + $context->applicationVersion = $format->askQuestion( + (new ChoiceQuestion('Which OroCRM version are you using?', ['1.8', '2.6'], '2.6')) + ); + } else if (Semver::satisfies($context->phpVersion, '>=7.1 <7.3')) { + $context->applicationVersion = $format->askQuestion( + (new ChoiceQuestion('Which OroCRM version are you using?', ['2.6', '3.1'], '3.1')) + ); + } else if (Semver::satisfies($context->phpVersion, '>=7.2 <7.4')) { + $context->applicationVersion = $format->askQuestion( + (new ChoiceQuestion('Which OroCRM version are you using?', ['3.1', '4.1'], '3.1')) + ); + } else if (Semver::satisfies($context->phpVersion, '>=7.4')) { + $format->writeln(' Choosing automaticallly OroCRM version 4.1.'); + $context->applicationVersion = '4.1'; + } else { + throw NoPossibleGuess::noGuesserMatching(); + } + + return $context; + } +} \ No newline at end of file diff --git a/src/Platform/Context/PHPVersionConsoleGuesser/OroCommerce.php b/src/Platform/Context/PHPVersionConsoleGuesser/OroCommerce.php new file mode 100644 index 0000000..52f75c4 --- /dev/null +++ b/src/Platform/Context/PHPVersionConsoleGuesser/OroCommerce.php @@ -0,0 +1,46 @@ +phpVersion, '>=5.6 <7.2')) { + $format->writeln(' Choosing automaticallly OroCommerce version 1.6.'); + $context->applicationVersion = '1.6'; + } else if (Semver::satisfies($context->phpVersion, '>=7.1 <7.3')) { + $context->applicationVersion = $format->askQuestion( + (new ChoiceQuestion('Which OroCommerce version are you using?', ['1.6', '3.1'], '3.1')) + ); + } else if (Semver::satisfies($context->phpVersion, '>=7.2 <7.4')) { + $context->applicationVersion = $format->askQuestion( + (new ChoiceQuestion('Which OroCommerce version are you using?', ['3.1', '4.1'], '3.1')) + ); + } else if (Semver::satisfies($context->phpVersion, '>=7.4')) { + $format->writeln(' Choosing automaticallly OroCommerce version 4.1.'); + $context->applicationVersion = '4.1'; + } else { + throw NoPossibleGuess::noGuesserMatching(); + } + + return $context; + } +} \ No newline at end of file diff --git a/src/Platform/Context/PHPVersionConsoleGuesser/OroPlatform.php b/src/Platform/Context/PHPVersionConsoleGuesser/OroPlatform.php new file mode 100644 index 0000000..89c1cbc --- /dev/null +++ b/src/Platform/Context/PHPVersionConsoleGuesser/OroPlatform.php @@ -0,0 +1,47 @@ +phpVersion, '>=5.6 <7.2')) { + $context->applicationVersion = $format->askQuestion( + (new ChoiceQuestion('Which OroPlatform version are you using?', ['1.8', '2.6'], '2.6')) + ); + } else if (Semver::satisfies($context->phpVersion, '>=7.1 <7.3')) { + $context->applicationVersion = $format->askQuestion( + (new ChoiceQuestion('Which OroPlatform version are you using?', ['2.6', '3.1'], '3.1')) + ); + } else if (Semver::satisfies($context->phpVersion, '>=7.2 <7.4')) { + $context->applicationVersion = $format->askQuestion( + (new ChoiceQuestion('Which OroPlatform version are you using?', ['3.1', '4.1'], '3.1')) + ); + } else if (Semver::satisfies($context->phpVersion, '>=7.4')) { + $format->writeln(' Choosing automaticallly OroPlatform version 4.1.'); + $context->applicationVersion = '4.1'; + } else { + throw NoPossibleGuess::noGuesserMatching(); + } + + return $context; + } +} \ No newline at end of file diff --git a/src/Platform/Context/PHPVersionConsoleGuesser/PHPVersionConsoleDelegatedGuesserInterface.php b/src/Platform/Context/PHPVersionConsoleGuesser/PHPVersionConsoleDelegatedGuesserInterface.php new file mode 100644 index 0000000..fd398f7 --- /dev/null +++ b/src/Platform/Context/PHPVersionConsoleGuesser/PHPVersionConsoleDelegatedGuesserInterface.php @@ -0,0 +1,13 @@ +contextGuessers = $contextGuessers; + } + + public function configure(Command $command) + { + $command->addOption('php-version', null, InputOption::VALUE_REQUIRED, 'Set up the required PHP version.'); + $command->addOption('application', null, InputOption::VALUE_REQUIRED, 'Set up the required application.'); + $command->addOption('application-version', null, InputOption::VALUE_REQUIRED, 'Set up the required application version.'); + $command->addOption('enterprise', null, InputOption::VALUE_NONE, 'Set up the required application edition to Enterprise Edition.'); + $command->addOption('community', null, InputOption::VALUE_NONE, 'Set up the required application edition to Community Edition.'); + } + + /** @throws NoPossibleGuess */ + public function guess(InputInterface $input, OutputInterface $output, ?Stack\DTO\Context $context = null): Stack\DTO\Context + { + $format = new SymfonyStyle($input, $output); + + if (null === ($phpVersion = $input->getOption('php-version'))) { + $phpVersion = $format->askQuestion( + (new ChoiceQuestion('Which PHP version are you using?', ['5.6', '7.1', '7.2', '7.3', '7.4', '8.0'], '7.3')) + ); + } + + if (null === ($application = $input->getOption('application'))) { + $application = $format->askQuestion( + (new ChoiceQuestion('Which application are you using? (leave empty for native image)', ['orocommerce', 'oroplatform', 'orocrm', 'marello', 'middleware', ''], '')) + ); + } + + if ($context === null) { + $context = new Stack\DTO\Context($phpVersion, $application); + } else { + $context->phpVersion = $phpVersion; + $context->application = $application; + } + + if (null === ($applicationVersion = $input->getOption('application-version'))) { + foreach ($this->contextGuessers as $guesser) { + if (!$guesser->matches($application)) { + continue; + } + + try { + $context = $guesser->guess($input, $output, $context); + break; + } catch (NoPossibleGuess $exception) { + $format->error($exception->getMessage()); + } + } + } else { + $context->applicationVersion = $applicationVersion; + } + + $context->isEnterpriseEdition = false; + if (!empty($context->application)) { + if ($input->getOption('enterprise') === $input->getOption('community')) { + $context->isEnterpriseEdition = $format->askQuestion( + (new ConfirmationQuestion('Is it for Enterprise Edition?', false)) + ); + } else { + $context->isEnterpriseEdition = $input->getOption('enterprise'); + } + } + + if ($context->application === 'orocommerce' && $context->isEnterpriseEdition) { + $format->writeln(strtr('Choosing OroCommerce Enterprise Edition, version %version%.', ['%version%' => $context->applicationVersion])); + } else if ($context->application === 'orocommerce' && !$context->isEnterpriseEdition) { + $format->writeln(strtr('Choosing OroCommerce Community Edition, version %version%.', ['%version%' => $context->applicationVersion])); + } else if ($context->application === 'orocrm' && $context->isEnterpriseEdition) { + $format->writeln(strtr('Choosing OroCRM Enterprise Edition, version %version%.', ['%version%' => $context->applicationVersion])); + } else if ($context->application === 'orocrm' && !$context->isEnterpriseEdition) { + $format->writeln(strtr('Choosing OroCRM Community Edition, version %version%.', ['%version%' => $context->applicationVersion])); + } else if ($context->application === 'marello' && $context->isEnterpriseEdition) { + $format->writeln(strtr('Choosing Marello Enterprise Edition, version %version%.', ['%version%' => $context->applicationVersion])); + } else if ($context->application === 'marello' && !$context->isEnterpriseEdition) { + $format->writeln(strtr('Choosing Marello Community Edition, version %version%.', ['%version%' => $context->applicationVersion])); + } else if ($context->application === 'middleware' && !$context->isEnterpriseEdition) { + $format->writeln(strtr('Choosing Middleware Community Edition, version %version%.', ['%version%' => $context->applicationVersion])); + } else if ($context->application === 'oroplatform' && $context->isEnterpriseEdition) { + $format->writeln(strtr('Choosing OroPlatform Enterprise Edition, version %version%.', ['%version%' => $context->applicationVersion])); + } else if ($context->application === 'oroplatform' && !$context->isEnterpriseEdition) { + $format->writeln(strtr('Choosing OroPlatform Community Edition, version %version%.', ['%version%' => $context->applicationVersion])); + } + + return $context; + } +} \ No newline at end of file