I’ve been developing a simple python-fastapi app. Has been working fine in development. When I go to deploy the app, it only runs if I do not mount a volume or if the mounted volume contains all the source code, i.e. from cloning the GitHub repo. If I try to mount an empty volume it fails with the log output:
OS: development - PopOS
deployment - PopOS and Unraid (linux)
‘ERROR: Error loading ASGI app. Could not import module “main”.’
docker build command:
docker build . -t jamesonhm/invest-dash:latest --no-cache
docker run command:
docker run -v .:/invest_dash -p 9090:9090 jamesonhm/invest-dash:latest
GitHub repo:
https://github.com/jamesonhm/invest-dash
Dockerfile:
FROM python:3.11
EXPOSE 9090
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
RUN mkdir /invest_dash
WORKDIR /invest_dash
ENV PYTHONPATH "${PYTHONPATH}:/invest_dash"
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
#VOLUME /invest_dash
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "9090"]
Any help on why this is happening would be greatly appreciated!
Thank you