surbi karki commited on
Commit
a43f1f0
·
verified ·
1 Parent(s): 700d42b

Rename Dockerfile_HF to Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile_HF → Dockerfile +23 -34
Dockerfile_HF → Dockerfile RENAMED
@@ -1,34 +1,23 @@
1
- # Python Backend API for Hugging Face Spaces
2
- FROM python:3.11-slim
3
-
4
- # Set working directory
5
- WORKDIR /app
6
-
7
- # Install system dependencies
8
- RUN apt-get update && apt-get install -y \
9
- gcc \
10
- postgresql-client \
11
- libpq-dev \
12
- && rm -rf /var/lib/apt/lists/*
13
-
14
- # Copy requirements first for better caching
15
- COPY requirements.txt .
16
-
17
- # Install Python dependencies
18
- RUN pip install --no-cache-dir -r requirements.txt
19
-
20
- # Copy application code
21
- COPY . .
22
-
23
- # Create directory for model files
24
- RUN mkdir -p /app/models
25
-
26
- # Hugging Face Spaces default port is 7860
27
- EXPOSE 7860
28
-
29
- # Health check (pointing to the correct port)
30
- HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
31
- CMD python -c "import requests; requests.get('http://localhost:7860/api/health')" || exit 1
32
-
33
- # Run the application on port 7860 as required by HF Spaces
34
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Python Backend API for Hugging Face Spaces
2
+ FROM python:3.11-slim
3
+ # Set working directory
4
+ WORKDIR /app
5
+ # Install system dependencies
6
+ RUN apt-get update && apt-get install -y \
7
+ gcc \
8
+ postgresql-client \
9
+ libpq-dev \
10
+ && rm -rf /var/lib/apt/lists/*
11
+ # Copy requirements first
12
+ COPY requirements.txt .
13
+ RUN pip install --no-cache-dir -r requirements.txt
14
+ # Copy everything else
15
+ COPY --chown=1000 . .
16
+ # Hugging Face specific user setup
17
+ RUN useradd -m -u 1000 user
18
+ USER user
19
+ ENV PATH="/home/user/.local/bin:$PATH"
20
+ # Listen on port 7860
21
+ EXPOSE 7860
22
+ # Point to your main.py
23
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]