As the title states, I am working with a dockerized Flask app with Gunicorn, but the hot reload is not working.
I know I have to map the local file system to that of the container, so that it is aware of the changes and Flask on Debug mode will do the rest.
This is the structure of my project:
This is my Dockerfile
:
FROM python:3.9
ARG USER
ARG PASS
ARG RESOLVER_URL
ENV PIP_INDEX_URL=https://$USER:$PASS@$RESOLVER_URL
ENV FLASK_APP jfrog_api.py
ENV FLASK_ENV development
COPY . /app/
WORKDIR /app
RUN adduser --system --group app -u 1001 \
&& apt-get update \
&& apt-get upgrade -y \
&& python3 -m pip install -r requirements.txt
USER app:app
EXPOSE 5000
CMD ["gunicorn", "-b", "0.0.0.0:5000", "jfrog_api:app"]
This is my docker-compose.yml
file:
version: '3'
services:
jfrog-api:
build: .
image: jfrog-api
ports:
- "${JFROG_API_PORT:-5000}:5000"
volumes:
- type: volume
source: data
target: /data
env_file: .env
restart: always
volumes:
data:
This is the entrypoint of my Flask application, jfrog_api.py
:
from api import create_app
app = create_app()
I have checked many other similar cases but I still cannot make it work in my project. Any ideas would be greatly appreciated.