File size: 1,068 Bytes
9d688be
 
8d5f1ef
 
 
 
 
 
9d688be
 
8d5f1ef
 
 
 
 
 
 
 
9d688be
 
 
 
 
 
8d5f1ef
 
 
 
9d688be
 
8d5f1ef
 
 
 
 
 
 
9d688be
8d5f1ef
 
5d39f5a
8d5f1ef
1465638
9d688be
8d5f1ef
9d688be
 
8d5f1ef
9d688be
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
47
48
49
50
FROM python:3.11-slim

# Create user (required for Hugging Face security)
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"

# Set working directory
WORKDIR /app

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV TF_CPP_MIN_LOG_LEVEL=3
ENV CUDA_VISIBLE_DEVICES=-1

# Install system dependencies (switch to root temporarily)
USER root
RUN apt-get update && apt-get install -y \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libgomp1 \
    libgtk-3-0 \
    libjpeg-dev \
    libpng-dev \
    ffmpeg \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Switch back to user
USER user

# Copy requirements and install Python dependencies
COPY --chown=user:user requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY --chown=user:user . /app

# Create necessary directories
RUN mkdir -p app/static app/templates flask_session

# Expose Hugging Face port
EXPOSE 7860

# Run the application
CMD ["python", "app.py"]