These documentation is the guide to painlessly setup an automated deploy on the Hipex B.V. platform. The repository contains:
- Configuration objects
- Documentation
The deploy image is based on https://deployer.org/ and is 100% compatible with its recipe's and functions. Hipex uses
configuration objects to provide some form of autocompleteion. These configuration objects can be found in this
repository. The hipex wrapper will use the configuration set to create a set of deploy recipe's and hosts that
can be overwritten / extended by the projects deploy.php
.
- Deployer configuration hosts / tasks
- Hipex server setup
- Email / New Relic notification
- CloudFlare flush
- Composer
require hipex/deploy-configuration --dev
package. Only needed when you want to have autocomplete in yourdeploy.php
file. - Copy the deploy templates inside the root of your project as
deploy.php
. You can find the template in templates/deploy.php. - Setup your CI server
- GitLab CI templates/.gitlab-ci.yml.
- Bitbucket templates/bitbucket-pipelines.yml.
- Your first build will fail due to missing configuration. Login to the server and depending on your project file edit
the
app/etc/env.php
orapp/etc/local.xml
. You will find these files in~/domains/<domain>/application/shared/
.
build:update
Checkout the code and run composer installerbuild:compile
Run frontend build and compilation tasks and otherConfiguration::getBuildCommands
commandsbuild:package
Package code intotgz
archivedeploy:prepare_release
Prepare deployment folders on the server(s)deploy:copy
Copy build files to server(s)deploy:deploy
Run database migrations and otherConfiguration::getDeployCommands
commandsdeploy:link
Set symlinks to new versiondeploy:after
Flush caches and send notification and otherConfiguration::getAfterDeployCommands
commands
All these steps are regular deployer tasks so the can be extended or even overwritten per project.
Some specific environment variables are required to allow the deploy image access to the git repository or to be able to send out notifications.
SSH_PRIVATE_KEY
Unencrypted SSH key. The key needs to have access to: main git repository, private packages and the SSH user. Must be base64 encoded like this:
cat ~/.ssh/deploy_key | base64
These variables are only required if Magento composer repository authentication is not configured using auth.json
.
DEPLOY_COMPOSER_AUTH
base64 encoded content ofauth.json
. Can be fetched usingcat auth.json | base64
.
Email notifications
SMTP_SERVER
SMTP_USER
SMTP_PASS
NOTIFICATION_EMAIL_TO
Comma separated list of email address to send notification toNOTIFICATION_EMAIL_FROM
NewRelic deploy mark (https://deployer.org/recipes/newrelic)
NEWRELIC_APP_ID
NEWRELIC_API_KEY
Slack (https://deployer.org/recipes/slack)
SLACK_WEBHOOK
Cloudflare
CLOUDFLARE_SERVICE_KEY
To test your build & deploy you can run your deploy locally.
First make sure you have all the required env variables setup using.
export SSH_PRIVATE_KEY=***
export DEPLOY_COMPOSER_AUTH=***
.... etc
Then start your build / deployment run command from root of the project.
repeat -e for all env vars that are present during build
docker run -it -e SSH_PRIVATE_KEY -e DEPLOY_COMPOSER_AUTH -v `pwd`:/build hipex/deploy hipex-deploy build -vvv
docker run -it -e SSH_PRIVATE_KEY -e DEPLOY_COMPOSER_AUTH -v `pwd`:/build hipex/deploy hipex-deploy deploy acceptance -vvv
Deployer exposes allot of variables you can fetch using the \Deployer\get
or any other deployer method. Please see
https://deployer.org/docs/configuration for a more detailed explenation. On top of the default variables exposed by
deployer the Hipex image adds the following:
bin/php
PHP binary locationpublic_folder
Public html folder of the project.domain_path
Root domain folder (/home/<user>/domains/<domain>
)deploy_path
Root deploy folder containing releases, shared files etc: (/home/<user>/domains/<domain>/application
)cpu_cores
Number of CPU cores on the systemrelease_message
Markdown formatted release message, including branch, commit and merged branches.commit_sha
Commit sha1 reference
Synchronise nginx configuration from repository to server
Arguments:
sourceFolder
Relative path to the nginx configuration in project. (defaultetc/nginx/
)
Replaces crontab with cron file from git. Will prepend some extra env variables to use in cronjobs:
PATH
, bash configuredPATH
variable at deploy time.APP_ROOT
Root of the current release{{release_path}}
Arguments:
sourceFifle
Relative path to the crontab file. (defaultetc/cron
)
Create a supervisord managed jobqueue consumer on server with role ServerRole::APPLICATION_FIRST
.
Arguments:
consumer
Name of the consumer for exampleasync.operations.all
workers
Number of consumers to run (default1
)
Create a varnish instance managed by supervisord on server with role ServerRole::VARNISH
.
Arguments:
memory
Memory usage (default1024m
)frontendPort
Default varnish frontend port (default6181
)adminPort
Default varnish admin port (default6182
)configFile
Varnish configuration file (defaultetc/varnish.vcl
)arguments
Extra arguments used to start varnish
Create a redis instance managed by supervisord on server with role ServerRole::REDIS
.
Arguments:
maxMemory
Max memory usage (default1024m
)listen
Listen to unix socket or ip:port (default{{domain_path}}var/run/redis.sock
)master
Redis instance is slave of configurationconfiguration
Key value pairs with extra configuration for redis config
Create supervisor service configuration for long running process like varnish or PWA nodejs service.
Arguments:
name
Name of the servicesupervisorCommand
The command to runworkers
Number of workers (default1
)configuration
Array of extra key value pairs with configuration settings for supervisor