简体   繁体   English

.env 文件未复制到 AWS EB 上的 docker 容器中

[英].env file didn't copy into docker container on AWS EB

I have the following project structure locally我在本地有以下项目结构

|-- docker-compose.yml |-- docker-entrypoint.sh |-- Dockerfile |-- nginx | `-- loc | `-- nginx.conf |-- poetry.lock |-- pyproject.toml `-- src |-- my_project | |-- asgi.py | |-- __init__.py | |-- settings.py | |-- urls.py | `-- wsgi.py |-- __init__.py |-- manage.py |--.env

In Dockerfile I have the following line COPY /src/ /workdir/在 Dockerfile 我有以下行COPY /src/ /workdir/

Elastic Beanstalk takes env variable and stores them in .env file by the following path /var/app/current then when the container has been built, the env file wasn't copied inside. Elastic Beanstalk 获取 env 变量并通过以下路径将它们存储在.env文件中/var/app/current然后在构建容器时,不会将 env 文件复制到里面。 I made a workaround by copying .env file COPY.env /workdir/ but it doesn't look like a good solution.我通过复制.env文件COPY.env /workdir/来解决问题,但它看起来不是一个好的解决方案。 Should I move everything from /src folder to one level above?我应该将所有内容从/src文件夹移动到上一级吗?

Make sure you do not have the .env file in your .gitignore , .ebignore , or your .dockerignore , otherwise it will not get copied.确保您的.gitignore.ebignore.dockerignore中没有.env文件,否则它不会被复制。

Here is a link to the Elastic Beanstalk documentation regarding how the .env file is handled with regards to Docker deployments:以下是 Elastic Beanstalk 文档的链接,该文档介绍了如何处理 Docker 部署的.env文件:

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker.container.console.html#docker-env-cfg.env-variables https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker.container.console.html#docker-env-cfg.env-variables

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

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