abdullahalioo commited on
Commit
3c03305
·
verified ·
1 Parent(s): 6a26007

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +43 -0
Dockerfile ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ # Set working directory
4
+ WORKDIR /app
5
+
6
+ # Install system dependencies
7
+ RUN apt-get update && \
8
+ apt-get install -y --no-install-recommends \
9
+ build-essential \
10
+ git \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Create and set cache directory
14
+ RUN mkdir -p /tmp/hf_home && \
15
+ chmod -R 777 /tmp/hf_home
16
+
17
+ # Set environment variables
18
+ ENV HF_HOME=/tmp/hf_home
19
+ ENV TRANSFORMERS_CACHE=/tmp/hf_home
20
+ ENV HUGGINGFACE_HUB_CACHE=/tmp/hf_home
21
+
22
+ # Copy requirements first
23
+ COPY requirements.txt .
24
+
25
+ # Install Python dependencies
26
+ RUN pip install --upgrade pip && \
27
+ pip install --no-cache-dir -r requirements.txt
28
+
29
+ # Copy application code
30
+ COPY . .
31
+
32
+ # Create non-root user
33
+ RUN useradd -m myuser && \
34
+ chown -R myuser /app && \
35
+ chown -R myuser /tmp/hf_home
36
+
37
+ USER myuser
38
+
39
+ # Expose port
40
+ EXPOSE 7860
41
+
42
+ # Run the app
43
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]