Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add environment commands for deployment #13

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
88bb5b9
Update README.md
gplanchat Aug 5, 2020
60a3705
Update README.md
gplanchat Aug 5, 2020
9200f7d
Added Dejavu enable/disable switch
gplanchat Sep 11, 2020
a075f5c
update doc
sylvainraye Sep 21, 2020
2841eb3
Merge pull request #11 from diglin/master
gplanchat Sep 23, 2020
762af97
#12 : add environment:init
nicolas43000 Sep 23, 2020
3bb55d9
#12 : refacto
nicolas43000 Sep 24, 2020
4afd180
#12 : big commit adding DTO, some refacto, get and list command
nicolas43000 Sep 30, 2020
de6bd0a
Merge remote-tracking branch 'origin/master' into feature/12-add-envi…
nicolas43000 Sep 30, 2020
5c58d79
#12 : refacto
nicolas43000 Sep 30, 2020
2e5bdf5
#12 : Add Set & Unset commands + changed PHP requirements + small cs …
nicolas43000 Oct 2, 2020
3174ade
#12 : fix
nicolas43000 Oct 2, 2020
890f79b
#12 : Add deploy, destroy and rsync commands
nicolas43000 Oct 6, 2020
ae22456
#12 : Add cache clear, start and stop commands
nicolas43000 Oct 6, 2020
8f6e466
Merge remote-tracking branch 'origin/master' into feature/12-add-envi…
nicolas43000 Oct 6, 2020
a7100cb
Merge remote-tracking branch 'origin/master' into feature/12-add-envi…
nicolas43000 Nov 17, 2020
a7ba45a
#12 : Run `composer update nothing` after merge
nicolas43000 Nov 17, 2020
8d73483
#12 : fix yaml indent and default dbms to null
nicolas43000 Nov 20, 2020
f4bc6e2
#12 : Add database:dump and variable:add commands
nicolas43000 Nov 20, 2020
3b874f2
#12 : Remove useless code
nicolas43000 Nov 20, 2020
e70ba8b
#12 : Add database:load cmd and timeout(0) to database:dump cmd
nicolas43000 Nov 20, 2020
4bc7a60
#12 : Add shell cmd
nicolas43000 Nov 20, 2020
f1db046
#12 : Add doc to README.md
nicolas43000 Nov 20, 2020
5852e9f
Merge branch 'master' into feature/12-add-environment-commands
gplanchat Nov 25, 2020
5fc566c
Updated retrieved lost docs about environment commands
gplanchat Nov 25, 2020
4c1e9d9
#12 : Add proxy command for port forwarding
nicolas43000 Dec 10, 2020
eee91d7
Merge branch 'feature/12-add-environment-commands' of github.com:kibo…
nicolas43000 Dec 10, 2020
71b9ace
Merge branch 'master' into feature/12-add-environment-commands
gplanchat Dec 14, 2020
1684b03
Remove typo
sebprt Dec 22, 2020
c556e8a
Fix dump and load commands : Create Normalizer and a second Finder in…
sebprt Dec 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ RUN set -ex\
perl \
pkgconf \
pkgconfig \
python \
python3 \
re2c \
readline \
sqlite-libs \
Expand Down
44 changes: 39 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ Docker images and stacks for Oro and Marello development

This project aims at building your Docker stack for [OroCommerce](https://oroinc.com/b2b-ecommerce/), [OroCRM](https://oroinc.com/orocrm/), [OroPlatform](https://oroinc.com/oroplatform/) and [Marello](https://www.marello.com/) development.

> ⚠️ Nota: Those stacks are not suited for production hosting
> ⚠️ Nota: Those stacks are not suited for production hosting, but to provide an environment based on Docker as identical as possible to OroCloud on a personal computer.

* [Requirements](#requirements)
* [Installation](#installation)
* [Usage](#usage)
* [Supported versions and flavors](#supported-versions-and-flavours)
Expand All @@ -14,6 +15,11 @@ This project aims at building your Docker stack for [OroCommerce](https://oroinc
* [Marello](#marello)
* [Middleware](#middleware)

Requirements:
---

- PHP 7.4

Installation
---

Expand All @@ -22,8 +28,8 @@ Installation
While installing system-wide, you will need administrator privilleges to install the command inside `/usr/local/bin/` directory.

```
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 curl -L -o /usr/local/bin/kloud https://github.com/kiboko-labs/docker-images/releases/latest/download/kloud.phar
sudo curl -L -o /usr/local/bin/kloud.pubkey https://github.com/kiboko-labs/docker-images/releases/latest/download/kloud.phar.pubkey
sudo chmod +x /usr/local/bin/kloud
```

Expand All @@ -32,8 +38,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 -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
curl -L -o bin/kloud.phar https://github.com/kiboko-labs/docker-images/releases/latest/download/kloud.phar
curl -L -o bin/kloud.phar.pubkey https://github.com/kiboko-labs/docker-images/releases/latest/download/kloud.phar.pubkey
chmod +x bin/kloud.phar
```

Expand All @@ -60,6 +66,32 @@ You can invoke the following command that will guess what you need and a wizard

`kloud stack:init`

#### Available command line options

* Database engine selection
* `--mysql`: Set up the application to use MySQL.
* `--postgresql`: Set up the application to use PostgreSQL.

* Xdebug a debugger for PHP
* `--with-xdebug`: Set up the application to use Xdebug.
* `--without-xdebug`: Set up the application without Xdebug.

* Blackfire an APM for PHP performance optimizations
* `--with-blackfire`: Set up the application to use Blackfire.
* `--without-blackfire`: Set up the application without Blackfire.

* Dejavu, An ElasticSearch UI
* `--with-dejavu`: Set up the application to use Dejavu UI.
* `--without-dejavu`: Set up the application without Dejavu UI.

* Elastic Stack for application logging
* `--with-elastic-stack`: Set up the application to use Elastic Stack logging.
* `--without-elastic-stack`: Set up the application without Elastic Stack logging.

* Mac OS optimizations on data volumes
* `--with-macos-optimizations`: Set up the application to use Docker for Mac optimizations.
* `--without-macos-optimizations`: Set up the application without Docker for Mac optimizations.

### Update your stack

In an existing project, you can upgrade the docker stack configuration. automagically.
Expand All @@ -73,6 +105,8 @@ If you need to build the images you need in a stack, you can execute the followi

`kloud image:build`

To enable experimental images, you will need to add option `--with-experimental`.

### Test the required images

If you need to test if the images you are using are following every constraint you would expect:
Expand Down
7 changes: 5 additions & 2 deletions bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ DIRECTORY=$( dirname $( dirname $0 ) )

EXEC="docker-compose --project-directory=$DIRECTORY/ --file=$DIRECTORY/docker-compose.yml exec sh"

$EXEC composer install --no-dev --optimize-autoloader \
$EXEC composer install --dev --optimize-autoloader \
&& $EXEC vendor/bin/phpspec run --stop-on-failure --no-code-generation \
&& $EXEC composer install --no-dev --optimize-autoloader \
&& $EXEC box build \
&& docker build -t kiboko/kloud:latest $DIRECTORY/build/ \
&& docker push kiboko/kloud
&& docker push kiboko/kloud \
&& $EXEC composer install --dev --optimize-autoloader
8 changes: 7 additions & 1 deletion bin/kloud
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env php
<?php

if (version_compare(PHP_VERSION, '5.4.0') < 0) {
throw new RuntimeException('This command requires a minimum version 5.4 for PHP. Please upgrade your PHP version or use the pre-packaged Docker image variant. See https://github.com/kiboko-labs/docker-images/#if-you-want-to-use-the-pre-packaged-docker-image');
}

require __DIR__ . '/../vendor/autoload.php';

use Kiboko\Cloud\Platform\Console\Command;
Expand Down Expand Up @@ -55,6 +59,8 @@ $app->addCommands([
__DIR__ . '/../config/',
__DIR__ . '/../compose/',
))->setAliases(['upgrade']),

(new Command\Environment\InitCommand())->setAliases(['env:init']),
nicolas43000 marked this conversation as resolved.
Show resolved Hide resolved
]);

$app->run(new ArgvInput($argv), new ConsoleOutput());
$app->run(new ArgvInput($argv), new ConsoleOutput());
6 changes: 3 additions & 3 deletions phpspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ extensions:
# - vendor
# whitelist:
# - src
Builder\PHPSpec\BuilderExtension: ~
Kiboko\Cloud\PHPSpec\BuilderExtension: ~
formatter.name: pretty
stop_on_failure: false
suites:
builder_suite:
namespace: Builder
psr4_prefix: Builder
namespace: Kiboko\Cloud
psr4_prefix: Kiboko\Cloud
src_path: '%paths.config%'
32 changes: 22 additions & 10 deletions spec/Domain/Packaging/Context/BuildableContextSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

declare(strict_types=1);

namespace spec\Builder\Domain\Packaging\Context;
namespace spec\Kiboko\Cloud\Domain\Packaging\Context;

use Builder\Domain\Packaging;
use Kiboko\Cloud\Domain\Packaging;
use PhpSpec\ObjectBehavior;

final class BuildableContextSpec extends ObjectBehavior
Expand All @@ -20,48 +20,60 @@ public function it_is_initializable()

public function it_does_not_have_a_buildable_parent()
{
$this->beConstructedWith(new Packaging\Context\Context(null, []), '/path/to/dockerfile', []);
$this->beConstructedWith(
new Packaging\Context\Context(null, []),
new Packaging\Placeholder('/path/to/dockerfile'),
[]
);

$this->isParentBuildable()->shouldReturn(false);
$this->asBuildable()->shouldReturnAnInstanceOf(Packaging\Context\BuildableContextInterface::class);
}

public function it_does_fail_if_empty_path()
{
$this->beConstructedWith(null, null, []);

$this->shouldThrow(new \RuntimeException('Could not determine path from parent context, please provide a path for the context.'))
->duringInstantiation();
}

public function it_does_fail_if_empty_path_and_not_a_buildable_parent()
{
$this->beConstructedWith(new Packaging\Context\Context(null, []), null, []);

$this->shouldThrow(new \RuntimeException('Could not determine path from parent context.'))
$this->shouldThrow(new \RuntimeException('Could not determine path from parent context, please provide a path for the context.'))
->duringInstantiation();
}

public function it_does_have_a_buildable_parent()
{
$this->beConstructedWith(new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), []), null, []);

$this->isParentBuildable()->shouldReturn(true);
$this->asBuildable()->shouldReturnAnInstanceOf(Packaging\Context\BuildableContextInterface::class);
}

public function it_does_build_a_copy_from_parent()
{
$this->beConstructedWith(new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), ['%lorem%' => 'ipsum']), null, []);

$this->getParent(['%dolor%' => 'sit amet'])->shouldReturnAnInstanceOf(Packaging\Context\ContextInterface::class);
$this->getParent()->shouldReturnAnInstanceOf(Packaging\Context\ContextInterface::class);
}

public function it_does_build_a_copy_from_parent_and_combine_variables()
{
$this->beConstructedWith(new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), ['%lorem%' => 'ipsum']), null, []);

$this->getParent(['%dolor%' => 'sit amet'])->shouldIterateAs(new \ArrayObject([
'%lorem%' => 'ipsum',
$this->getBuildableParent(null, ['%dolor%' => 'sit amet'])->shouldIterateAs(new \ArrayObject([
'%dolor%' => 'sit amet',
'%lorem%' => 'ipsum',
]));
}

public function it_does_build_a_copy_from_parent_and_replace_variables()
{
$this->beConstructedWith(new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), ['%lorem%' => 'ipsum']), null, []);

$this->getParent(['%lorem%' => 'ipsum sit amet'])->shouldIterateAs(new \ArrayObject([
$this->getBuildableParent(null, ['%lorem%' => 'ipsum sit amet'])->shouldIterateAs(new \ArrayObject([
'%lorem%' => 'ipsum sit amet',
]));
}
Expand Down
128 changes: 128 additions & 0 deletions spec/Domain/Packaging/Context/DependentBuildableContextSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<?php

declare(strict_types=1);

namespace spec\Kiboko\Cloud\Domain\Packaging\Context;

use Kiboko\Cloud\Domain\Packaging;
use PhpSpec\ObjectBehavior;

final class DependentBuildableContextSpec extends ObjectBehavior
{
public function it_is_initializable()
{
$this->beConstructedWith(
null,
new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), []),
null,
[]
);

$this->shouldHaveType(Packaging\Context\DependentBuildableContext::class);
$this->shouldHaveType(Packaging\Context\ContextInterface::class);
$this->shouldHaveType(Packaging\Context\BuildableContextInterface::class);
}

public function it_does_not_have_a_buildable_parent()
{
$this->beConstructedWith(
new Packaging\Context\Context(null, []),
new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), []),
new Packaging\Placeholder('/path/to/dockerfile'),
[]
);

$this->asBuildable()->shouldReturnAnInstanceOf(Packaging\Context\BuildableContextInterface::class);
}

public function it_does_fail_if_empty_path()
{
$this->beConstructedWith(
null,
new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), []),
null,
[]
);

$this->shouldThrow(new \RuntimeException('Could not determine path from parent context, please provide a path for the context.'))
->duringInstantiation();
}

public function it_does_fail_if_empty_path_and_not_a_buildable_parent()
{
$this->beConstructedWith(
new Packaging\Context\Context(null, []),
new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), []),
null,
[]
);

$this->shouldThrow(new \RuntimeException('Could not determine path from parent context, please provide a path for the context.'))
->duringInstantiation();
}

public function it_does_have_a_buildable_parent()
{
$this->beConstructedWith(
new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), []),
new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), []),
null,
[]
);

$this->asBuildable()->shouldReturnAnInstanceOf(Packaging\Context\BuildableContextInterface::class);
}

public function it_does_build_a_copy_from_parent()
{
$this->beConstructedWith(
new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), ['%lorem%' => 'ipsum']),
new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), []),
null,
[]
);

$this->getParent()->shouldReturnAnInstanceOf(Packaging\Context\ContextInterface::class);
}

public function it_does_build_a_copy_from_parent_and_combine_variables()
{
$this->beConstructedWith(
new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), ['%lorem%' => 'ipsum']),
new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), []),
null,
[]
);

$this->getBuildableParent(null, ['%dolor%' => 'sit amet'])->shouldIterateAs(new \ArrayObject([
'%dolor%' => 'sit amet',
'%lorem%' => 'ipsum',
]));
}

public function it_does_build_a_copy_from_parent_and_replace_variables()
{
$this->beConstructedWith(
new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), ['%lorem%' => 'ipsum']),
new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), []),
null,
[]
);

$this->getBuildableParent(null, ['%lorem%' => 'ipsum sit amet'])->shouldIterateAs(new \ArrayObject([
'%lorem%' => 'ipsum sit amet',
]));
}

public function it_does_copy_path_from_parent()
{
$this->beConstructedWith(
new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), ['%lorem%' => 'ipsum']),
new Packaging\Context\BuildableContext(null, new Packaging\Placeholder('/path/to/dockerfile'), []),
null,
[]
);

$this->getPath()->shouldBeLike('/path/to/dockerfile');
}
}
18 changes: 9 additions & 9 deletions spec/Domain/Packaging/DependencyTree/NodeSpec.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace spec\Builder\Domain\Packaging\DependencyTree;

use Builder\Domain\Packaging\Context\BuildableContext;
use Builder\Domain\Packaging\DependencyTree\Node;
use Builder\Domain\Packaging\DependencyTree\NodeInterface;
use Builder\Domain\Packaging\DependencyTree\ResolutionInterface;
use Builder\Domain\Packaging\Native\Tag;
use Builder\Domain\Packaging\Placeholder;
use Builder\Domain\Packaging\Repository;
namespace spec\Kiboko\Cloud\Domain\Packaging\DependencyTree;

use Kiboko\Cloud\Domain\Packaging\Context\BuildableContext;
use Kiboko\Cloud\Domain\Packaging\DependencyTree\Node;
use Kiboko\Cloud\Domain\Packaging\DependencyTree\NodeInterface;
use Kiboko\Cloud\Domain\Packaging\DependencyTree\ResolutionInterface;
use Kiboko\Cloud\Domain\Packaging\Native\PHP\Tag;
use Kiboko\Cloud\Domain\Packaging\Placeholder;
use Kiboko\Cloud\Domain\Packaging\Repository;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

Expand Down
6 changes: 3 additions & 3 deletions spec/Domain/Stack/Compose/EnvironmentVariableSpec.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace spec\Builder\Domain\Stack\Compose;
namespace spec\Kiboko\Cloud\Domain\Stack\Compose;

use Builder\Domain\Stack\Compose\EnvironmentVariable;
use Builder\Domain\Stack\Compose\Variable;
use Kiboko\Cloud\Domain\Stack\Compose\EnvironmentVariable;
use Kiboko\Cloud\Domain\Stack\Compose\Variable;
use PhpSpec\ObjectBehavior;

class EnvironmentVariableSpec extends ObjectBehavior
Expand Down
Loading