Skip to content

Commit f5e5fdf

Browse files
authored
Merge pull request #27 from ByteInternet/v3
Merge v3 branch into master
2 parents 85aca24 + 0259f5f commit f5e5fdf

29 files changed

+155
-197
lines changed

README.md

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ These documentation is the guide to painlessly setup an automated deploy on the
33
The repository contains:
44

55
- Configuration objects
6+
- Deploy configuration templates
7+
- CI configuration templates
68
- Documentation
79

810
## Whats inside?
@@ -14,9 +16,9 @@ The repository contains:
1416
## Configuration
1517
1. Composer `require hypernode/deploy-configuration --dev` package. Only needed when you want to have autocomplete in your `deploy.php`
1618
file.
17-
2. Copy the deploy templates inside the root of your project as `deploy.php`. You can find the template in
19+
2. Copy a `deploy.php` template inside the root of your project as `deploy.php`. You can find the template in
1820
[templates/deploy.php](./templates/deploy.magento2.php).
19-
As you can see a `$configuration` variable is assigned a instance of a `Configuration` class.
21+
As you can see a `$configuration` variable is assigned an instance of a `Configuration` class.
2022
This configuration object contains the whole deploy configuration and can be altered to your needs using getters/setters.
2123
Change configuration matching you use case, and refer to the documentation for other build in configurations and tasks.
2224
3. Setup your CI server
@@ -35,7 +37,7 @@ Builds the application to prepare to run in a production environment.
3537
You can define commands which needs to be executed during the build stage as follows:
3638

3739
``` php
38-
$configuration->addBuildCommand(new \Hypernode\DeployConfiguration\Command\Build\Composer());
40+
$configuration->addBuildTask('deploy:vendors');
3941
```
4042

4143
This command will execute a `composer install` in your project folder install all project dependencies.
@@ -61,18 +63,21 @@ To set extra SSH options (https://www.ssh.com/academy/ssh/config) for your serve
6163
For example:
6264

6365
``` php
64-
$stage->addServer(
65-
'appname.hypernode.io',
66-
[],
67-
[],
68-
['LogLevel' => 'verbose']
69-
);
66+
$stage->addServer('appname.hypernode.io', [], [], ['LogLevel' => 'verbose']);
7067
```
7168

72-
You can define commands which needs to be executed during the deploy stage as follows:
69+
You can define tasks which needs to be executed during the `deploy` stage as follows:
7370

7471
``` php
75-
$configuration->addDeployCommand(new \Hypernode\DeployConfiguration\Command\Deploy\Magento2\CacheFlush());
72+
use function Deployer\{run, task};
73+
74+
...
75+
76+
task('magento:cache:flush', static function () {
77+
run('{{bin/php}} {{release_or_current_path}}/bin/magento cache:flush');
78+
});
79+
80+
$configuration->addDeployTask('magento:cache:flush');
7681
```
7782

7883
All possible commands can be found in the `Hypernode\DeployConfiguration\Command\Deploy` namespace.
@@ -85,9 +90,8 @@ Optionally you can have some services and application configurations setup autom
8590
For example you could maintain your cron configuration in your GIT repository and have it automatically deployed to particular servers.
8691

8792
``` php
88-
$configuration ->addPlatformConfiguration(
89-
(new \Hypernode\DeployConfiguration\PlatformConfiguration\CronConfiguration())
90-
->setStage('production')
93+
$configuration->addPlatformConfiguration(
94+
(new PlatformConfiguration\CronConfiguration())->setStage('production')
9195
);
9296
```
9397

@@ -99,7 +103,7 @@ $configuration->addPlatformService(new \Hypernode\DeployConfiguration\PlatformSe
99103

100104
For all possible tasks and configuration please refer to the API docs.
101105

102-
### 3. AfterDeploy tasks
106+
### 4. AfterDeploy tasks
103107

104108
After deploy tasks are triggered after a succesfull deployment.
105109
For example notifications are available.
@@ -108,60 +112,70 @@ Usage:
108112
``` php
109113
$configuration->addAfterDeployTask(new \Hypernode\DeployConfiguration\AfterDeployTask\SlackWebhook());
110114
```
115+
### 5. Ephemeral servers for acceptance/integration testing
116+
117+
Usage:
118+
``` php
119+
$stage = $configuration->addStage('test', 'test.domain.com');
120+
$stage->addEphemeralServer('appname');
121+
```
111122

112123
## Application template
113124

114125
We provide a few application template which define the common set of tasks to be executed for a specific application type.
115126
You could use those so you don't have to specify each task manually.
116127

117128
Available templates:
118-
- Magento 1
119-
- Magento 2
120-
- Shopware 6
129+
- [Magento 1](src/ApplicationTemplate/Magento1.php)
130+
- [Magento 2](src/ApplicationTemplate/Magento2.php)
131+
- [Shopware 6](src/ApplicationTemplate/Shopware6.php)
121132

122133
Example usage:
123-
`$configuration = new Magento2('git@git.foo.bar:magento-2/project.git', ['nl_NL'], ['nl_NL'])`
134+
`$configuration = new ApplicationTemplate\Magento2(['nl_NL']);`
124135

125136
## Environment variables
126137
Some specific environment variables are required to allow the deploy image access to the git repository
127138
or to be able to send out notifications.
128139

129140
### Required
130-
- `SSH_PRIVATE_KEY` Unencrypted SSH key. The key needs to have access to: main git repository, private packages
131-
and the SSH user. Must be base64 encoded like this:
132-
133-
``` bash
134-
cat ~/.ssh/deploy_key | base64
135-
```
141+
- `SSH_PRIVATE_KEY` Unencrypted SSH key. The key needs to have access to the remote server(s).
142+
May be base64 encoded like this:
143+
``` console
144+
cat ~/.ssh/deploy_key | base64
145+
```
136146

137147
### Optional
138148
- `DEPLOY_COMPOSER_AUTH` Composer auth.json contents. This file is required if you require access to specific Composer
139149
repositories like Magento's, 3rd party vendors, or even your own private Composer package repository. If this environment
140150
variable does not exist, no `auth.json` will be written, so it is optional.
141151
The auth.json must be base64 encoded like this:
142-
143-
``` bash
144-
cat auth.json | base64
145-
```
152+
``` console
153+
cat auth.json | base64
154+
```
155+
- `HYPERNODE_API_TOKEN` The Hypernode API token to be used for the project. Request one at support@hypernode.com.
146156

147157
## Testing
148-
To test your build & deploy you can run your deploy locally.
158+
To test your build & deploy, you can run `hypernode-deploy` locally.
149159

150160
First make sure you have all the required env variables setup using.
151161

152-
``` bash
162+
``` console
153163
export SSH_PRIVATE_KEY=***
154164
export DEPLOY_COMPOSER_AUTH=***
165+
export HYPERNODE_API_TOKEN=***
155166
.... etc
156167
```
157168

158169
Then start your build / deployment run command from root of the project.
159170

160171
*repeat -e <ENV> for all env vars that are present during build*
161-
``` bash
162-
docker run -it -e SSH_PRIVATE_KEY -e DEPLOY_COMPOSER_AUTH -v `pwd`:/build hypernode/deploy hypernode-deploy build -vvv
163-
```
164-
165-
``` bash
166-
docker run -it -e SSH_PRIVATE_KEY -e DEPLOY_COMPOSER_AUTH -v `pwd`:/build hypernode/deploy hypernode-deploy deploy acceptance -vvv
172+
``` console
173+
docker run -it \
174+
-e SSH_PRIVATE_KEY -e DEPLOY_COMPOSER_AUTH -e HYPERNODE_API_TOKEN \
175+
-v `pwd`:/build hypernode/deploy \
176+
hypernode-deploy build -vvv
177+
docker run -it \
178+
-e SSH_PRIVATE_KEY -e DEPLOY_COMPOSER_AUTH -e HYPERNODE_API_TOKEN \
179+
-v `pwd`:/build hypernode/deploy \
180+
hypernode-deploy deploy acceptance -vvv
167181
```

src/AfterDeployTask/Cloudflare.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
use Hypernode\DeployConfiguration\Exception\EnvironmentVariableNotDefinedException;
66
use function Hypernode\DeployConfiguration\getenv;
7-
use Hypernode\DeployConfiguration\ServerRoleConfigurableInterface;
8-
use Hypernode\DeployConfiguration\ServerRoleConfigurableTrait;
9-
use Hypernode\DeployConfiguration\StageConfigurableInterface;
10-
use Hypernode\DeployConfiguration\StageConfigurableTrait;
7+
use Hypernode\DeployConfiguration\Configurable\ServerRoleConfigurableInterface;
8+
use Hypernode\DeployConfiguration\Configurable\ServerRoleConfigurableTrait;
9+
use Hypernode\DeployConfiguration\Configurable\StageConfigurableInterface;
10+
use Hypernode\DeployConfiguration\Configurable\StageConfigurableTrait;
1111
use Hypernode\DeployConfiguration\TaskConfigurationInterface;
1212

1313
class Cloudflare implements

src/AfterDeployTask/EmailNotification.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
use Hypernode\DeployConfiguration\Exception\EnvironmentVariableNotDefinedException;
66
use function Hypernode\DeployConfiguration\getenv;
7-
use Hypernode\DeployConfiguration\ServerRoleConfigurableInterface;
8-
use Hypernode\DeployConfiguration\ServerRoleConfigurableTrait;
9-
use Hypernode\DeployConfiguration\StageConfigurableInterface;
10-
use Hypernode\DeployConfiguration\StageConfigurableTrait;
7+
use Hypernode\DeployConfiguration\Configurable\ServerRoleConfigurableInterface;
8+
use Hypernode\DeployConfiguration\Configurable\ServerRoleConfigurableTrait;
9+
use Hypernode\DeployConfiguration\Configurable\StageConfigurableInterface;
10+
use Hypernode\DeployConfiguration\Configurable\StageConfigurableTrait;
1111
use Hypernode\DeployConfiguration\TaskConfigurationInterface;
1212

1313
class EmailNotification implements

src/AfterDeployTask/NewRelic.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
use Hypernode\DeployConfiguration\Exception\EnvironmentVariableNotDefinedException;
66
use function Hypernode\DeployConfiguration\getenv;
7-
use Hypernode\DeployConfiguration\ServerRoleConfigurableInterface;
8-
use Hypernode\DeployConfiguration\ServerRoleConfigurableTrait;
9-
use Hypernode\DeployConfiguration\StageConfigurableInterface;
10-
use Hypernode\DeployConfiguration\StageConfigurableTrait;
7+
use Hypernode\DeployConfiguration\Configurable\ServerRoleConfigurableInterface;
8+
use Hypernode\DeployConfiguration\Configurable\ServerRoleConfigurableTrait;
9+
use Hypernode\DeployConfiguration\Configurable\StageConfigurableInterface;
10+
use Hypernode\DeployConfiguration\Configurable\StageConfigurableTrait;
1111
use Hypernode\DeployConfiguration\TaskConfigurationInterface;
1212

1313
class NewRelic implements

src/AfterDeployTask/SlackWebhook.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
use Hypernode\DeployConfiguration\Exception\EnvironmentVariableNotDefinedException;
66
use function Hypernode\DeployConfiguration\getenv;
7-
use Hypernode\DeployConfiguration\ServerRoleConfigurableInterface;
8-
use Hypernode\DeployConfiguration\ServerRoleConfigurableTrait;
9-
use Hypernode\DeployConfiguration\StageConfigurableInterface;
10-
use Hypernode\DeployConfiguration\StageConfigurableTrait;
7+
use Hypernode\DeployConfiguration\Configurable\ServerRoleConfigurableInterface;
8+
use Hypernode\DeployConfiguration\Configurable\ServerRoleConfigurableTrait;
9+
use Hypernode\DeployConfiguration\Configurable\StageConfigurableInterface;
10+
use Hypernode\DeployConfiguration\Configurable\StageConfigurableTrait;
1111
use Hypernode\DeployConfiguration\TaskConfigurationInterface;
1212

1313
class SlackWebhook implements

src/ClusterSharedFile.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/ClusterSharedFolder.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/Command/Command.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Hypernode\DeployConfiguration\Command;
44

5-
use Hypernode\DeployConfiguration\StageConfigurableInterface;
6-
use Hypernode\DeployConfiguration\StageConfigurableTrait;
5+
use Hypernode\DeployConfiguration\Configurable\StageConfigurableInterface;
6+
use Hypernode\DeployConfiguration\Configurable\StageConfigurableTrait;
77
use Hypernode\DeployConfiguration\TaskConfigurationInterface;
88

99
class Command implements TaskConfigurationInterface, StageConfigurableInterface

src/Command/DeployCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Hypernode\DeployConfiguration\Command;
44

5-
use Hypernode\DeployConfiguration\ServerRoleConfigurableInterface;
6-
use Hypernode\DeployConfiguration\ServerRoleConfigurableTrait;
5+
use Hypernode\DeployConfiguration\Configurable\ServerRoleConfigurableInterface;
6+
use Hypernode\DeployConfiguration\Configurable\ServerRoleConfigurableTrait;
77

88
class DeployCommand extends Command implements ServerRoleConfigurableInterface
99
{

src/ServerRoleConfigurableInterface.php renamed to src/Configurable/ServerRoleConfigurableInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Hypernode\DeployConfiguration;
5+
namespace Hypernode\DeployConfiguration\Configurable;
66

77

88
interface ServerRoleConfigurableInterface

0 commit comments

Comments
 (0)