GodfreyOwino commited on
Commit
bd32dbf
·
verified ·
1 Parent(s): cb78538

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +36 -0
Dockerfile CHANGED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use Python 3.9 slim image for better performance
2
+ FROM python:3.9-slim
3
+
4
+ # Set environment variables
5
+ ENV PYTHONUNBUFFERED=1
6
+ ENV PYTHONDONTWRITEBYTECODE=1
7
+
8
+ # Create user
9
+ RUN useradd -m -u 1000 user
10
+ USER user
11
+
12
+ # Set PATH
13
+ ENV PATH="/home/user/.local/bin:$PATH"
14
+
15
+ # Set working directory
16
+ WORKDIR /app
17
+
18
+ # Copy requirements first for better caching
19
+ COPY --chown=user ./requirements.txt requirements.txt
20
+
21
+ # Install dependencies
22
+ RUN pip install --no-cache-dir --upgrade pip && \
23
+ pip install --no-cache-dir --upgrade -r requirements.txt
24
+
25
+ # Copy application code
26
+ COPY --chown=user . /app
27
+
28
+ # Expose port
29
+ EXPOSE 7860
30
+
31
+ # Health check
32
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
33
+ CMD curl -f http://localhost:7860/health || exit 1
34
+
35
+ # Run the application
36
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]