将代码从GitLab推送到AWS EC2的简便方法

时间:2019-01-05 19:57:35

标签: amazon-web-services amazon-ec2 gitlab gitlab-ci

我正在努力寻找一种简单的方法来将我的后端代码从GitLab推送到AWS EC2。我发现的所有教程和指南真的都很烦人,这对我来说很奇怪,因为将代码上传到AWS S3真是小菜一碟。这是我的S3的gitlab-ci.yml,我在其中上传了前端:

variables:
  S3_BUCKET_PROD: "production-frontend"
  S3_BUCKET_STAGE: "stage-frontend"

deploy-server-stage:
  image: python:3.5
  environment: stage
  script:
  - pip install awscli
  - aws s3 cp dist s3://$S3_BUCKET_STAGE/ --recursive
  only:
    - stage

deploy-server-production:
  image: python:3.5
  environment: production
  script:
  - pip install awscli
  - aws s3 cp dist s3://$S3_BUCKET_PROD/ --recursive
  only:
    - master

对于EC2,这是一个遍历.pemchmod甚至是用.sh文件编写的单独脚本以本地提取代码的过程。确实,大多数教程都是针对此类常见任务的复杂方法。

这并不难(like here for example)-我希望有人能够轻松,优雅地进行管理。目前,最简单的方法是将其从我的计算机中推入ssh,但实际上不应该那样。

万一这很重要:我在说的是Node.js文件,所以没什么花哨的。

0 个答案:

没有答案