dimension_model / Dockerfile
suryaprakash01's picture
Update Dockerfile
9bd04ba verified
# ================================================
# Base Image
# ================================================
FROM python:3.9-slim
ENV DEBIAN_FRONTEND=noninteractive
# ================================================
# System Dependencies
# ================================================
RUN apt-get update && apt-get install -y \
build-essential \
curl \
git \
python3-dev \
libglib2.0-0 \
libsm6 \
libxrender1 \
libxext6 \
libgl1 \
&& rm -rf /var/lib/apt/lists/*
# ================================================
# Upgrade pip
# ================================================
RUN pip install --upgrade pip
# ================================================
# Install PyTorch CPU (Detectron2-compatible version)
# ================================================
RUN pip install torch==1.13.1+cpu torchvision==0.14.1+cpu --index-url https://download.pytorch.org/whl/cpu
# ================================================
# Install OpenCV and Streamlit
# ================================================
RUN pip install opencv-python streamlit pillow numpy
# ================================================
# Setup configs for Streamlit/Matplotlib in /tmp
# ================================================
ENV HOME=/tmp
ENV STREAMLIT_CONFIG_DIR=/tmp/.streamlit
ENV MPLCONFIGDIR=/tmp/.matplotlib
ENV XDG_CACHE_HOME=/tmp/.cache
RUN mkdir -p /tmp/.streamlit /tmp/.matplotlib /tmp/.cache
# ================================================
# Working Directory
# ================================================
WORKDIR /app
# ================================================
# Copy requirements (optional)
# ================================================
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt || true
# ================================================
# Copy App Code
# ================================================
COPY app.py .
COPY model/ ./model/
# ================================================
# Expose Streamlit Port
# ================================================
EXPOSE 8501
HEALTHCHECK --interval=30s --timeout=3s \
CMD curl --fail http://localhost:8501/_stcore/health || exit 1
# ================================================
# Run the Streamlit Application
# ================================================
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]