Swapnilbpatil commited on
Commit
d1436c2
·
verified ·
1 Parent(s): b95ead8

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +37 -0
Dockerfile ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use Python 3.9 as base image
2
+ FROM python:3.9-slim
3
+
4
+ # Set working directory
5
+ WORKDIR /app
6
+
7
+ # Add user for security
8
+ RUN useradd -m -u 1000 user
9
+
10
+ # Copy requirements file first to leverage Docker cache
11
+ COPY requirements.txt .
12
+
13
+ # Install dependencies
14
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
15
+
16
+ # Copy the application files
17
+ COPY . /app
18
+
19
+ # Create necessary directories with correct permissions
20
+ RUN mkdir -p static/images && \
21
+ chown -R user:user /app
22
+
23
+ # Switch to non-root user
24
+ USER user
25
+
26
+ # Environment variable to prevent Python from writing .pyc files
27
+ ENV PYTHONDONTWRITEBYTECODE=1
28
+ # Environment variable to prevent Python from buffering stdout and stderr
29
+ ENV PYTHONUNBUFFERED=1
30
+ # Path config for user-installed packages
31
+ ENV PATH="/home/user/.local/bin:$PATH"
32
+
33
+ # Expose the port the app runs on
34
+ EXPOSE 7860
35
+
36
+ # Command to run the application using Uvicorn
37
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]