prshntdxt commited on
Commit
c97b972
·
verified ·
1 Parent(s): 831da65

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +6 -18
Dockerfile CHANGED
@@ -1,10 +1,8 @@
1
- # Use official Python runtime as base image
2
  FROM python:3.11-slim
3
 
4
- # Set working directory in container
5
  WORKDIR /app
6
 
7
- # Install system dependencies (OpenCV, HDF5 support)
8
  RUN apt-get update && apt-get install -y \
9
  libsm6 \
10
  libxext6 \
@@ -13,35 +11,25 @@ RUN apt-get update && apt-get install -y \
13
  pkg-config \
14
  && rm -rf /var/lib/apt/lists/*
15
 
16
- # Copy requirements file
17
- COPY requirements.txt .
18
-
19
  # Install Python dependencies
 
20
  RUN pip install --no-cache-dir -r requirements.txt
21
 
22
  # Copy application code
23
  COPY main.py .
24
- COPY model.py .
25
  COPY schemas.py .
26
  COPY inference/ ./inference/
27
 
28
- # Copy pre-trained model (use .keras format only)
29
  COPY models/Forest_Segmentation_Best.keras ./models/
30
 
31
- # Create logs directory
32
  RUN mkdir -p logs
33
 
34
- # Expose port (Hugging Face Spaces default)
35
  EXPOSE 7860
36
 
37
- # Set environment for production
38
  ENV PYTHONUNBUFFERED=1
39
- ENV PORT=7860
40
- ENV HOST=0.0.0.0
41
-
42
- # Health check
43
- HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
44
- CMD python -c "import requests; requests.get('http://localhost:7860/health')" || exit 1
45
 
46
- # Run FastAPI application with uvicorn
47
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
  FROM python:3.11-slim
2
 
 
3
  WORKDIR /app
4
 
5
+ # System dependencies for TensorFlow / HDF5
6
  RUN apt-get update && apt-get install -y \
7
  libsm6 \
8
  libxext6 \
 
11
  pkg-config \
12
  && rm -rf /var/lib/apt/lists/*
13
 
 
 
 
14
  # Install Python dependencies
15
+ COPY requirements.txt .
16
  RUN pip install --no-cache-dir -r requirements.txt
17
 
18
  # Copy application code
19
  COPY main.py .
 
20
  COPY schemas.py .
21
  COPY inference/ ./inference/
22
 
23
+ # Copy model
24
  COPY models/Forest_Segmentation_Best.keras ./models/
25
 
26
+ # Logs directory
27
  RUN mkdir -p logs
28
 
29
+ # Hugging Face uses 7860
30
  EXPOSE 7860
31
 
 
32
  ENV PYTHONUNBUFFERED=1
 
 
 
 
 
 
33
 
34
+ # Start FastAPI
35
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]