ranranrunforit commited on
Commit
a946183
·
verified ·
1 Parent(s): 509c53b

Upload 33 files

Browse files
Files changed (3) hide show
  1. Dockerfile +3 -3
  2. requirements.txt +2 -0
  3. server.py +12 -14
Dockerfile CHANGED
@@ -3,7 +3,6 @@ FROM python:3.11-slim
3
  RUN useradd -m -u 1000 user
4
  WORKDIR /app
5
 
6
- # system deps for building wheels if needed
7
  RUN apt-get update && apt-get install -y --no-install-recommends \
8
  build-essential git curl && rm -rf /var/lib/apt/lists/*
9
 
@@ -15,7 +14,8 @@ USER user
15
 
16
  ENV HOME=/home/user \
17
  PATH=/home/user/.local/bin:$PATH \
18
- AUTO_LOAD_MODEL=1
 
19
 
20
  EXPOSE 7860
21
- CMD ["python", "app.py"]
 
3
  RUN useradd -m -u 1000 user
4
  WORKDIR /app
5
 
 
6
  RUN apt-get update && apt-get install -y --no-install-recommends \
7
  build-essential git curl && rm -rf /var/lib/apt/lists/*
8
 
 
14
 
15
  ENV HOME=/home/user \
16
  PATH=/home/user/.local/bin:$PATH \
17
+ AUTO_LOAD_MODEL=1 \
18
+ PORT=7860
19
 
20
  EXPOSE 7860
21
+ CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "7860"]
requirements.txt CHANGED
@@ -1,4 +1,6 @@
1
  gradio==6.17.3
 
 
2
  pandas>=2.0
3
  numpy>=1.24
4
  pyarrow>=14
 
1
  gradio==6.17.3
2
+ uvicorn[standard]>=0.27
3
+ fastapi>=0.110
4
  pandas>=2.0
5
  numpy>=1.24
6
  pyarrow>=14
server.py CHANGED
@@ -269,26 +269,24 @@ async def send_email(req: Request):
269
  return JSONResponse({"status": status})
270
 
271
 
272
- # ───────────────────────── static frontend ─────────────────────────
273
- # Mounted last so /api/* wins. html=True serves index.html at /.
274
- app.mount("/", StaticFiles(directory=UI_DIR, html=True), name="ui")
275
-
276
-
277
  # ───────────────────────── startup ─────────────────────────
278
- @app.on_event("startup")
279
- def _startup():
280
- automation.start_scheduler()
 
 
281
  if os.environ.get("AUTO_LOAD_MODEL", "1") == "1":
282
  import threading
283
  threading.Thread(target=llm_local.auto_load_all, daemon=True).start()
284
 
285
 
286
- def launch():
287
- app.launch(
288
- server_name=os.environ.get("GRADIO_SERVER_NAME", "0.0.0.0"),
289
- server_port=int(os.environ.get("GRADIO_SERVER_PORT", os.environ.get("PORT", "7860"))),
290
- )
291
 
 
 
292
 
293
  if __name__ == "__main__":
294
- launch()
 
 
 
269
  return JSONResponse({"status": status})
270
 
271
 
 
 
 
 
 
272
  # ───────────────────────── startup ─────────────────────────
273
+ def _boot():
274
+ try:
275
+ automation.start_scheduler()
276
+ except Exception:
277
+ pass
278
  if os.environ.get("AUTO_LOAD_MODEL", "1") == "1":
279
  import threading
280
  threading.Thread(target=llm_local.auto_load_all, daemon=True).start()
281
 
282
 
283
+ # Static frontend mounted LAST so /api/* and /download/* win.
284
+ app.mount("/", StaticFiles(directory=UI_DIR, html=True), name="ui")
 
 
 
285
 
286
+ # Boot background services at import time (uvicorn serves `app` directly).
287
+ _boot()
288
 
289
  if __name__ == "__main__":
290
+ import uvicorn
291
+ uvicorn.run(app, host="0.0.0.0",
292
+ port=int(os.environ.get("PORT", "7860")))