Mentora / Dockerfile
samuelolubukun's picture
Upload 37 files
f8dbd20 verified
# Use an official Python runtime as a parent image
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PORT=7860
# Set the working directory in the container
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user and change ownership of the /app directory
RUN useradd -m -u 1000 user
RUN chown -R user:user /app
# Switch to the non-root user
USER user
ENV PATH="/home/user/.local/bin:${PATH}"
# Copy the requirements file into the container at /app
COPY --chown=user:user requirements.txt .
# Install any needed packages specified in requirements.txt
RUN pip install --no-cache-dir --user -r requirements.txt
# Copy the rest of the application code into the container
COPY --chown=user:user . .
# Generate Prisma client
RUN python -m prisma generate
# Expose the port the app runs on
EXPOSE 7860
# Command to run the application
# We use uvicorn to run the FastAPI app.
# Hugging Face Spaces expects the app to be on port 7860.
CMD ["python", "main.py"]