yeonjin98 commited on
Commit
da9d55b
·
verified ·
1 Parent(s): 530fb78

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -0
Dockerfile ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dockerfile for Hugging Face Spaces or other cloud deployments
2
+ FROM python:3.10-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
+ g++ \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Copy requirements and install Python packages
14
+ COPY requirements.txt .
15
+ RUN pip install --no-cache-dir -r requirements.txt
16
+
17
+ # Copy application files
18
+ COPY server_birefnet.py .
19
+
20
+ # Create a non-root user
21
+ RUN useradd -m -u 1000 user && chown -R user:user /app
22
+ USER user
23
+
24
+ # Expose port (7860 for Hugging Face Spaces, 8000 for general use)
25
+ EXPOSE 7860
26
+
27
+ # Health check
28
+ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
29
+ CMD python -c "import requests; requests.get('http://localhost:7860/health')" || exit 1
30
+
31
+ # Run the application
32
+ CMD ["uvicorn", "server_birefnet:app", "--host", "0.0.0.0", "--port", "7860"]