ProjSentinel / Dockerfile
Paulownia's picture
docker deployment
27b973a verified
Raw
History Blame Contribute Delete
952 Bytes
# Use Python 3.9
FROM python:3.9
# Install system dependencies for OpenCV and GLib
USER root
RUN apt-get update && apt-get install -y \
libgl1 \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user matching HF Spaces UID (1000)
RUN useradd -m -u 1000 user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
YOLO_CONFIG_DIR=/tmp/Ultralytics \
MPLCONFIGDIR=/tmp/matplotlib
# Set working directory to user's home/app (Standard for spaces)
WORKDIR $HOME/app
# Copy only requirements first to cache dependencies
COPY --chown=user requirements.txt $HOME/app/requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy the rest of the application with correct ownership
COPY --chown=user . $HOME/app
# ensure uploads directory exists and is writable
RUN mkdir -p uploads && chmod 777 uploads
# Run as the user
USER user
# Command to run the application
CMD ["python", "app.py"]