File size: 892 Bytes
286d36e
 
 
 
 
 
 
 
 
f3ad87e
 
286d36e
f3ad87e
 
 
 
 
 
 
 
 
 
 
 
 
286d36e
 
 
 
 
 
 
 
 
 
 
 
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
# Use official Python slim image for a leaner base
FROM python:3.11-slim

# Set working directory
WORKDIR /app

# Copy requirements file first to leverage Docker cache
COPY requirements.txt .

# Update apt-get with retries and install system dependencies
RUN apt-get update --fix-missing && apt-get install -y --no-install-recommends \
    gcc \
    build-essential \
    libpython3.11-dev \
    && rm -rf /var/lib/apt/lists/*

# Update pip and install pip-tools
RUN pip install --no-cache-dir --upgrade pip \
    && pip install --no-cache-dir pip-tools

# Sync dependencies with pip-sync
RUN pip-sync requirements.txt

# Install Gradio
RUN pip install --no-cache-dir gradio

# Copy the rest of the application code
COPY . .

# Expose Gradio default port
EXPOSE 7860

# Set environment variable to prevent Python buffering
ENV PYTHONUNBUFFERED=1

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