AWS CodeDeploy:修订间差异

来自Gea-Suan Lin's Wiki
跳到导航 跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
第4行: 第4行:


== 安裝 ==
== 安裝 ==
 在伺服器端需要安裝Agent,這隻Agent會負責取得檔案並且執行設定的步驟<ref>{{Cite web |url=https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-install.html |title=Install or Reinstall the AWS CodeDeploy Agent}}</ref>。
 在伺服器端需要安裝Agent,這隻Agent會負責取得檔案並且執行設定的步驟<ref>{{Cite web |url=https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-install.html |title=Install or Reinstall the AWS CodeDeploy Agent - AWS CodeDeploy}}</ref>。
 
以[[Ubuntu]]的環境為例子來說<ref>{{Cite web |url=https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-install-ubuntu.html |title=Install or reinstall the AWS CodeDeploy agent for Ubuntu Server - AWS CodeDeploy}}</ref>,會需要先安裝Ruby 2.0(14.04下)或2.3(16.04下)後,取得安裝設定檔執行:
 
<syntaxhighlight lang="shell-session">
$ sudo apt install ruby2.3
$ cd /tmp
$ wget https://aws-codedeploy-us-east-1.s3.amazonaws.com/latest/install
$ chmod 755 install
$ sudo ./install auto
</syntaxhighlight>
 
在非[[EC2]]的機器上可能會跑比較久(需要等<code>169.254.169.254</code>的timeout)。
 
然後啟動Agent:
 
<syntaxhighlight lang="shell-session">
$ sudo service codedeploy-agent start
</syntaxhighlight>


== 設定 ==
== 設定 ==

2018年5月1日 (二) 19:25的版本

AWS CodeDeployAWS提供的服务之一,用于发布服务器端的软件。

简介

安装

在服务器端需要安装Agent,这只Agent会负责取得档案并且执行设定的步骤[1]

Ubuntu的环境为例子来说[2],会需要先安装Ruby 2.0(14.04下)或2.3(16.04下)后,取得安装设定档执行:

$ sudo apt install ruby2.3
$ cd /tmp
$ wget https://aws-codedeploy-us-east-1.s3.amazonaws.com/latest/install
$ chmod 755 install
$ sudo ./install auto

在非EC2的机器上可能会跑比较久(需要等169.254.169.254的timeout)。

然后启动Agent:

$ sudo service codedeploy-agent start

设定

软件本身有两段设定,一段是Deploy的发起端透过awscli呼叫,另外一段是在appspec.yml定义在服务器上的行为。

发起端

通常会有两个指令:

  • 将现在的目录打包起来传到S3上。可能会使用--ignore-hidden-files避免.git或是.svn被包进去,但这个方式会使得.htaccess不会被包进去,对于使用Apache的使用者来说要注意。
  • 要求CodeDeploy送指令到各机器上抓档案。
$ aws deploy push --application-name "${APPLICATIO_NAME}" --region us-east-1 --s3-location s3://${S3_BUCKET}/${GIT_BRANCH}-${GIT_HASH}
$ aws deploy create-deployment --application-name "${APPLICATION_NAME}" --deployment-group-name "${DEPLOYMENT_GROUP_NAME}" --region us-east-1 --s3-location bucket="${S3_BUCKET},key=${GIT_BRANCH}-${GIT_HASH},bundleType=zip"

服务器端

appspec.xml内最简单的设定就是指定要将这包档案解到哪边:

version: 0.0
os: linux
files:
  - source: /
    destination: /srv/www.example.com

外部机器

当机器不在EC2上时,需要用register-on-premises-instance将机器注册到CodeDeploy上后才能使用。

参考资料

外部链接