File size: 977 Bytes
ca25ed2
d313bbf
ca25ed2
 
 
 
 
 
c06eaa7
ca25ed2
 
 
 
 
 
3782f93
 
ca25ed2
 
 
 
 
 
 
 
 
 
 
 
 
3782f93
ca25ed2
 
3782f93
 
 
 
 
 
 
 
 
 
5419d77
3782f93
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
# Use an official Python runtime as a parent image
FROM python:3.12-slim

# Set the working directory in the container
WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    libgl1 \
    libglib2.0-0 \
    && rm -rf /var/lib/apt/lists/*

# Copy the requirements file
COPY requirements.txt requirements.txt

# Install Python packages with timeout increase
RUN pip install --no-cache-dir --timeout=1000 -r requirements.txt

# Copy application code
COPY . /app

# Create a non-root user
RUN useradd -m -u 1000 user

# Change ownership
RUN chown -R user:user /app

# Switch to the non-root user
USER user

# Expose the port
EXPOSE 7860

# Set environment variables
ENV FLASK_HOST=0.0.0.0
ENV FLASK_PORT=7860
ENV FLASK_DEBUG=False

# CRITICAL: Set HF-specific env vars
ENV TRANSFORMERS_CACHE=/tmp/transformers_cache
ENV HF_HOME=/tmp/hf_home
ENV TORCH_HOME=/tmp/torch_home

# Command to run the app
CMD ["python", "app.py"]