File size: 1,030 Bytes
4670dfa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Use a slim Python base image. For GPU, you'd need a CUDA-enabled base.
FROM python:3.9-slim

# Set the working directory in the container
WORKDIR /app

# Install git (useful for some Hugging Face model/tokenizer downloads that might use it)
# Also install common build tools often needed for Python packages
RUN apt-get update && apt-get install -y \
    git \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Copy the requirements file first to leverage Docker layer caching
COPY requirements.txt requirements.txt

# Install Python dependencies
# --no-cache-dir reduces image size
# --prefer-binary can speed up builds for packages with binary distributions
RUN pip install --no-cache-dir --prefer-binary -r requirements.txt

# Copy the application code into the container
COPY app.py app.py

# Expose the port Gradio will run on (default is 7860)
EXPOSE 7860

# Set the default command to run the Gradio application
# Using `python -u` for unbuffered output, which is good for logging
CMD ["python", "-u", "app.py"]