File size: 1,417 Bytes
99f5777
ca26ae2
963b33c
ba60a03
 
3f84c0a
974a821
 
 
6cfbd2a
 
 
8a3b1d6
 
 
 
 
 
 
716770e
 
 
974a821
99f5777
974a821
5e4985f
 
 
ca26ae2
 
d5de85c
 
5e4985f
0ecb388
36389f5
 
eb762e0
 
 
 
963b33c
 
 
c84ad76
 
716770e
 
a8516bf
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
# Use NVIDIA CUDA image as the parent image
FROM nvidia/cuda:11.8.0-cudnn8-devel-ubuntu20.04

# Set the working directory inside the container
WORKDIR /app

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

# Set noninteractive mode to skip prompts
ENV DEBIAN_FRONTEND=noninteractive

# Install Python and pip
RUN apt-get update && apt-get install -y --no-install-recommends \
    python3 \
    python3-pip \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Copy the requirements file into the container at /app
COPY ./requirements.txt /app/

# Grant necessary permissions to the non-root user
RUN chown -R appuser /app

# Switch to the non-root user
USER appuser

# Install Python dependencies and add necessary directories to PATH
RUN python3 -m pip install --user --no-cache-dir --upgrade pip && \
    python3 -m pip install --user --no-cache-dir -r requirements.txt uvicorn && \
    hash -r

# Add necessary directories to PATH
ENV PATH="/home/appuser/.local/bin:${PATH}"


# Explicitly add the scripts directory to PATH
ENV PATH="/home/appuser/.local/bin:/home/appuser/.local/scripts:${PATH}"

# Copy the current directory contents into the container at /app
COPY . /app/

# Create a writable cache directory inside the /app directory
RUN mkdir -p /app/.cache && chmod -R 777 /app/.cache

# Specify the command to run your application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]