简体   繁体   English

AWS Elastic Beanstalk + Git 子模块

[英]AWS Elastic Beanstalk + Git Submodules

I'm using Amazon's Elastic Beanstalk to deploy my app via Git, and I've got submodules within my Git.我正在使用 Amazon 的 Elastic Beanstalk 通过 Git 部署我的应用程序,并且我的 Git 中有子模块。 Of course, when I look at the directories where the data for the submodules should be, nothing is there because the submodules have not been initialized.当然,当我查看子模块数据应该在的目录时,什么都没有,因为子模块尚未初始化。

Apparently Elastic Beanstalk doesn't support submodules.显然 Elastic Beanstalk 不支持子模块。 Is this correct?这样对吗? If so, how can I convince Git to let me have the features of a submodule but still upload all the code of the submodule when I push the main repo?如果是这样,我如何说服 Git 让我拥有子模块的功能,但在推送主 repo 时仍然上传子模块的所有代码?

Elastic Beanstalk does support sub-modules if you just make sure that Git is installed on the AMI you use by Customizing and Configuring AWS Elastic Beanstalk Environments .如果您只是通过自定义和配置 AWS Elastic Beanstalk 环境确保 Git 安装在您使用的 AMI 上,则 Elastic Beanstalk 确实支持子模块。 You can do that by providing a config in your git repo:你可以通过在你的 git repo 中提供一个配置来做到这一点:

  • Create a configuration file with the extension .config (eg, myapp.config ) and place it in an .ebextensions top-level directory of your git repo创建一个扩展名为.config的配置文件(例如myapp.config ),并将其放在.ebextensions git repo 的顶级目录中

  • In that file, specify the dependencies:在该文件中,指定依赖项:

 packages: <name of package manager>: <package name>: <version>

for example:例如:

 packages: yum: git: []
  • make sure you match the name of package manager to the AMI you're using, so for example yum for Amazon Linux, apt for Ubuntu.确保name of package managername of package manager您正在使用的 AMI 匹配,例如yum用于 Amazon Linux, apt用于 Ubuntu。

  • you'll probably have to adapt your build script to initialize the sub-modules as EB won't do that for you你可能需要调整你的构建脚本来初始化子模块,因为 EB 不会为你做这件事

  • commit, push and deploy and go提交、推送和部署然后开始

Which container?哪个容器? Java, Ruby, etc? Java、Ruby 等?

There are different deployment tools, you aren't just stuck with the command-line eb that is available at aws.有不同的部署工具,您不仅限于 aws 上可用的命令行eb I've been working on a config/rake gem (that uses eb_deployer ) that I'll be putting out shortly that just uses a zip file, not a git push, so that would work.我一直在研究 config/rake gem(使用eb_deployer ),我很快就会推出它,它只使用 zip 文件,而不是 git push,这样就可以了。 You might also try ebs-deploy .您也可以尝试ebs-deploy

If you use awsebcli installed thru pip, then this may help you.如果您使用通过 pip 安装的awsebcli ,那么这可能对您有所帮助。

We found the source code for AWS-EB client 3.10.1 on PyPi.我们在 PyPi 上找到了 AWS-EB 客户端 3.10.1 的源代码

The issue is in how git repos are handled while zipping your project's source code for uploading it to AWS.问题在于在压缩项目的源代码以将其上传到 AWS 时如何处理 git repos。 If you do not use git for your AWS project, the whole project directory (including any other git modules under subdirectories you may have in it) is zipped and sent to AWS.如果您不将 git 用于您的 AWS 项目,则整个项目目录(包括您可能在其中拥有的子目录下的任何其他 git 模块)将被压缩并发送到 AWS。 If you use git, then all the checked-in or staged code except the submodules is zipped and sent to AWS.如果您使用 git,则除子模块之外的所有签入或暂存代码都会被压缩并发送到 AWS。 Git submodules are skipped.跳过 Git 子模块。

We wrote a fix for this issue by changing the behavior such that the submodules are also added to the zipped archive.我们通过更改行为来解决此问题,以便将子模块也添加到压缩存档中。 You can see the fix at github.com/uppercasebrands/awsebcli-3.10.1/compare/eb-deploy-submodule on our git repo which is created from the original PyPi package.您可以在 github.com/uppercasebrands/awsebcli-3.10.1/compare/eb-deploy-submodule 上看到我们的 git 存储库中的修复,它是从原始 PyPi 包创建的。

You can install the fixed awsebcli-3.10.1 which now supports submodules by using pip:您可以使用 pip 安装现在支持子模块的固定 awsebcli-3.10.1:

pip install --upgrade git+https://github.com/uppercasebrands/awsebcli-3.10.1.git@eb-deploy-submodule

如果您使用的是 CodePipeline,则有一种方法可以使用 CodeBuild 获取所有子模块并自动将此工件提供给 Elastic Beanstalk: https ://medium.com/@cristiano.ventura/working-with-git-submodules-in-codepipeline -83e843e5d0a

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM