hipex/deploy-configuration
Composer 安装命令:
composer require hipex/deploy-configuration
包简介
Hipex deploy image configuration files
README 文档
README
These documentation is the guide to painlessly setup an automated deploy on the Hipex B.V. platform. The repository contains:
- Configuration objects
- Documentation
Whats inside?
- Deployer configuration hosts / tasks
- Hipex server setup
- Email / New Relic notification
- CloudFlare flush
Configuration
- Composer
require hipex/deploy-configuration --devpackage. Only needed when you want to have autocomplete in yourdeploy.phpfile. - Copy the deploy templates inside the root of your project as
deploy.php. You can find the template in templates/deploy.php. As you can see a$configurationvariable is assigned a instance of aConfigurationclass. This configuration object contains the whole deploy configuration and can be altered to your needs using getters/setters. Change configuration matching you use case, and refer to the documentation for other build in configurations and tasks. - Setup your CI server
- GitLab CI templates/.gitlab-ci.yml.
- Bitbucket templates/bitbucket-pipelines.yml.
- For Magento 2 your first build will fail due to missing configuration. Login to the server and depending on your project file edit
the
app/etc/env.phporapp/etc/local.xml. You will find these files in~/domains/<domain>/application/shared/.
Build steps
1. Build
Builds the application to prepare to run in a production environment.
You can define commands which needs to be executed during the build stage as follows:
$configuration->addBuildCommand(new \HipexDeployConfiguration\Command\Build\Composer())
This command will execute a composer install in your project folder install all project dependencies.
All possible commands can be found in the HipexDeployConfiguration\Command\Build namespace.
Refer to the API docs for usage and options.
This repository contains a few application templates which specifies the common tasks and their order to get the application build correctly. See application templates for more information.
2. Deploy
Deploys the application which was build in the build stage to a given set of hosts.
First you need to define your environments / infrastructure.
$stageAcceptance = $configuration->addStage('acceptance', 'acceptance.mydomain.com', 'my_ssh_username');
$stageAcceptance->addServer('productionxxx.hipex.io', [
ServerRole::APPLICATION_FIRST,
ServerRole::APPLICATION,
ServerRole::LOAD_BALANCER,
ServerRole::VARNISH,
ServerRole::REDIS,
]);
To set extra SSH options (https://www.ssh.com/academy/ssh/config) for your server you can also provide these. For example:
$stage->addServer(
'productionxxx.hipex.io',
[ServerRole::APPLICATION],
[],
['LogLevel' => 'verbose']
You can define commands which needs to be executed during the deploy stage as follows:
$configuration->addDeployCommand(new \HipexDeployConfiguration\Command\Deploy\Magento2\CacheFlush())
All possible commands can be found in the HipexDeployConfiguration\Command\Deploy namespace.
Refer to the API docs for usage and options.
3. Provision Platform services / configurations
Optionally you can have some services and application configurations setup automatically from your git repository to the Hipex platform
For example you could maintain your cron configuration in your GIT repository and have it automatically deployed to particular servers.
$configuration
->addPlatformConfiguration(
(new \HipexDeployConfiguration\PlatformConfiguration\CronConfiguration())
->setStage('production')
)
Or setup a varnish instance
$configuration->addPlatformService(new \HipexDeployConfiguration\PlatformService\VarnishService())
For all possible tasks and configuration please refer to the API docs.
4. AfterDeploy tasks
After deploy tasks are triggered after a succesfull deployment. For example notifications are available.
Usage:
$configuration->addAfterDeployTask(\HipexDeployConfiguration\AfterDeployTask\SlackWebhook())
Application template
We provide a few application template which define the common set of tasks to be executed for a specific application type. You could use those so you don't have to specify each task manually.
Available templates:
- Magento 1
- Magento 2
Example usage:
$configuration = new Magento2('git@git.foo.bar:magento-2/project.git', ['nl'], ['nl'])
Required environment variables
Some specific environment variables are required to allow the deploy image access to the git repository or to be able to send out notifications.
Required
SSH_PRIVATE_KEYUnencrypted 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
ServerRoles and Stages
Servers are defined with a given set of server roles
$stage = $configuration->addStage('production', 'www.mydomain.com', 'my_ssh_username');
$stage->addServer('production1.hipex.io', [
ServerRole::APPLICATION,
]);
$stage->addServer('production2.hipex.io', [
ServerRole::LOADBALANCER,
]);
Most of the configurations can be specifically set for a given serverrole and/or stage.
$nginxConfiguration = (new NginxConfiguration('/etc/nginx/production'))
->setServerRoles([ServerRole::APPLICATION])
->setStage('production')
$configuration->addPlatformConfiguration($nginxConfiguration)
This nginx configuration task will only be executed on production1, because this is the only one having server role APPLICATION
Most tasks are assigned logical server roles already, so no need to specify them in those cases.
Testing
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
hipex/deploy-configuration 适用场景与选型建议
hipex/deploy-configuration 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 263.12k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2018 年 08 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 hipex/deploy-configuration 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hipex/deploy-configuration 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 263.12k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: OSL-3.0
- 更新时间: 2018-08-13