Spaces:
Sleeping
Sleeping
surbi karki commited on
Rename Dockerfile_HF to Dockerfile
Browse files- 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 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
# Copy
|
| 15 |
-
COPY
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
#
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 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"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|