tes_vero / Dockerfile
omgy's picture
Update Dockerfile
19689ad verified
FROM python:3.10-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
git wget build-essential cmake \
tesseract-ocr libtesseract-dev libleptonica-dev \
libgl1 libglib2.0-0 libsm6 libxrender1 libxext6 \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Copy requirements first
COPY requirements.txt .
# Upgrade pip
RUN pip install --upgrade pip
# Install PyTorch (CPU-only)
RUN pip install torch==2.2.0 torchvision==0.17.0 --index-url https://download.pytorch.org/whl/cpu
# Install Detectron2 build dependencies
RUN pip install setuptools wheel ninja
# Install Detectron2 with no build isolation (so it can see torch)
RUN pip install --no-build-isolation 'git+https://github.com/facebookresearch/detectron2.git@main'
# Install the rest of requirements
RUN pip install --no-cache-dir -r requirements.txt
# Copy app code
COPY . .
# Set environment variables for cache
ENV FVCORE_CACHE=/root/.torch/iopath_cache
ENV TORCH_HOME=/root/.torch
# Create cache directories and download models with proper naming
RUN mkdir -p /root/.torch/iopath_cache/s/dgy9c10wykk4lq4 && \
mkdir -p /root/.torch/iopath_cache/s/u9t7pqwz79q8kw5 && \
chmod -R 777 /root/.torch && \
wget -q --show-progress https://www.dropbox.com/s/dgy9c10wykk4lq4/model_final.pth?dl=1 \
-O /root/.torch/iopath_cache/s/dgy9c10wykk4lq4/model_final.pth && \
wget -q --show-progress https://www.dropbox.com/s/u9t7pqwz79q8kw5/config.yml?dl=1 \
-O /root/.torch/iopath_cache/s/u9t7pqwz79q8kw5/config.yml && \
echo "✓ Model files downloaded successfully"
EXPOSE 8080
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"]