# 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"]