FROM python:3.9 # Create and set the working directory WORKDIR /code # Copy the requirements file COPY ./requirements.txt /code/requirements.txt # Install the virtualenv package RUN pip install --no-cache-dir virtualenv # Create a virtual environment RUN python -m virtualenv venv # Use the virtual environment ENV PATH="/code/venv/bin:$PATH" # Install dependencies in the virtual environment RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt # Copy the rest of the application code COPY . . # Run the application using the virtual environment's Python CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]