File size: 1,517 Bytes
29e172c
b97cd42
b81ce9f
42970bb
c5db93e
 
b81ce9f
 
 
c0d002d
 
ef3c14e
 
c0d002d
 
 
29e172c
 
b81ce9f
42970bb
c5db93e
 
b81ce9f
b97cd42
 
 
 
 
 
 
 
42970bb
 
 
b97cd42
42970bb
 
 
 
 
b97cd42
42970bb
 
b97cd42
42970bb
 
b97cd42
 
29e172c
 
b97cd42
 
 
4d93b8e
 
b81ce9f
 
29e172c
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
51
52
53
54
55
56
57
58
59
# Use an official CUDA runtime as a parent image
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu20.04

# Set environment variables
ENV DEBIAN_FRONTEND=noninteractive

# Install necessary system dependencies
RUN apt-get update && apt-get install -y \
    cmake \
    libsm6 \
    libxext6 \
    libglib2.0-0 \
    libxrender-dev \
    libgl1-mesa-glx \
    build-essential \
    g++ \
    python3-pip \
    python3-dev \
    && rm -rf /var/lib/apt/lists/*

# Reset noninteractive mode
ENV DEBIAN_FRONTEND=

# Set cache directories for transformers and matplotlib
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface/hub
ENV MPLCONFIGDIR=/app/.cache/matplotlib
ENV XDG_CACHE_HOME=/app/.cache
ENV FONTCONFIG_PATH=/app/.cache/fontconfig

RUN mkdir -p /app/.cache/huggingface/hub /app/.cache/matplotlib /app/.cache/fontconfig

# Set working directory
WORKDIR /app

# Copy the requirements file
COPY requirements.txt .

# Install pip and upgrade it
RUN pip install --upgrade pip

# Install dependencies from requirements.txt
RUN pip install -r requirements.txt

# Install torch, torchvision, and torchaudio with the specified extra index URL
RUN pip install torch==2.0.1+cu118 torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu118

# Ensure the application is run as a non-root user
RUN adduser --disabled-password --gecos '' appuser && chown -R appuser /app
USER appuser

# Copy the rest of the application code
COPY . .

# Expose the port
EXPOSE 7860

# Command to run the app
CMD ["python3", "app.py"]