File size: 1,163 Bytes
1a403bf
 
 
 
ea5dece
 
 
60b5a19
1a403bf
 
 
 
 
 
 
60b5a19
1a403bf
 
60b5a19
 
1a403bf
60b5a19
 
 
ea5dece
 
 
 
 
 
 
 
 
 
 
60b5a19
1a403bf
 
ea5dece
 
 
60b5a19
 
 
 
9b6bf3c
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
40
41
42
43
44
45
46
FROM python:3.9-slim

WORKDIR /app

# Create a non-root user to run the application
RUN useradd -m -u 1000 appuser

# Install system dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    software-properties-common \
    git \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements first for better caching
COPY requirements.txt ./

# Install Python dependencies
RUN pip3 install --no-cache-dir -r requirements.txt

# Copy the rest of the application
COPY . .

# Create and set permissions for cache directories
RUN mkdir -p /app/.cache/huggingface /app/.streamlit /app/.config/matplotlib \
    && chown -R appuser:appuser /app

# Set environment variables
ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    TRANSFORMERS_CACHE=/app/.cache/huggingface \
    MPLCONFIGDIR=/app/.config/matplotlib \
    HOME=/app

# Expose the Streamlit port
EXPOSE 8501

# Switch to non-root user
USER appuser

# Add health check
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health || exit 1

# Run the Streamlit application
ENTRYPOINT ["streamlit", "run", "src/app.py", "--server.port=8501", "--server.address=0.0.0.0"]