FrancescoConte's picture
Edited Dockerfile, gave explicit permissions for streamlit
eb46e0a
# Base image with Python and Streamlit installed
FROM python:3.10-slim
# Avoid interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
# Set environment variables for Streamlit and Hugging Face
ENV HF_HUB_CACHE=/app/hf_cache
ENV HF_HOME=/app/hf_cache
ENV STREAMLIT_SERVER_PORT=8501
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
ENV STREAMLIT_CONFIG_DIR=/app/.streamlit
ENV STREAMLIT_TELEMETRY_DISABLED=true
ENV HOME=/app
RUN mkdir -p /app/.streamlit
# Create working directory
WORKDIR /app
# Copy application files
COPY . /app
# Give permissions to avoid the streamlit permission issue
RUN mkdir -p /app/.streamlit && chmod -R 777 /app/.streamlit
# Install required Python packages
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt \
&& python -c "from transformers import pipeline; pipeline(model='FrancescoConte/FC_finetuning-sentiment-model-3000-samples', task='sentiment-analysis')"
# Expose the required port
EXPOSE 8501
RUN python -c "from transformers import pipeline; pipeline(model='FrancescoConte/FC_finetuning-sentiment-model-3000-samples', task='sentiment-analysis')"
# Final command to launch the app
CMD ["streamlit", "run", "sentiment_huggingface.py", "--server.port=8501", "--server.address=0.0.0.0"]