soisy/codedeployer
Composer 安装命令:
composer require soisy/codedeployer
包简介
Deploy tool interacting with AWS Codedeploy
关键字:
README 文档
README
Codedeployer is a small library that helps deploying any application or codebase to groups of ec2 instances through AWS Codedeploy. The deploy process needs pre-configuration on the AWS side, so ask your nearest ops.
The deployment works like this:
- an archive is created containing the codebase and a special
appspec.ymlfile needed by Codedeploy - this archive is uploaded to S3
- a series of calls is made to the Codedeploy API to initiate deployments
- an agent installed on all supported instances polls Codedeploy waiting for deployment instructions
- when the agent receives a deployment instruction, it downloads the archive from S3 and executes the steps defined in the
appspec.ymlfile
This process shifts the deployment from a push system like Idephix or Deployer that requires ssh access to machines in order to rsync the code, to a poll system where the instances are notified of a new deployment request by the agent and download the application archive, running all the configured scripts to complete the deployment.
Components
Things that run on the deployer machine (dev or CI):
bin/deployscript: sets up autoload and executes the main PHP scriptCodedeployerPHP class: executed on the dev or CI machine, sets up the archive, pushes it to S3 and calls Codedeploy APIs to initiate deploymentsconfig/config.php: configuration file containing the name of the application and the instance groups target of the deployment, used by theCodedeployerclass
Things that run on the target machine (ec2 instance where the code is deployed)
config/appspec.yml: configuration file required by AWS Codedeploy, is included in the archive and describes what to do during the deployment on the target machinesconfig/hook-scripts/hook-wrapper.sh: wrapper script called byappspec.yml, is executed on the destination ec2 machines, calls deployments scripts and provides logging; requires thetstool for timestampingconfig/hook-scripts/instance-template: template directory containing premade scriptsconfig/hook-scripts/strategies: scripts that execute predefined deploy strategies: rotating releases and simple copyconfig/hook-scripts/rsync_exclude: list of files and directories excluded from the final copy
Installation and usage
- Run
composer require soisy/codedeployer - Run
./vendor/bin/deploy --setup - Create directories named as deployment groups
- Add scripts inside deployment groups directories
- Compile
config.php - Run
./vendor/bin/deploy
Point 1 and 2 are self explanatory.
Point 3 requires you to create a directory under deploy/hook-script for each instance group you want to deploy to. You should duplicate the instance-template directory, change its name to the match the deployment group and adjust its content.
For example, if you wish to deploy to ec2-alfa and ec2-beta instance groups, the tree will look like this:
deploy/
└── hook-scripts/
├── ec2-alfa/
└── ec2-beta/
Point 4 requires you to populate the directories from point 3.
AWS Codedeploy offers various hooks during the process, for simplicity the default setup only uses AfterInstall but other hooks can be easily added to appspec.yml if needed.
AfterInstall is the first hook available and is run after the agent has downloaded and extracted the revision archive to a temporary directory;
it is used to actually copy all the code to the real target directory and execute any post-install script that might be needed (ie. clearing cache, recreating snapshots, etc).
For more information on AWS Codedeploy hooks see: https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-hooks.html#appspec-hooks-server
Now add scripts in those directories named after these hooks, so assuming you go for the easy version with just AfterInstall, your tree should look like this:
deploy/
└── hook-scripts/
├── ec2-alfa/
│ └── AfterInstall.sh
└── ec2-beta/
└── AfterInstall.sh
these scripts will be run by the wrapper script hook-wrapper.sh which is defined as the main hook in appspec.yml
Point 5 only requires you to compile a few application related options, the file should be self explanatory.
TODO
- refactor config.php with some other form of configuration
- write Codedeploy new activation (app + groups) through CLI skipping web console
- sanity checks
soisy/codedeployer 适用场景与选型建议
soisy/codedeployer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 55.24k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 08 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「deploy」 「aws」 「codedeploy」 「soisy」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 soisy/codedeployer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 soisy/codedeployer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 soisy/codedeployer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package includes a script and fail2ban configuration that allows you to use fail2ban when utilizing AWS elastic load balancer (ELB) and an apache webserver.
blueways deployer recipes
Elastic Driver for Laravel Scout
The Laragoon utility package
simple api library.
A Highly Opinionated Symfony3/4 Deployer Recipe
统计信息
- 总下载量: 55.24k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-27