【问题标题】:Is it good practice to install OS packages using codedeploy?使用 codedeploy 安装操作系统包是一种好习惯吗?
【发布时间】:2021-03-30 11:01:47
【问题描述】:

我正在使用 CodeDeploy 将我的 Rails 应用程序部署到生产环境。如果我将手动部署代码,即转到 CodeDeploy 仪表板并提供提交 ID 并开始部署,则设置运行良好。我正在尝试自动化这个过程。然后,当将新实例添加到 Amazon ELB 时,CodeDeploy 应该部署最后一次成功的部署。完成此设置后,我收到此错误:

[stdout]Retrying `git clone 'https://github.com/charusat09/blazer.git' "/home/ec2-user/web-app/vendor/bundle/ruby/2.4.0/cache/bundler/git/blazer-8d8d6c852e45320db5b464988b7414ae28b41" --bare --no-hardlinks --quiet` due to error (3/4): Bundler::Source::Git::GitCommandError Git error: command `git clone 'https://github.com/charusat09/blazer.git' "/home/ec2-user/web-app/vendor/bundle/ruby/2.4.0/cache/bundler/git/blazer-8d8d6c852e45320db5b464988b7414ae28b41" --bare --no-hardlinks --quiet` in directory /home/ec2-user/web-app has failed.
[stderr]sh: git: command not found

产生这个错误是因为我在我的 Gemfile 文件中使用了分叉的 gem:

gem 'blazer', github: 'charusat09/blazer', branch: 'master'

当 CodeDeploy 尝试安装此 gem 时,它抛出了上述错误。

为了解决这个错误,我在prepare.sh文件中执行bundle install之前安装了GIT:

sudo yum install -y git
bundle install --deployment --without development test

而且,这个设置就像一个魅力。

问题:
我需要帮助来了解我应该从 CodeDeploy 安装 GIT 等软件包吗?或者这样的安装应该发生在其他地方?

感谢您的意见。

【问题讨论】:

    标签: deployment rubygems amazon-elb aws-code-deploy


    【解决方案1】:

    假设您使用的是 CodeDeploy 的蓝绿色部署,

    何时将新实例添加到 Amazon ELB

    最佳做法是使用预烘焙的 AMI。虽然这可能无法使用完全预烘焙的 AMI,但您应该使用预先安装了所有依赖项的 AMI,并且只复制经常更改的工件,即源代码/构建工件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-09
      • 1970-01-01
      • 2019-03-06
      • 2013-03-30
      相关资源
      最近更新 更多