本文介绍了CircleCI部署到AWS EC2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您能帮我找到有用的分步指南还是详细概述如何配置(使用2.0语法)以部署到AWS EC2?

Can you help me find a useful step-by-step guide or a Gist outlining in detail how to configure CircleCI (using 2.0 syntax) to deploy to AWS EC2?

我了解基本要求和动态内容,但是不确定在 deploy中放置 .circleci / config.yml 文件的内容步骤。

I understand the basic requirements and the moving pieces, but unsure what to put in the .circleci/config.yml file in the deploy step.

到目前为止,我得到了:

So far I got:


  • A在CircleCI中成功构建的 Hello World (只是没有部署步骤) )

  • 一个正在运行的EC2实例(Ubuntu 16.04)

  • 一个具有足够权限的IAM用户已为该特定作业添加到CircleCI

  • A "Hello World" Node.js app which is building successfully in CircleCI (just without the deploy step)
  • A running EC2 instance (Ubuntu 16.04)
  • An IAM user with sufficient permissions added to CircleCI for that particular job

您能帮上CircleCI部署步骤吗?

Can you help out with the CircleCI deploy step?

推荐答案

遵循您的存储库,y您可以这样创建脚本: deploy.sh

Following your repository, you could create a script just like that: deploy.sh

#!/bin/bash

echo "Start deploy"
cd ~/circleci-aws
git pull
npm i
npm run build
pm2 stop build/server
pm2 start build/server
echo "Deploy end"

然后在您的 .circleci / conf.yml 中执行以下操作:

And in your .circleci/conf.yml you do it:

deploy:
docker:
  - image: circleci/node:chakracore-8.11.1
steps:
  - restore_cache:
      keys:
      - v1-dependencies-{{ checksum "package.json" }}
  - run:
      name: AWS EC2 deploy
      command: |
        #upload all the code to machine
        scp -r -o StrictHostKeyChecking=no ./ [email protected]:/home/circleci-aws/
        #Run script inside of machine
        ssh -o StrictHostKeyChecking=no [email protected] "./deploy.sh"

但是这太丑了,尝试使用AWS Codedeploy或ecs之类的方法来使用容器。

But this is so ugly, try something like AWS Codedeploy or ecs for using containers.

这篇关于CircleCI部署到AWS EC2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 01:55