Spaces:
Running
Running
# Use the official Python 3.10.9 image | |
FROM python:3.10.9 | |
# Set the working directory to /app | |
WORKDIR /app | |
# Copy the current directory contents into /app inside the container | |
COPY . /app | |
# Copy the model file into the /app directory | |
COPY 1026.pt /app/1026.pt | |
# Install dependencies for OpenCV and other requirements | |
RUN apt-get update && apt-get install -y libgl1 libglib2.0-0 curl | |
# Create a user to avoid permission issues | |
RUN useradd -m appuser | |
# Ensure that saved_images directory is created and has the right permissions | |
RUN mkdir -p /app/saved_images && chown -R appuser:appuser /app/saved_images | |
# Switch to the non-root user | |
USER appuser | |
# Add /home/appuser/.local/bin to PATH | |
ENV PATH="/home/appuser/.local/bin:${PATH}" | |
# Install Python dependencies | |
RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt | |
# Set the FastAPI app environment variable to point to the app file path | |
ENV PYTHONPATH=/app | |
# Start the FastAPI app | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |