0

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

John Heyer
  • 711
  • 1
  • 6
  • 18
  • I don't think root_path has the same affect - what happens if you set the WORKDIR to QUART_DIR? – pgjones May 24 '22 at 16:50
  • You're correct, root_path is for the URL, not the directory. WORKDIR sets the directory at build time, but can't be overridden at run time. – John Heyer May 25 '22 at 19:10

0 Answers0