File size: 1,180 Bytes
046a9c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.9-slim

# Set working directory
WORKDIR /app

# Set environment variables first
ENV TRANSFORMERS_CACHE=/tmp/transformers
ENV HF_HOME=/tmp/huggingface
ENV TORCH_HOME=/tmp/torch
ENV HUGGINGFACE_HUB_CACHE=/tmp/huggingface/hub
ENV PYTHONPATH=/app
ENV FLASK_APP=app.py
ENV FLASK_ENV=production

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git curl wget build-essential \
    libgl1-mesa-dev libglib2.0-0 \
    libsm6 libxext6 libxrender-dev \
    libgomp1 libgcc-s1 ffmpeg \
    && rm -rf /var/lib/apt/lists/*

# Create cache directories with proper permissions
RUN mkdir -p /tmp/transformers /tmp/huggingface /tmp/torch && \
    chmod -R 777 /tmp/

# Copy application files
COPY . .

# Install minimal dependencies only
RUN pip install --no-cache-dir --upgrade pip && \
    pip install Flask==2.3.3 pillow>=10.0.0 && \
    pip install requests>=2.31.0 loguru

# Expose port
EXPOSE 7860

# Simple health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
    CMD curl -f http://localhost:7860/health || exit 1

# Run with simple python command
CMD ["python", "app.py"]