Really-amin commited on
Commit
ff8f8bb
·
verified ·
1 Parent(s): db06919

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -14
Dockerfile CHANGED
@@ -1,13 +1,14 @@
1
  FROM python:3.11-slim
2
 
3
- # Environment variables
4
  ENV PYTHONUNBUFFERED=1 \
5
  PYTHONDONTWRITEBYTECODE=1 \
6
  PIP_NO_CACHE_DIR=1 \
7
  PIP_DISABLE_PIP_VERSION_CHECK=1 \
8
- ENABLE_AUTO_DISCOVERY=false
 
9
 
10
- # System dependencies (gcc + curl for healthcheck)
11
  RUN apt-get update && apt-get install -y \
12
  gcc \
13
  curl \
@@ -16,22 +17,22 @@ RUN apt-get update && apt-get install -y \
16
  # Workdir
17
  WORKDIR /app
18
 
19
- # Python deps
20
  COPY requirements.txt .
21
  RUN pip install --no-cache-dir -r requirements.txt
22
 
23
- # App code
24
  COPY . .
25
 
26
- # Logs dir
27
- RUN mkdir -p logs
28
 
29
- # Ports (HF usually sets PORT=7860)
30
- EXPOSE 8000 7860
 
31
 
32
- # Healthcheck without extra Python deps
33
- HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
34
- CMD curl -f "http://127.0.0.1:${PORT:-8000}/health" || exit 1
35
 
36
- # Run server (FastAPI app is in app.py -> app)
37
- CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port ${PORT:-8000}"]
 
1
  FROM python:3.11-slim
2
 
3
+ # Environment variables for Hugging Face
4
  ENV PYTHONUNBUFFERED=1 \
5
  PYTHONDONTWRITEBYTECODE=1 \
6
  PIP_NO_CACHE_DIR=1 \
7
  PIP_DISABLE_PIP_VERSION_CHECK=1 \
8
+ ENABLE_AUTO_DISCOVERY=false \
9
+ PORT=7860
10
 
11
+ # System dependencies
12
  RUN apt-get update && apt-get install -y \
13
  gcc \
14
  curl \
 
17
  # Workdir
18
  WORKDIR /app
19
 
20
+ # Python dependencies
21
  COPY requirements.txt .
22
  RUN pip install --no-cache-dir -r requirements.txt
23
 
24
+ # Copy all app files
25
  COPY . .
26
 
27
+ # Create necessary directories
28
+ RUN mkdir -p logs data static/css static/js
29
 
30
+ # Healthcheck (uses dynamic PORT)
31
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
32
+ CMD curl -f "http://127.0.0.1:${PORT}/health" || exit 1
33
 
34
+ # Expose Hugging Face default port
35
+ EXPOSE 7860
 
36
 
37
+ # Run with port from environment (HF sets PORT=7860)
38
+ CMD uvicorn app:app --host 0.0.0.0 --port ${PORT}