final_v1 / Dockerfile
amritn8's picture
Update Dockerfile
de234f8 verified
raw
history blame contribute delete
991 Bytes
# Use lightweight Python image
FROM python:3.9-slim
# Set up environment
WORKDIR /app
ENV PYTHONUNBUFFERED=1 \
TRANSFORMERS_CACHE=/app/model_cache \
HF_HOME=/app/model_cache
# Install system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc \
python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Create cache directory with write permissions
RUN mkdir -p /app/model_cache && chmod 777 /app/model_cache
# Copy only necessary files
COPY requirements.txt .
COPY app.py .
# Install Python packages
RUN pip install --no-cache-dir -r requirements.txt && \
python -c "from transformers import pipeline; pipeline('question-answering', model='distilbert-base-uncased-distilled-squad')"
# Expose and run
EXPOSE 8501
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8501/_stcore/health || exit 1
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]