File size: 1,442 Bytes
ec1b552
 
 
 
 
 
 
 
 
 
 
 
 
 
4905514
ec1b552
 
4905514
ec1b552
 
4905514
 
 
ec1b552
 
4905514
ec1b552
 
4905514
ec1b552
4905514
 
ec1b552
 
4905514
ec1b552
 
4905514
 
 
ec1b552
 
 
 
 
 
 
 
 
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 an official Python runtime as a parent image
FROM python:3.10-slim

# Install git as root
RUN apt-get update && \
    apt-get install -y wget gnupg nmap && \
    # Add the LLVM repository for clang
    wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
    echo "deb http://apt.llvm.org/bullseye/ llvm-toolchain-bullseye-15 main" > /etc/apt/sources.list.d/llvm-toolchain.list && \
    apt-get update && \
    apt-get install -y git cmake clang && \
    rm -rf /var/lib/apt/lists/*

# Create a non-root user (do this as root)
RUN useradd -ms /bin/bash user

# Set the working directory as root before switching users
WORKDIR /home/user/app

# Copy files and change permissions as root
COPY requirements.txt /home/user/app/requirements.txt
COPY setup.sh /home/user/app/setup.sh
RUN chmod +x /home/user/app/setup.sh

# Install Python dependencies as root
RUN pip install --no-cache-dir -r /home/user/app/requirements.txt

# Run setup.sh as root (if it needs elevated privileges)
RUN /home/user/app/setup.sh

# Change ownership of the directory to user
RUN chown -R user:user /home/user/app

# Switch to the non-root user
USER user


RUN ls /home/user/app
# Copy the rest of the application code to the container (as user)
COPY . /home/user/app

# Expose the necessary port
EXPOSE 7860

# Set environment variable for Gradio
ENV GRADIO_SERVER_NAME="0.0.0.0"

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