Nihar Shah commited on
Commit
aa08e8d
·
1 Parent(s): bcb55c1

Critical: Fix port configuration for HuggingFace Spaces (use port 7860 instead of 8000)

Browse files
Files changed (2) hide show
  1. Dockerfile +6 -5
  2. app.py +1 -0
Dockerfile CHANGED
@@ -16,13 +16,14 @@ RUN pip install --no-cache-dir -r requirements.txt
16
  # Copy app code
17
  COPY app/ ./app/
18
  COPY openenv.yaml .
 
19
 
20
- # Expose port
21
- EXPOSE 8000
22
 
23
  # Health check
24
  HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
25
- CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
26
 
27
- # Run FastAPI app
28
- CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
 
16
  # Copy app code
17
  COPY app/ ./app/
18
  COPY openenv.yaml .
19
+ COPY app.py .
20
 
21
+ # Expose port 7860 for Hugging Face Spaces
22
+ EXPOSE 7860
23
 
24
  # Health check
25
  HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
26
+ CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/health')" || exit 1
27
 
28
+ # Run FastAPI app on port 7860 for HF Spaces compatibility
29
+ CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
app.py CHANGED
@@ -8,4 +8,5 @@ from app.main import app
8
 
9
  if __name__ == "__main__":
10
  import uvicorn
 
11
  uvicorn.run(app, host="0.0.0.0", port=7860)
 
8
 
9
  if __name__ == "__main__":
10
  import uvicorn
11
+ # HF Spaces uses port 7860 by default
12
  uvicorn.run(app, host="0.0.0.0", port=7860)