chenx906 commited on
Commit
7ed8f5e
·
1 Parent(s): 12bb355

Fix the deployment space problem

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -15
Dockerfile CHANGED
@@ -1,36 +1,32 @@
1
  FROM python:3.9-slim
2
 
3
- # Create user to avoid permission issues on Hugging Face Spaces
4
  RUN useradd -m -u 1000 user
5
-
6
  WORKDIR /app
7
 
8
- # === Install dependencies ===
9
  COPY requirements.txt .
10
  RUN pip install --no-cache-dir -r requirements.txt
11
  RUN pip install fastapi uvicorn python-multipart requests
12
 
13
- # === Copy backend (app + model + data) ===
14
- COPY app.py ./app.py
15
- COPY scripts/ ./scripts/
16
- COPY checkpoints/ ./checkpoints/
17
- COPY data/ ./data/
18
 
19
- # === Copy API code ===
20
- COPY api/app.py api/app.py
 
21
 
22
- # === Copy UI last (so UI updates bust cache) ===
23
  RUN mkdir -p ui
24
  COPY ui/ ./ui/
25
 
26
- # Optional cache-buster so HF rebuilds UI layer
27
  RUN echo "UI_BUILD_TS=$(date +%s)" > /app/ui/.buildtag
28
 
29
- # === Permissions & user ===
30
  RUN chown -R user:user /app
31
  USER user
32
-
33
  EXPOSE 7860
34
 
35
- # === Start FastAPI ===
36
  CMD ["uvicorn", "api.app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  FROM python:3.9-slim
2
 
3
+ # --- 1. Create user and working directory ---
4
  RUN useradd -m -u 1000 user
 
5
  WORKDIR /app
6
 
7
+ # --- 2. Install dependencies ---
8
  COPY requirements.txt .
9
  RUN pip install --no-cache-dir -r requirements.txt
10
  RUN pip install fastapi uvicorn python-multipart requests
11
 
12
+ # --- 3. Copy your backend code ---
13
+ COPY --chown=user:user . .
 
 
 
14
 
15
+ # --- 4. Create API directory and copy your app.py into it ---
16
+ RUN mkdir -p api
17
+ COPY app.py api/app.py
18
 
19
+ # --- 5. Copy UI (last to force rebuild when changed) ---
20
  RUN mkdir -p ui
21
  COPY ui/ ./ui/
22
 
23
+ # Optional: small cache-buster to ensure rebuilds update UI
24
  RUN echo "UI_BUILD_TS=$(date +%s)" > /app/ui/.buildtag
25
 
26
+ # --- 6. Permissions and start ---
27
  RUN chown -R user:user /app
28
  USER user
 
29
  EXPOSE 7860
30
 
31
+ # --- 7. Run FastAPI ---
32
  CMD ["uvicorn", "api.app:app", "--host", "0.0.0.0", "--port", "7860"]