Auto reloading flask server on Docker

前端 未结 4 2233
南笙
南笙 2020-12-16 11:44

I want my flask server to detect changes in code and reload automatically. I\'m running this on docker container. Whenever I change something, I have to build and up again t

4条回答
  •  时光取名叫无心
    2020-12-16 12:16

    Assuming your file structure is the below:

    Dockerfile: (note WORKING DIR)

    FROM python:3.6.5-slim
    RUN mkdir -p /home/project/bottle
    WORKDIR /home/project/bottle 
    COPY requirements.txt .
    RUN pip install --upgrade pip --no-cache-dir -r requirements.txt
    COPY . .
    CMD ["python", "app.py"]
    

    Docker Compose:

    version: '3'
    
    services:
      web:
        container_name: web
        volumes:
          - './web:/home/project/bottle/'  <== Local Folder:WORKDIR
        build: ./web
        ports:
          - "8080:8080"
    

提交回复
热议问题