hanszhu's picture
chore(docker): set PYTHONUNBUFFERED=1 for immediate log flushing
e25aace
FROM python:3.10-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1 libglib2.0-0 git libsm6 libxext6 libxrender1 \
&& rm -rf /var/lib/apt/lists/*
ENV PIP_NO_CACHE_DIR=1 \
MPLBACKEND=Agg \
MIM_IGNORE_INSTALL_PYTORCH=1 \
HF_HOME=/data/hf \
HF_CACHE_DIR=/data/hf-cache \
HUGGINGFACE_HUB_CACHE=/data/hf-cache \
MPLCONFIGDIR=/data/matplotlib \
PYTHONPATH=/app:/app/custom_models:$PYTHONPATH \
PYTHONUNBUFFERED=1
RUN mkdir -p /data/hf /data/hf-cache /data/matplotlib && chmod -R 777 /data
WORKDIR /app
COPY requirements.txt /app/requirements.txt
RUN python -m pip install --upgrade pip wheel setuptools openmim \
&& pip install --no-cache-dir -r requirements.txt \
&& pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch==2.1.0 torchvision==0.16.0 \
&& pip install --no-cache-dir 'git+https://github.com/facebookresearch/segment-anything.git' \
&& mim install "mmengine==0.10.4" \
&& mim install "mmcv==2.1.0" \
&& mim install "mmdet==3.3.0"
COPY . /app
# run as non-root user 1000 if available
RUN useradd -m -u 1000 user || true
USER 1000
EXPOSE 7860
CMD ["python", "app.py"]