Spaces:
Sleeping
Sleeping
FROM python:3.11 | |
# Set DEBIAN_FRONTEND to noninteractive to avoid prompts during apt-get install | |
ENV DEBIAN_FRONTEND=noninteractive | |
# --- User Setup --- | |
# Create a non-root user and switch to it | |
RUN useradd -m -u 1000 user | |
USER user | |
ENV PATH="/home/user/.local/bin:$PATH" | |
WORKDIR /app | |
# --- Python Package Installation (as user) --- | |
# Copy only requirements.txt first to leverage Docker cache | |
COPY --chown=user ./requirements.txt requirements.txt | |
RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
# --- Application Code --- | |
# Copy the rest of the application code | |
COPY --chown=user . /app | |
# --- Run Command --- | |
# Expose the port the app runs on (optional but good practice) | |
EXPOSE 7860 | |
# Start the application | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |