File size: 1,381 Bytes
bd2d8ae
 
 
 
 
 
e384a9f
 
 
 
f843516
 
7c8555b
bd2d8ae
 
 
 
 
 
 
 
 
 
 
f843516
 
 
7c8555b
bd2d8ae
f843516
 
9bb1e22
f843516
 
9bb1e22
bd2d8ae
e384a9f
 
f843516
 
 
 
 
 
e384a9f
 
 
f843516
bd2d8ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Use the official NVIDIA CUDA image
FROM nvidia/cuda:12.5.1-cudnn-devel-ubuntu20.04

# Set environment variables for non-interactive installation and timezone
ENV DEBIAN_FRONTEND=noninteractive \
    TZ=Europe/Paris

# Set the working directory
WORKDIR /app

# Create a non-root user
RUN useradd -m appuser

# Install system dependencies and Python
RUN apt-get update && apt-get install -y \
    python3-pip \
    python3-dev \
    git \
    && rm -rf /var/lib/apt/lists/*

# Install any necessary Python packages (e.g., Flask, transformers, torch, etc.)
COPY requirements.txt requirements.txt
RUN pip3 install --no-cache-dir -r requirements.txt

# Create writable directories for Hugging Face and Triton cache
RUN mkdir -p /workspace/huggingface_cache /home/appuser/.triton && \
    chmod -R 777 /workspace/huggingface_cache /home/appuser/.triton

# Set environment variables for Hugging Face and Triton cache
ENV HF_HOME=/workspace/huggingface_cache
ENV TRITON_CACHE_DIR=/home/appuser/.triton

# Set umask to ensure proper file permissions
RUN umask 002

# Copy the application code into the image
COPY . .

# Change ownership to non-root user
RUN chown -R appuser:appuser /app /workspace/huggingface_cache /home/appuser/.triton

# Switch to non-root user
USER appuser

# Expose the port your application will run on
EXPOSE 7860

# Run the application
CMD ["python3", "app.py"]