FROM python:3.10.9 | |
# Copy all files to the container | |
COPY . . | |
# Set the working directory | |
WORKDIR / | |
# Create the directories with appropriate permissions | |
RUN mkdir -m 777 /tmp/NUMBA_CACHE_DIR /tmp/MPLCONFIGDIR | |
# Set environment variables | |
ENV NUMBA_CACHE_DIR=/tmp/NUMBA_CACHE_DIR/ | |
ENV MPLCONFIGDIR=/tmp/MPLCONFIGDIR/ | |
# Install virtualenv | |
RUN python -m venv /opt/venv | |
# Activate the virtual environment and install requirements | |
RUN /opt/venv/bin/pip install --no-cache-dir --upgrade pip && \ | |
/opt/venv/bin/pip install --no-cache-dir --upgrade -r /requirements.txt | |
# Ensure the virtual environment is activated for subsequent commands | |
ENV PATH="/opt/venv/bin:$PATH" | |
# Command to run the application | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |