Carbaz commited on
Commit
78a89d3
·
1 Parent(s): b63763e

Refactor Dockerfile to streamline build process and update INSTALL_TARGET configuration

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -14
Dockerfile CHANGED
@@ -1,27 +1,42 @@
1
  # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
  # you will also find guides on how best to write your Dockerfile
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  FROM python:3.13
5
 
6
- # Install system utilities
7
- RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
 
8
 
9
  RUN useradd -m -u 1000 user
 
 
 
 
 
 
 
10
  USER user
11
  ENV PATH="/home/user/.local/bin:$PATH"
12
 
13
  WORKDIR /app
14
-
15
- # --- CONFIGURATION ---
16
- # Default is the stable 'gradio' from PyPI.
17
- # Replace with the .whl URL from the PR bot to test changes:
18
- # 1. Go to the Gradio PR on GitHub
19
- # 2. Find the "PR wheel preview build" check at the bottom
20
- # 3. Click "Details" and copy the .whl URL from the logs
21
- ENV INSTALL_TARGET="gradio"
22
- # ENV INSTALL_TARGET="git+https://github.com/Aarnonn/gradio.git@fix/fill-height-empty-footer-12992"
23
-
24
- RUN pip install --no-cache-dir --upgrade ${INSTALL_TARGET}
25
-
26
  COPY --chown=user . /app
27
  CMD ["python", "app.py"]
 
1
  # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
  # you will also find guides on how best to write your Dockerfile
3
 
4
+ # Configuration
5
+ ARG GRADIO_REPO="https://github.com/Aarnonn/gradio.git"
6
+ ARG GRADIO_BRANCH="fix/fill-height-empty-footer-12992"
7
+
8
+ # Stage 1: Build frontend with Node 24
9
+ FROM node:24 AS builder
10
+
11
+ ARG GRADIO_REPO
12
+ ARG GRADIO_BRANCH
13
+
14
+ RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
15
+ RUN npm install -g pnpm
16
+
17
+ # Clone and build Gradio
18
+ RUN git clone --branch ${GRADIO_BRANCH} ${GRADIO_REPO} /tmp/gradio
19
+ WORKDIR /tmp/gradio
20
+ RUN bash scripts/build_frontend.sh
21
+
22
+ # Stage 2: Runtime with Python
23
  FROM python:3.13
24
 
25
+ ARG GRADIO_REPO
26
+ ARG GRADIO_BRANCH
27
+ ENV INSTALL_TARGET="${GRADIO_REPO}@${GRADIO_BRANCH}"
28
 
29
  RUN useradd -m -u 1000 user
30
+
31
+ # Copy compiled Gradio from builder and install
32
+ COPY --from=builder /tmp/gradio /tmp/gradio
33
+ WORKDIR /tmp/gradio
34
+ RUN pip install --no-cache-dir --upgrade .
35
+ RUN rm -rf /tmp/gradio
36
+
37
  USER user
38
  ENV PATH="/home/user/.local/bin:$PATH"
39
 
40
  WORKDIR /app
 
 
 
 
 
 
 
 
 
 
 
 
41
  COPY --chown=user . /app
42
  CMD ["python", "app.py"]