Anirudh Esthuri commited on
Commit
14aec40
·
1 Parent(s): 1dbbeef

Fix: Handle empty PORT env var with default value 7860

Browse files
Files changed (2) hide show
  1. Dockerfile +2 -2
  2. app.py +2 -3
Dockerfile CHANGED
@@ -47,5 +47,5 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
47
  CMD curl --fail http://localhost:${PORT:-7860}/_stcore/health || exit 1
48
 
49
  # Run Streamlit app using PORT env var from Hugging Face Spaces
50
- # HuggingFace sets $PORT, don't override it.
51
- CMD ["bash", "-c", "streamlit run app.py --server.address=0.0.0.0 --server.port=$PORT --server.headless=true"]
 
47
  CMD curl --fail http://localhost:${PORT:-7860}/_stcore/health || exit 1
48
 
49
  # Run Streamlit app using PORT env var from Hugging Face Spaces
50
+ # HuggingFace sets $PORT, don't override it. Default to 7860 if not set.
51
+ CMD ["bash", "-c", "streamlit run app.py --server.address=0.0.0.0 --server.port=${PORT:-7860} --server.headless=true"]
app.py CHANGED
@@ -7,9 +7,8 @@ from llm import chat, set_model
7
  from model_config import MODEL_CHOICES, MODEL_TO_PROVIDER
8
 
9
  # Configure Streamlit for Hugging Face Spaces
10
- # Use PORT env var if provided (Hugging Face Spaces sets this), otherwise default to 7860
11
- port = os.getenv("PORT", "7860")
12
- os.environ["STREAMLIT_SERVER_PORT"] = port
13
  os.environ["STREAMLIT_SERVER_ADDRESS"] = "0.0.0.0"
14
 
15
 
 
7
  from model_config import MODEL_CHOICES, MODEL_TO_PROVIDER
8
 
9
  # Configure Streamlit for Hugging Face Spaces
10
+ # Port is set via command line argument in Dockerfile
11
+ # Don't set STREAMLIT_SERVER_PORT here to avoid conflicts
 
12
  os.environ["STREAMLIT_SERVER_ADDRESS"] = "0.0.0.0"
13
 
14