[英]Python in AWS Elastic Beanstalk: Private package dependencies
I would like to deploy a Python Flask application on beanstalk.我想在 beanstalk 上部署一个 Python Flask 应用程序。
The application depends on external packages (eg geopy
) and internal packages (eg adam_geography
).应用程序依赖于外部包(例如geopy
)和内部包(例如adam_geography
)。
Create a requirements.txt file and place it in the top-level directory of your source bundle.创建一个 requirements.txt 文件并将其放在源包的顶级目录中。
This would probably fetch geopy
and its dependencies, but would not fetch adam_geography
which is available from a custom repo inside my VPC.这可能会获取geopy
及其依赖项,但不会获取可从我的 VPC 中的自定义存储库获得的adam_geography
。
How do I specify/upload private, internal Python package dependencies in a Beanstalk application?如何在 Beanstalk 应用程序中指定/上传私有的内部 Python package 依赖项?
1) copy internal Python package to server 1) 将内部 Python package 复制到服务器
2) use Pip's "editable installs" feature to install the private package: 2) 使用 Pip 的“可编辑安装”功能安装私有 package:
pip install -e path/to/SomeProject
http://pip.readthedocs.org/en/latest/reference/pip_install.html#editable-installs http://pip.readthedocs.org/en/latest/reference/pip_install.html#editable-installs
Use ebextensions to specify custom commands you can use to download files on all your EC2 instances.使用 ebextensions 指定可用于在所有 EC2 实例上下载文件的自定义命令。 These ebextensions can be used to run pip like @shavenwarthog suggested in his answer.这些 ebextensions 可用于运行 pip 就像@shavenwarthog 在他的回答中建议的那样。 Create a directory called .ebextensions
in your app source root directory.在您的应用程序源根目录中创建一个名为.ebextensions
的目录。 Inside this directory create a file with a .config
extension say 01-custom-files.config
.在此目录中创建一个扩展名为.config
的文件,例如01-custom-files.config
。 This file can contain custom unix commands you want to run on each EC2 instance.此文件可以包含您要在每个 EC2 实例上运行的自定义 unix 命令。 You can run your own scripts here.您可以在此处运行自己的脚本。
You can also use container_commands which are executed after unzipping your app source on the EC2 instance.您还可以使用在 EC2 实例上解压缩应用程序源后执行的 container_commands。
Read more about commands and container_commands here.在此处阅读有关命令和 container_commands 的更多信息。 You can also find examples here:您还可以在此处找到示例:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-commands http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-commands
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-container_commands http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-container_commands
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.