abdullahalioo commited on
Commit
3a6ecdf
·
verified ·
1 Parent(s): 1f075b2

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -9
Dockerfile CHANGED
@@ -1,16 +1,39 @@
1
- FROM python:3.10
 
2
 
3
- # Set working directory inside container
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  WORKDIR /app
5
 
6
- # Copy requirements first (for faster build cache)
7
- COPY requirements.txt .
8
 
9
  # Install Python dependencies
10
- RUN pip install -r requirements.txt
 
 
 
 
11
 
12
- # Copy the entire project into container
13
- COPY . .
14
 
15
- # Run FastAPI with uvicorn
16
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]
 
1
+ # Use NVIDIA CUDA base image
2
+ FROM nvidia/cuda:12.1.1-base-ubuntu22.04
3
 
4
+ # Install system dependencies
5
+ RUN apt-get update && apt-get install -y \
6
+ python3.10 \
7
+ python3-pip \
8
+ git \
9
+ && rm -rf /var/lib/apt/lists/*
10
+
11
+ # Create a non-root user and working directory
12
+ RUN useradd -m appuser && \
13
+ mkdir -p /app && \
14
+ chown appuser:appuser /app
15
+
16
+ # Set environment variables for Hugging Face cache
17
+ ENV TRANSFORMERS_CACHE=/app/model_cache \
18
+ HF_HOME=/app/huggingface \
19
+ XDG_CACHE_HOME=/app/cache
20
+
21
+ # Switch to non-root user
22
+ USER appuser
23
  WORKDIR /app
24
 
25
+ # Create cache directories
26
+ RUN mkdir -p $TRANSFORMERS_CACHE $HF_HOME $XDG_CACHE_HOME
27
 
28
  # Install Python dependencies
29
+ COPY --chown=appuser:appuser requirements.txt .
30
+ RUN pip install --no-cache-dir -r requirements.txt
31
+
32
+ # Copy application code
33
+ COPY --chown=appuser:appuser . .
34
 
35
+ # Expose port (7860 in your error, adjust if needed)
36
+ EXPOSE 7860
37
 
38
+ # Run FastAPI
39
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]