sentimental_analysis / Dockerfile
shavkatvicc's picture
Update Dockerfile
a533b21 verified
FROM python:3.9-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
git \
&& rm -rf /var/lib/apt/lists/*
# Set environment variables for cache
ENV TRANSFORMERS_CACHE=/app/hf_cache
ENV HF_HOME=/app/hf_cache
ENV HF_DATASETS_CACHE=/app/hf_cache
# Copy dependency list and install Python packages
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# Pre-download the Hugging Face model and tokenizer
RUN python -c "from transformers import AutoTokenizer, AutoModelForSequenceClassification; \
AutoTokenizer.from_pretrained('finiteautomata/bertweet-base-sentiment-analysis', cache_dir='/app/hf_cache'); \
AutoModelForSequenceClassification.from_pretrained('finiteautomata/bertweet-base-sentiment-analysis', cache_dir='/app/hf_cache')"
# Copy app code
COPY app.py ./
# Expose Streamlit port
EXPOSE 8501
# Healthcheck (optional)
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1
# Start Streamlit
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]