使用不可变部署策略将Django部署到弹性Beanstalk时没有这样的文件或目录



我已经将我的Django项目部署到AWS上的EB,它运行得很好。

我现在尝试用不可变部署策略部署它,但我得到了这个错误:

Command failed on instance. Return code: 2 Output: python: can't open file '/opt/python/current/app/manage.py': [Errno pt/python/current/app/manage.py': [Errno 2] No such file or directory.

这发生在命令期间:source /opt/python/current/env && python /opt/python/current/app/manage.py migrate

出于某种原因,我无法在第一次部署中包含该命令。

有人知道如何在Django中使用不可变部署方法吗?

以下内容:

source /opt/python/current/env && python /opt/python/current/app/manage.py migrate

当您通过ssh进入EB实例并希望使用环境变量手动运行代码时,它非常有用。

在我看来,当您部署EB时,.ebextensions中的container_commands会更好。

例如,您可以有以下文件.ebextensions/10_run_migrate.config

container_commands:
10_run_migrate:
command: 'python ./manage.py migrate'

请注意,这只是一个例子。因此,该文件可能需要使用Django特定的命令或设置进行调整。

最新更新