abdullahalioo commited on
Commit
fda80c2
·
verified ·
1 Parent(s): c4f17bd

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +38 -0
Dockerfile ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 build-essential && \
9
+ rm -rf /var/lib/apt/lists/*
10
+
11
+ # Create and set writable cache directories with proper permissions
12
+ RUN mkdir -p /tmp/hf_cache && \
13
+ chmod -R 777 /tmp/hf_cache
14
+
15
+ # Set environment variables for Hugging Face cache
16
+ ENV HF_HOME=/tmp/hf_cache
17
+ ENV TRANSFORMERS_CACHE=/tmp/hf_cache
18
+ ENV HUGGINGFACE_HUB_CACHE=/tmp/hf_cache
19
+
20
+ # Copy requirements first to leverage Docker cache
21
+ COPY requirements.txt .
22
+
23
+ # Install Python dependencies
24
+ RUN pip install --upgrade pip && \
25
+ pip install --no-cache-dir -r requirements.txt
26
+
27
+ # Copy application code
28
+ COPY . .
29
+
30
+ # Expose port
31
+ EXPOSE 7860
32
+
33
+ # Run as non-root user for better security
34
+ RUN useradd -m myuser && chown -R myuser /app
35
+ USER myuser
36
+
37
+ # Run the app
38
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]