File size: 978 Bytes
e0ea777 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# Use an official Python runtime as a parent image
FROM python:3.10-slim
# Set the working directory in the container
WORKDIR /app
# Install minimal system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libgl1 \
libglib2.0-0 \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy the requirements file into the container at /app
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the entire project into the container
COPY . .
# Create a non-root user to run the app (required by Hugging Face Spaces)
RUN useradd -m -u 1000 user
# Switch to the new user
USER user
# Set home directory env
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Expose port 7860 for Hugging Face
EXPOSE 7860
# Healthcheck to ensure the app is running
HEALTHCHECK CMD curl --fail http://localhost:7860/ || exit 1
# Run the Flask application
CMD ["python", "apps/flask_server.py"]
|