objectdetection / Dockerfile
sandbox338's picture
Update Dockerfile
7d0b950 verified
FROM python:3.9-slim
WORKDIR /app
# Set HOME to a writable location
ENV HOME=/app
ENV TORCH_HOME=/tmp/.torch
ENV STREAMLIT_HOME=/tmp/.streamlit
ENV MPLCONFIGDIR=/tmp/mplconfig
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
software-properties-common \
git \
libgl1-mesa-glx \
libglib2.0-0 \
libffi-dev \
libssl-dev \
libbz2-dev \
liblzma-dev \
libreadline-dev \
libsqlite3-dev \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy project files
COPY requirements.txt ./
COPY src/ ./src/
# Install Python dependencies
RUN pip install --upgrade pip && \
pip install "numpy<2.0" && \
pip install -r requirements.txt && \
pip install torchvision==0.15.2 && \
pip install 'git+https://github.com/facebookresearch/detectron2.git'
# Create writable directories
RUN mkdir -p /app/.torch /app/.streamlit /app/.config/matplotlib /tmp && \
chmod -R 777 /app /tmp
EXPOSE 8501
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]