amitbhatt6075 commited on
Commit
293d75c
Β·
1 Parent(s): d2020f6

fix: Use dynamic from platform in Docker CMD

Browse files
Files changed (2) hide show
  1. Dockerfile +7 -5
  2. README.md +0 -1
Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- # Start with the official Python 3.11 image (the full version, not slim)
2
  FROM python:3.11
3
 
4
  # Set the working directory inside the container
@@ -20,8 +20,10 @@ RUN pip install --no-cache-dir --upgrade -r requirements.txt
20
  # Copy the rest of your application code
21
  COPY . .
22
 
23
- # Expose the port the app will run on (Hugging Face uses 7860)
24
- EXPOSE 7860
25
 
26
- # Command to run the application using uvicorn
27
- CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
1
+ # Start with the official Python 3.11 image
2
  FROM python:3.11
3
 
4
  # Set the working directory inside the container
 
20
  # Copy the rest of your application code
21
  COPY . .
22
 
23
+ # EXPOSE the PORT variable that will be provided by Hugging Face
24
+ EXPOSE ${PORT}
25
 
26
+ # βœ… THE FINAL FIX IS HERE
27
+ # Command to run the application using the PORT provided by the platform environment
28
+ # If $PORT is not set, it will default to 7860 for local testing
29
+ CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "${PORT:-7860}"]
README.md CHANGED
@@ -4,7 +4,6 @@ emoji: πŸš€
4
  colorFrom: indigo
5
  colorTo: purple
6
  sdk: docker
7
- app_port: 7860
8
  pinned: false
9
  license: mit
10
  ---
 
4
  colorFrom: indigo
5
  colorTo: purple
6
  sdk: docker
 
7
  pinned: false
8
  license: mit
9
  ---