File size: 1,038 Bytes
21439bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5d55ef2
21439bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Use a slim Python base image
FROM python:3.10-slim

# Create a non-root user (UID 1000) to match Spaces runtime
RUN useradd -m -u 1000 user

# Set environment vars for the non-root user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Set working directory
WORKDIR /home/user/app

# Copy only requirements first (for layer caching)
COPY --chown=user requirements.txt ./

# Switch to root to install system build dependencies
USER root
RUN apt-get update \
 && apt-get install -y --no-install-recommends \
      build-essential \
      cmake \
      git \
      python3-dev \
      libffi-dev \
 && rm -rf /var/lib/apt/lists/*

# Switch back to non-root user for pip install
USER user
RUN pip install --upgrade pip \
 && pip install --no-cache-dir -r requirements.txt

# Copy the rest of your application code
COPY --chown=user . ./

# Expose the port your app runs on
EXPOSE 7860

# Launch the Gradio app on 0.0.0.0 so it's reachable externally
CMD ["python", "app.py", "--server_port", "7860", "--server_name", "0.0.0.0"]