【发布时间】:2018-12-17 05:57:12
【问题描述】:
虽然我已经看到其他问题 - 到目前为止,没有任何建议的解决方案或文档对我有帮助。抱歉,如果这有点多余。
我正在尝试在我的docker-compose.yml 文件中安装一个卷,以便在我进行更改时“热重新加载”我的代码。我正在运行一个烧瓶应用程序。我的文件结构如下:
├── celery_queue
│ ├── Dockerfile
│ ├── requirements.txt
│ └── tasks.py
├── docker-compose.yml
├── my_test_app
│ ├── Dockerfile
│ ├── app
│ │ ├── __init__.py
│ ├── my_test_app.py
│ ├── requirements.txt
│ └── worker.py
├── run.sh
└── stop.sh
我的docker-compose.yml:
version: "3"
services:
redis:
image: "redis:alpine"
web:
build:
context: ./my_test_app
dockerfile: Dockerfile
restart: always
volumes:
- ./my_test_app:/my_test_app
ports:
- "5000:5000"
depends_on:
- redis
worker:
build:
context: celery_queue
dockerfile: Dockerfile
depends_on:
- redis
monitor:
build:
context: celery_queue
dockerfile: Dockerfile
ports:
- "5555:5555"
entrypoint: flower
command: -A tasks --port=5555 --broker=redis://redis:6379/0
depends_on:
- redis
最后——my_test_app 目录中的Dockerfile:
FROM python:3.6-alpine
ENV CELERY_BROKER_URL redis://redis:6379/0
ENV CELERY_RESULT_BACKEND redis://redis:6379/0
ENV C_FORCE_ROOT true
ENV HOST 0.0.0.0
ENV PORT 5000
ENV DEBUG true
ADD . /my_test_app
WORKDIR /my_test_app
# install requirements
RUN pip install --upgrade pip && \
pip install -r requirements.txt
# expose the app port
EXPOSE 5000
RUN pip install gunicorn
# run the app server
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "3", "my_test_app:app"]
再次——我的目标是编辑 my_test_app 目录中的 Flask 代码,并将其重新加载到我的容器中,而无需启动/停止。
提前感谢您的任何建议!
【问题讨论】:
标签: docker flask docker-compose