abdullahalioo commited on
Commit
9e88f57
·
verified ·
1 Parent(s): b317162

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -0
Dockerfile ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use official Python slim image for a smaller footprint
2
+ FROM python:3.12-slim
3
+
4
+ # Set environment variables for security and performance
5
+ ENV PYTHONDONTWRITEBYTECODE=1 \
6
+ PYTHONUNBUFFERED=1 \
7
+ PIP_NO_CACHE_DIR=1
8
+
9
+ # Set working directory
10
+ WORKDIR /app
11
+
12
+ # Copy requirements.txt first for caching
13
+ COPY requirements.txt .
14
+
15
+ # Install dependencies
16
+ RUN pip install --no-cache-dir -r requirements.txt
17
+
18
+ # Copy the server code
19
+ COPY app
20
+
21
+ # Create a non-root user for security
22
+ RUN useradd -m appuser && chown -R appuser:appuser /app
23
+ USER appuser
24
+
25
+ # Expose port 8000
26
+ EXPOSE 7860
27
+
28
+ # Command to run the server
29
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]