Running Hypercorn in Docker with custom directory/app location and name

1k Views Asked by At

I'm fairly new to Docker and am building a series of Python containers for practice. One of my goals is to be able to dynamically set the directory and app/module locations via environment variables. I've done this with Flask/Gunicorn and it works fine:

ENV PORT=8080
ENV FLASK_DIR=/opt
ENV FLASK_APP=app:app
COPY app.py $FLASK_DIR
ENTRYPOINT gunicorn --bind=0.0.0.0:$PORT --workers=1 --chdir $FLASK_DIR $FLASK_APP
EXPOSE $PORT

Now I'm just trying to do the same with Quart/Hypercorn:

ENV PORT=8000
ENV QUART_DIR=/opt
ENV QUART_APP=app:app
COPY app.py $QUART_DIR
ENTRYPOINT hypercorn --reload --bind 0.0.0.0:$PORT --workers 1 --root-path $QUART_DIR $QUART_APP
EXPOSE $PORT

But I get this error:

ModuleNotFoundError: No module named 'app'

Looks as if either Hypercorn is ignoring the variable or isn't reading that directory

0

There are 0 best solutions below