Spaces:
Sleeping
Sleeping
FROM python:3.9-slim | |
WORKDIR /app | |
# Create a non-root user | |
RUN useradd -m appuser | |
# Install system dependencies | |
RUN apt-get update && apt-get install -y \ | |
build-essential \ | |
git \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Create directories for matplotlib and set appropriate permissions | |
RUN mkdir -p /home/appuser/.config/matplotlib && \ | |
chown -R appuser:appuser /home/appuser/.config | |
# Copy requirements first for better caching | |
COPY requirements.txt . | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy application files | |
COPY app.py . | |
COPY utils.py . | |
# Set ownership of application files | |
RUN chown -R appuser:appuser /app | |
# Set environment variable for matplotlib | |
ENV MPLCONFIGDIR=/home/appuser/.config/matplotlib | |
# Expose port for the application | |
EXPOSE 7860 | |
# Switch to the non-root user | |
USER appuser | |
# Command to run the application | |
CMD ["python", "app.py"] |