Spaces:
Sleeping
Sleeping
File size: 1,474 Bytes
5a729af 241f993 98bf2c9 241f993 98bf2c9 5a729af 98bf2c9 691c981 5a729af 691c981 241f993 98bf2c9 5a729af 691c981 98bf2c9 691c981 241f993 5a729af 98bf2c9 5a729af 241f993 |
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
FROM python:3.10-slim
WORKDIR /code
# Set environment variables
ENV PIP_NO_CACHE_DIR=1
ENV HOME=/home/user
ENV PYTHONPATH=/code
ENV HF_HOME=/home/user/huggingface
ENV YOLO_CONFIG_DIR=/home/user/ultralytics
# Create non-root user
RUN useradd -m -u 1000 user && \
mkdir -p /home/user && \
chown -R user:user /home/user
# Install system dependencies with cleanup
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
libgl1-mesa-glx \
libglib2.0-0 \
git \
&& apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Create all necessary directories with proper permissions
RUN mkdir -p /tmp/uploads && \
mkdir -p /tmp/results && \
mkdir -p /tmp/models/parts/weights/weights && \
chmod -R 777 /tmp && \
chown -R user:user /tmp && \
mkdir -p /home/user/.cache && \
mkdir -p /home/user/huggingface && \
mkdir -p /home/user/ultralytics && \
chown -R user:user /home/user/.cache && \
chown -R user:user /home/user/huggingface && \
chown -R user:user /home/user/ultralytics
# Copy requirements first
COPY requirements.txt .
# Install dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir setuptools wheel && \
pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY --chown=user:user . .
# Switch to non-root user
USER user
EXPOSE 7860
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|