[英]change ec2 instance to use ecr image and docker
I have ec2 instance for testing.我有 ec2 实例用于测试。 I deployed using OpsWorks, and now I'm making new job on Jenkins to deploy automatically.我使用 OpsWorks 进行部署,现在我正在 Jenkins 上创建新工作以自动部署。 what I want to do is我想做的是
when someone push to branch当有人推动分支时
I made a job that using ecr and deploy ECS Fargate, but never done using ecr and deploy pre existed ec2 instance.I wonder this is possible to make it.我做了一份使用 ecr 并部署 ECS Fargate 的工作,但从未使用过 ecr 并部署预先存在的 ec2 实例。我想知道这是否可能实现。
Pre-requisite先决条件
On your EC2
you first have to install docker
.在您的EC2
您首先必须安装docker
。
There are many ways you can do it.有很多方法可以做到。
Once Jenkin build & push docker image to ECR
you can further add the step in Jenkin build steps.一旦 Jenkin 构建并将 docker 镜像推送到ECR
您可以进一步添加 Jenkin 构建步骤中的步骤。 Jenkin will do SSH inside EC2
and pull and run the docker image. Jenkin 将在EC2
内执行 SSH 并拉取并运行 docker 镜像。
Once Jenkin build & push docker image to ECR you can further add the step in Jenkin build steps.一旦 Jenkin 构建并将 docker 镜像推送到 ECR,您可以进一步添加 Jenkin 构建步骤中的步骤。 Jenkin will trigger shell script
file on EC2
. Jenkin 将在EC2
上触发shell script
文件。 That sh
file having all logic to pull the latest one and stop existing etc.该sh
文件具有提取最新文件并停止现有等的所有逻辑。
From Jenkins also you can do it via ansible script.从 Jenkins 也可以通过 ansible 脚本来完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.