coderuday21 commited on
Commit
7186eb1
·
1 Parent(s): 7496827

HF runtime fix: bind uvicorn to dynamic PORT env

Browse files
Files changed (1) hide show
  1. Dockerfile +4 -5
Dockerfile CHANGED
@@ -26,7 +26,7 @@ WORKDIR /app
26
 
27
  # Build-time info + cache-bust:
28
  # Changing APP_BUILD forces Docker to re-run subsequent layers (including pip install).
29
- ARG APP_BUILD=10
30
  ENV APP_BUILD=${APP_BUILD}
31
  RUN echo "Docker build start: APP_BUILD=${APP_BUILD}" && python -V
32
 
@@ -43,10 +43,9 @@ RUN mkdir -p data/overlays && chown -R appuser:appuser /app
43
 
44
  USER appuser
45
 
46
- # HF Spaces expects port 7860.
47
  ENV PORT=7860
48
- ENV PYTHONUNBUFFERED=1
49
  EXPOSE 7860
50
 
51
- # Use direct exec form so container startup is simpler and logs flush reliably.
52
- CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "info"]
 
26
 
27
  # Build-time info + cache-bust:
28
  # Changing APP_BUILD forces Docker to re-run subsequent layers (including pip install).
29
+ ARG APP_BUILD=11
30
  ENV APP_BUILD=${APP_BUILD}
31
  RUN echo "Docker build start: APP_BUILD=${APP_BUILD}" && python -V
32
 
 
43
 
44
  USER appuser
45
 
46
+ # HF Spaces generally uses 7860, but binding to $PORT is safer.
47
  ENV PORT=7860
 
48
  EXPOSE 7860
49
 
50
+ # Bind to runtime PORT so health checks always reach the server.
51
+ CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-7860} --log-level info"]