SamuelJaja commited on
Commit
ea3018d
·
verified ·
1 Parent(s): 60ae325

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -14
Dockerfile CHANGED
@@ -1,25 +1,39 @@
1
- # Use Python base image
2
- FROM python:3.10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  # Create a non-root user with a home directory
5
- RUN useradd -m appuser
6
 
7
  # Set the working directory
8
  WORKDIR /app
9
 
10
- # Copy requirements and install dependencies
11
  COPY requirements.txt .
12
- RUN pip install --no-cache-dir -r requirements.txt
 
 
 
13
 
14
  # Copy the application code
15
  COPY . .
16
-
17
- # Create and set permissions for the offload directory
18
- RUN mkdir -p /app/offload && chown -R appuser:appuser /app/offload
19
-
20
- # Set environment variables for cache and Hugging Face token
21
- ENV TRANSFORMERS_CACHE=/app/offload
22
- ENV HF_HOME=/app/offload
23
 
24
  # Switch to the non-root user
25
  USER appuser
@@ -27,5 +41,5 @@ USER appuser
27
  # Expose the application port
28
  EXPOSE 8000
29
 
30
- # Run the FastAPI application
31
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
 
1
+ # Use NVIDIA CUDA base image for GPU support
2
+ FROM nvidia/cuda:12.1.0-runtime-ubuntu22.04
3
+
4
+ # Set environment variables
5
+ ENV DEBIAN_FRONTEND=noninteractive
6
+ ENV PYTHONUNBUFFERED=1
7
+ ENV HF_HOME=/app/cache
8
+ ENV TRANSFORMERS_CACHE=/app/cache
9
+
10
+ # Install Python and other dependencies
11
+ RUN apt-get update && apt-get install -y \
12
+ python3 \
13
+ python3-pip \
14
+ python3-dev \
15
+ git \
16
+ && rm -rf /var/lib/apt/lists/*
17
+
18
+ # Set Python alias
19
+ RUN ln -sf /usr/bin/python3 /usr/bin/python
20
 
21
  # Create a non-root user with a home directory
22
+ RUN useradd -m -u 1000 appuser
23
 
24
  # Set the working directory
25
  WORKDIR /app
26
 
27
+ # Copy requirements and install dependencies first (for better caching)
28
  COPY requirements.txt .
29
+ RUN pip3 install --no-cache-dir -r requirements.txt
30
+
31
+ # Create directories with appropriate permissions
32
+ RUN mkdir -p /app/cache && chown -R appuser:appuser /app
33
 
34
  # Copy the application code
35
  COPY . .
36
+ RUN chown -R appuser:appuser /app
 
 
 
 
 
 
37
 
38
  # Switch to the non-root user
39
  USER appuser
 
41
  # Expose the application port
42
  EXPOSE 8000
43
 
44
+ # Run the FastAPI application with log level
45
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000", "--log-level", "info"]