File size: 1,338 Bytes
219a131
 
e66bea6
219a131
 
 
 
 
12ff843
219a131
 
12ff843
eb46e0a
12ff843
 
 
 
219a131
e66bea6
 
219a131
e66bea6
 
eb46e0a
 
 
219a131
 
 
 
e66bea6
219a131
 
e66bea6
219a131
e66bea6
219a131
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 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"]