khalednabawi11 commited on
Commit
985c437
·
verified ·
1 Parent(s): bc676ba

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +42 -0
Dockerfile ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ ENV PYTHONUNBUFFERED=1
4
+
5
+ WORKDIR /code
6
+
7
+ # Install system dependencies
8
+ RUN apt-get update && apt-get install -y \
9
+ build-essential \
10
+ git \
11
+ curl \
12
+ cmake \
13
+ ninja-build \
14
+ libopenblas-dev \
15
+ && useradd -m appuser \
16
+ && rm -rf /var/lib/apt/lists/*
17
+
18
+ # Copy requirements first to leverage Docker cache
19
+ COPY requirements.txt .
20
+
21
+ # Install Python dependencies
22
+ RUN pip install --no-cache-dir -r requirements.txt
23
+
24
+ # Copy all source code (app.py and related files)
25
+ COPY . /code
26
+
27
+ # Create models and cache directories and set correct ownership
28
+ RUN mkdir -p /code/models/.cache/huggingface && \
29
+ chown -R appuser:appuser /code
30
+
31
+ # Set environment variables
32
+ ENV HOST=0.0.0.0
33
+ ENV PORT=7860
34
+
35
+ # Expose the FastAPI port
36
+ EXPOSE 7860
37
+
38
+ # Switch to non-root user
39
+ USER appuser
40
+
41
+ # Run the FastAPI app
42
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]