@@ -3,6 +3,8 @@ These documentation is the guide to painlessly setup an automated deploy on the
33The 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
15171 . Composer ` require hypernode/deploy-configuration --dev ` package. Only needed when you want to have autocomplete in your ` deploy.php `
1618file.
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.
2022This configuration object contains the whole deploy configuration and can be altered to your needs using getters/setters.
2123Change configuration matching you use case, and refer to the documentation for other build in configurations and tasks.
22243 . Setup your CI server
@@ -35,7 +37,7 @@ Builds the application to prepare to run in a production environment.
3537You 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
4143This 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
6163For 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
7883All 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
8590For 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
100104For all possible tasks and configuration please refer to the API docs.
101105
102- ### 3 . AfterDeploy tasks
106+ ### 4 . AfterDeploy tasks
103107
104108After deploy tasks are triggered after a succesfull deployment.
105109For 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
114125We provide a few application template which define the common set of tasks to be executed for a specific application type.
115126You could use those so you don't have to specify each task manually.
116127
117128Available 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
122133Example 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
126137Some specific environment variables are required to allow the deploy image access to the git repository
127138or 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
139149repositories like Magento's, 3rd party vendors, or even your own private Composer package repository. If this environment
140150variable does not exist, no ` auth.json ` will be written, so it is optional.
141151The 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
150160First make sure you have all the required env variables setup using.
151161
152- ``` bash
162+ ``` console
153163export SSH_PRIVATE_KEY=***
154164export DEPLOY_COMPOSER_AUTH=***
165+ export HYPERNODE_API_TOKEN=***
155166.... etc
156167```
157168
158169Then 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```
0 commit comments