Nikhil Pujari commited on
Commit
7706847
·
1 Parent(s): 6dac1b1

fix: match working OpenEnv space configuration exactly

Browse files

- Restore base_path: /web in README (required by all working OpenEnv spaces)
- Switch HEALTHCHECK from curl to python urllib (curl not in openenv-base)
- Increase start-period from 5s to 30s
- Remove root redirect hack (base_path handles this)
- Keep PYTHONUNBUFFERED=1 and ENABLE_WEB_INTERFACE=true

Files changed (3) hide show
  1. Dockerfile +4 -5
  2. README.md +1 -0
  3. server/app.py +0 -7
Dockerfile CHANGED
@@ -71,13 +71,12 @@ ENV PATH="/app/.venv/bin:$PATH"
71
  # Set PYTHONPATH so imports work correctly
72
  ENV PYTHONPATH="/app/env:$PYTHONPATH"
73
 
74
- # Ensure Python output is unbuffered so HF can detect app startup
75
  ENV PYTHONUNBUFFERED=1
76
 
77
- # Disable Docker-level health check; HF Spaces handles readiness detection
78
- HEALTHCHECK NONE
79
-
80
- EXPOSE 8000
81
 
82
  # Run the FastAPI server
83
  ENV ENABLE_WEB_INTERFACE=true
 
71
  # Set PYTHONPATH so imports work correctly
72
  ENV PYTHONPATH="/app/env:$PYTHONPATH"
73
 
74
+ # Set PYTHONUNBUFFERED so startup logs reach HF immediately
75
  ENV PYTHONUNBUFFERED=1
76
 
77
+ # Health check using Python (curl may not be in openenv-base)
78
+ HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
79
+ CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
 
80
 
81
  # Run the FastAPI server
82
  ENV ENABLE_WEB_INTERFACE=true
README.md CHANGED
@@ -5,6 +5,7 @@ colorTo: gray
5
  sdk: docker
6
  pinned: false
7
  app_port: 8000
 
8
  tags:
9
  - openenv
10
  ---
 
5
  sdk: docker
6
  pinned: false
7
  app_port: 8000
8
+ base_path: /web
9
  tags:
10
  - openenv
11
  ---
server/app.py CHANGED
@@ -23,13 +23,6 @@ app = create_app(
23
  )
24
 
25
 
26
- @app.get("/")
27
- async def root():
28
- """Root endpoint for HF Spaces health detection."""
29
- from fastapi.responses import RedirectResponse
30
- return RedirectResponse(url="/web")
31
-
32
-
33
  def main(host: str = "0.0.0.0", port: int = 8000):
34
  """Entry point for direct execution."""
35
  import uvicorn
 
23
  )
24
 
25
 
 
 
 
 
 
 
 
26
  def main(host: str = "0.0.0.0", port: int = 8000):
27
  """Entry point for direct execution."""
28
  import uvicorn