Skip to content

Commit

Permalink
Review and Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
Plopix committed Feb 11, 2021
1 parent c00a899 commit 7c6bef7
Show file tree
Hide file tree
Showing 19 changed files with 92 additions and 304 deletions.
30 changes: 27 additions & 3 deletions .github/workflows/main-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@master
with:
php-version: 7.3
php-version: 7.4
id: php
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest --no-interaction
Expand Down Expand Up @@ -46,8 +46,8 @@ jobs:
run: php vendor/behat/behat/bin/behat -c tests/behat.yml


usage:
name: Usage
ezpltaform:
name: eZ Platform
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -76,3 +76,27 @@ jobs:
run: php bin/ez-prod ps
- name: Verification using Postman
run: docker run --net=host -v $(pwd)/tests/postman:/etc/newman -t postman/newman_ubuntu1404 run ${{ matrix.collection }}

ibexa:
name: Ibexa
runs-on: ubuntu-latest
strategy:
matrix:
php: [7.2, 7.3, 7.4]
ezversion: [3.*]
collection: [collection-2x.json]
steps:
- uses: actions/checkout@v1
- name: Setup PHP
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php }}
id: php
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest --no-interaction
- name: Initialization
run: php bin/ez-prod init ibexa/oss ${{ matrix.ezversion }} --no-interaction -vvv
- name: Status Info
run: php bin/ez-prod ps
- name: Verification using Postman
run: docker run --net=host -v $(pwd)/tests/postman:/etc/newman -t postman/newman_ubuntu1404 run ${{ matrix.collection }}
6 changes: 1 addition & 5 deletions config/commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ services:

eZ\Launchpad\Command\Docker\Initialize:
calls:
- [setRequiredRecipes, [ [ 'composer_install', 'ez_install', 'ez_install_solr' ] ] ]

eZ\Launchpad\Command\Docker\InitializeIbexa:
calls:
- [setRequiredRecipes, [ [ 'composer_install', 'ibexa_install', 'ez_install_solr' ,'ibexa_db_init'] ] ]
- [setRequiredRecipes, [ [ 'composer_install', 'ez_install', 'ibexa_install', 'ez_install_solr' ] ] ]

eZ\Launchpad\Command\Docker\InitializeSkeleton:
calls:
Expand Down
23 changes: 0 additions & 23 deletions payload/dev/nginx/doc/nginx/ez_params.d/ez_fastcgi_params

This file was deleted.

11 changes: 0 additions & 11 deletions payload/dev/nginx/doc/nginx/ez_params.d/ez_prod_rewrite_params

This file was deleted.

This file was deleted.

This file was deleted.

26 changes: 0 additions & 26 deletions payload/dev/nginx/doc/nginx/ez_params.d/ez_rewrite_params

This file was deleted.

7 changes: 0 additions & 7 deletions payload/dev/nginx/doc/nginx/ez_params.d/ez_server_params

This file was deleted.

23 changes: 0 additions & 23 deletions payload/recipes/ibexa_db_init.bash

This file was deleted.

43 changes: 31 additions & 12 deletions payload/recipes/ibexa_install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ cd $PROJECTMAPPINGFOLDER

PHP="php"
COMPOSER="$PHP -d memory_limit=-1 /usr/local/bin/composer"
VERSION=$1
PACKAGE=$2
PROVISIONING=$3
REPO=$1
VERSION=$2
INIT_DATA=$3
DATABASE_PREFIXES=${DATABASE_PREFIXES:-DATABASE}
CONSOLE="bin/console"

for prefix in $DATABASE_PREFIXES
do
Expand All @@ -26,38 +27,56 @@ do
mysql -h"${!DATABASE_HOST_VAR}" -u"${!DATABASE_USER_VAR}" -p"${!DATABASE_PASSWORD_VAR}" -e "CREATE DATABASE ${!DATABASE_NAME_VAR}"
done

echo "Installation eZ Platform ($PACKAGE - $VERSION) in the container"
echo "Installation Ibexa ($REPO - $VERSION) in the container"

# Install ibexa/website-skeleton
echo "Install ibexa/website-skeleton"
$COMPOSER create-project --no-interaction ibexa/website-skeleton ezplatform $VERSION
cd ezplatform
# Copy nginx conf
echo "Copy nginx conf"
cp -r ../$PROVISIONING/dev/nginx/doc .
echo "Getting the NGINX config"
wget https://github.com/ibexa/docker/archive/main.zip
unzip main.zip
mkdir -pf doc
cp -r docker-main/templates/nginx doc/
rm -rf docker-main
rm main.zip

# Add .env.local to set database configuration
echo "Add .env.local to set database configuration"
echo "DATABASE_URL=\${DATABASE_PLATFORM}://\${DATABASE_USER}:\${DATABASE_PASSWORD}@\${DATABASE_HOST}:\${DATABASE_PORT}/\${DATABASE_NAME}?serverVersion=\${DATABASE_VERSION}" > ".env.local"

# Test the package version
if [ $PACKAGE != "ibexa/oss" ]; then
if [ "$REPO" != "ibexa/oss" ]; then
echo "configure auth updates.ibexa.co"
$COMPOSER config repositories.ibexa composer https://updates.ibexa.co
fi
# Install package ( oss or content or commerce or experience )
echo "Install package $PACKAGE"
$COMPOSER require $PACKAGE
echo "Install package $REPO"
$COMPOSER require $REPO

# recipes:install ( content or commerce or experience )
echo "recipes:install $PACKAGE"
$COMPOSER recipes:install $PACKAGE --force
echo "recipes:install $REPO"
$COMPOSER recipes:install $REPO --force

MAJOR_VERSION=`echo $VERSION | cut -c 1-2`

# Do some cleaning
## Folder
rm -rf bin/.ci bin/.travis

echo "Installation Ibexa $PACKAGE OK"
echo "Installation Ibexa $REPO OK"

# Prefer install via composer alias (added in v2.2, required for eZ Commerce)
if $COMPOSER run-script -l | grep -q " $INIT_DATA "; then
$COMPOSER run-script $INIT_DATA
else
echo "php bin/console ibexa:install"
$PHP $CONSOLE ibexa:install $INIT_DATA
fi
echo "php bin/console ibexa:graphql:generate-schema"
$PHP $CONSOLE ibexa:graphql:generate-schema
echo "composer run post-update-cmd"
$COMPOSER run-script post-install-cmd

echo "Database init OK"
44 changes: 23 additions & 21 deletions src/Command/Docker/Initialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use eZ\Launchpad\Core\DockerCompose;
use eZ\Launchpad\Core\ProcessRunner;
use eZ\Launchpad\Core\ProjectStatusDumper;
use eZ\Launchpad\Core\ProjectWizard;
use eZ\Launchpad\Core\TaskExecutor;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -55,6 +56,11 @@ protected function configure(): void
);
}

private function isIbexa(InputInterface $input): bool
{
return false !== strpos($input->getArgument('repository'), 'ibexa');
}

private function getEzPlataformMajorVersion(InputInterface $input): int
{
$normalizedVersion = trim($input->getArgument('version'), 'v');
Expand Down Expand Up @@ -82,19 +88,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int

// Get the Payload docker-compose.yml
$compose = new DockerCompose("{$this->getPayloadDir()}/dev/docker-compose.yml");
$wizard = $this->setProjectWizard();
$configurations = $wizard($compose);
$isIbexaPackage = $wizard->isFullIbexaPackage();
$wizard = new ProjectWizard($this->io, $this->projectConfiguration);

if (false !== $isIbexaPackage) {
// Ask the questions
[$networkName, $networkPort, $selectedServices, $provisioningName, $composeFileName] = $configurations;
} else {
// Ask the questions
[
$networkName, $networkPort, $selectedServices, $provisioningName, $composeFileName, $httpBasics
] = $configurations;
}
// Ask the questions
[$networkName, $networkPort, $httpBasics, $selectedServices, $provisioningName, $composeFileName] = $wizard(
$compose
);

$compose->filterServices($selectedServices);

Expand Down Expand Up @@ -172,7 +171,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

// Ibexa >= 3.3.x , update composer to v2
if (false !== $isIbexaPackage) {
if ($this->isIbexa($input)) {
$enginEntryPointPath = "{$provisioningFolder}/dev/engine/entrypoint.bash";
$engineEntryPointContent = file_get_contents($enginEntryPointPath);
file_put_contents(
Expand All @@ -199,13 +198,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'docker.network_prefix_port' => $networkPort,
];

if (isset($httpBasics) && is_array($httpBasics)) {
foreach ($httpBasics as $name => $httpBasic) {
[$host, $user, $pass] = $httpBasic;
$localConfigurations["composer.http_basic.{$name}.host"] = $host;
$localConfigurations["composer.http_basic.{$name}.login"] = $user;
$localConfigurations["composer.http_basic.{$name}.password"] = $pass;
}
foreach ($httpBasics as $name => $httpBasic) {
[$host, $user, $pass] = $httpBasic;
$localConfigurations["composer.http_basic.{$name}.host"] = $host;
$localConfigurations["composer.http_basic.{$name}.login"] = $user;
$localConfigurations["composer.http_basic.{$name}.password"] = $pass;
}

$this->projectConfiguration->setMultiLocal($localConfigurations);
Expand Down Expand Up @@ -277,7 +274,12 @@ protected function innerInitialize(
$initialdata = (false !== strpos($repository, 'ezplatform-ee') ? 'ezplatform-ee-clean' : 'clean');
}

$executor->eZInstall($normalizedVersion, $repository, $initialdata);
if (!$this->isIbexa($input)) {
$executor->eZInstall($normalizedVersion, $repository, $initialdata);
} else {
$executor->iBexaInstall($normalizedVersion, $repository, $initialdata);
}

if ($compose->hasService('solr')) {
$executor->eZInstallSolr();
}
Expand Down
Loading

0 comments on commit 7c6bef7

Please sign in to comment.