saeid1999 commited on
Commit
d6c84d1
·
verified ·
1 Parent(s): e6775e7

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +34 -0
Dockerfile ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9-slim
2
+
3
+ # Set environment variables
4
+ ENV PYTHONUNBUFFERED=1
5
+ ENV PYTHONDONTWRITEBYTECODE=1
6
+
7
+ # Install system dependencies and create user in one layer
8
+ RUN apt-get update && apt-get install -y \
9
+ build-essential \
10
+ curl \
11
+ && rm -rf /var/lib/apt/lists/* \
12
+ && useradd -m -u 1000 user
13
+
14
+ # Set work directory
15
+ WORKDIR /home/user/app
16
+
17
+ # Copy requirements and install packages
18
+ COPY requirements.txt .
19
+ RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
20
+ pip install --no-cache-dir -r requirements.txt
21
+
22
+ # Copy application code and set ownership
23
+ COPY . .
24
+ RUN chown -R user:user /home/user/app
25
+
26
+ # Switch to user and create data directory
27
+ USER user
28
+ RUN mkdir -p data
29
+
30
+ # Expose port
31
+ EXPOSE 7860
32
+
33
+ # Use uvicorn directly
34
+ CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]