Thinking / Dockerfile
mike23415's picture
Update Dockerfile
feea28d verified
raw
history blame
1.07 kB
FROM python:3.9-slim
# System dependencies
RUN apt-get update && apt-get install -y \
git \
gcc \
g++ \
curl \
libopenblas-dev \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Create cache directory
RUN mkdir -p /app/cache && chmod 777 /app/cache
WORKDIR /app
# Environment variables
ENV TRANSFORMERS_CACHE=/app/cache \
HF_HOME=/app/cache \
PYTHONWARNINGS="ignore" \
NPY_NO_DEPRECATED_API=1 \
XDG_CACHE_HOME=/app/cache \
PRELOAD_MODEL=false \
TOKENIZERS_PARALLELISM=false
COPY requirements.txt .
# Install Python deps in order (numpy first)
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir numpy==1.26.4 && \
pip install --no-cache-dir -r requirements.txt
COPY app.py .
EXPOSE 5000
# Healthcheck
HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
CMD curl -f http://localhost:5000/health || exit 1
# Use a single worker to reduce memory pressure
CMD ["gunicorn", "app:app", "--workers=1", "--threads=1", "--timeout=300", "--bind=0.0.0.0:5000"]