architrawat25 commited on
Commit
1e79b35
·
verified ·
1 Parent(s): f4eac47

added Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -0
Dockerfile ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use official Python runtime optimized for ML
2
+ FROM python:3.11-slim
3
+
4
+ # Set up user (required for HF Spaces security)
5
+ RUN useradd -m -u 1000 user
6
+ USER user
7
+
8
+ # Set environment variables
9
+ ENV PATH="/home/user/.local/bin:$PATH"
10
+ ENV PYTHONPATH="/app:$PYTHONPATH"
11
+
12
+ # Set working directory
13
+ WORKDIR /app
14
+
15
+ # Copy requirements first for better caching
16
+ COPY --chown=user ./requirements.txt requirements.txt
17
+
18
+ # Install Python dependencies
19
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
20
+
21
+ # Copy application code and model
22
+ COPY --chown=user . /app
23
+
24
+ # Expose the port that HF Spaces expects
25
+ EXPOSE 7860
26
+
27
+ # Health check
28
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
29
+ CMD curl -f http://localhost:7860/health || exit 1
30
+
31
+ # Command to run the application
32
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]