Python web应用程序项目结构和docker支持 描述
例如,我有以下flask项目结构:Python web应用程序项目结构和docker支持 描述,python,deployment,configuration,flask,docker,Python,Deployment,Configuration,Flask,Docker,例如,我有以下flask项目结构: ├ project_root/ ├── .gitignore ├── README.md ├── docs ├── requirements.txt ├── yourapp │ ├── templates/ │ ├── static/ │ ├── migrations/ │ ├── config.py │ ├── app1/ │ │ ├── __init__.py │ │ ├── controllers.py │ │
├ project_root/
├── .gitignore
├── README.md
├── docs
├── requirements.txt
├── yourapp
│ ├── templates/
│ ├── static/
│ ├── migrations/
│ ├── config.py
│ ├── app1/
│ │ ├── __init__.py
│ │ ├── controllers.py
│ │ ├── forms.py
│ │ └── models.py
│ ├── app2/
│ │ └── ...
│ └── app.py
└── tests/
我有以下要求:
yourapp/static
另一个问题是,我希望将带有flask代码的文件夹(yourapp)与配置文件夹分开,所有配置文件(nginx、gunicorn、芹菜)都应存储在同一个文件夹中。我将使用
docker compose
并执行类似于此示例的操作docker compose.yml
web-app:
build: .
links:
- postgresql
- rabbitmq
volumes_from:
- config
config:
build: .
dockerfile: dockerfiles/Dockerfile.config
postgresql:
image: postgres:9.4
volumes_from:
- postgresql-data
postgresql-data:
build: dockerfiles/postgresql-data/
nginx:
build: .
dockerfile: dockerfiles/Dockerfile.nginx
links:
- web-app
rabbitmq:
image: rabbitmq:3.5
celery-worker:
build: .
dockerfile: dockerfiles/Dockerfile.celery-worker
links:
- rabbitmq
web app
将使用项目根目录中的默认Dockerfile
,所有其他服务将在子目录中使用命名的Dockerfile(它们可以放在您想要的任何位置,也可以放在根目录中)。只要build
指向根目录,它们就可以访问所有文件
我会将您的应用程序配置放在一个单独的容器中,并使用
中的volumes\u将其提供给应用程序,以便您可以使用具有不同配置的相同无状态应用程序容器
我想这满足你的所有要求