File size: 861 Bytes
1b76b5d
 
 
 
 
 
ad184b5
63bd460
 
 
 
 
9240df3
 
22a3c8a
9240df3
 
 
22a3c8a
1b76b5d
 
 
 
ad184b5
1b76b5d
 
9240df3
 
 
 
 
 
 
1b76b5d
 
 
 
9240df3
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
# Use an official Python runtime
FROM python:3.10-slim

# Set working directory
WORKDIR /app

# Install dependencies
RUN apt-get update && apt-get install -y \

    build-essential \
    python3-dev \
    && rm -rf /var/lib/apt/lists/*

# Create non-root user to run the app
RUN useradd -m appuser

# Create the cache directory and set proper permissions
RUN mkdir -p /app/cache && \

    chown -R appuser:appuser /app

# Copy app code
COPY app.py /app/app.py
COPY requirements.txt /app/requirements.txt

# Install Python dependencies
RUN pip install --upgrade pip && pip install -r requirements.txt

# Set environment variables for the model caching
ENV TRANSFORMERS_CACHE=/app/cache
ENV HF_HOME=/app/cache

# Switch to non-root user
USER appuser

# Expose the port
EXPOSE 7860

# Start the Flask app
CMD ["python", "app.py"]