CircleCI deployment to AWS EC2

帅比萌擦擦* 提交于 2019-12-04 09:03:50

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"

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 ./ ubuntu@13.236.1.107:/home/circleci-aws/
        #Run script inside of machine
        ssh -o StrictHostKeyChecking=no ubuntu@13.236.1.107 "./deploy.sh"

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!