Pipertts / Dockerfile
drewThomasson's picture
Create Dockerfile
23f9b10 verified
# Start from a minimal Debian image
FROM debian:bullseye-slim
# Set NVIDIA environment variables
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
ENV NVIDIA_REQUIRE_CUDA "cuda>=11.8"
ENV LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:$LD_LIBRARY_PATH
# Update and install required packages
RUN apt-get update && apt-get install -y \
gnupg2 curl python3-pip ffmpeg \
libcublas-11-8 libcudnn8=8.6.0.163-1+cuda11.8
# Import NVIDIA repository GPG key
RUN curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/7fa2af80.pub | \
gpg --dearmor -o /usr/share/keyrings/cuda-archive-keyring.gpg
# Add CUDA repository to sources list
RUN echo "deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64 /" > /etc/apt/sources.list.d/cuda.list
# Update package lists
RUN apt-get update
# Install Python dependencies
WORKDIR /app
COPY ./requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt
# Copy application files
COPY ./app.py /app/app.py
COPY ./interface.html /app/interface.html
COPY ./styles.css /app/styles.css
# Create a non-root user for security
RUN useradd -m -u 1000 user
USER user
# Set environment and working directory
ENV HOME=/home/user
WORKDIR $HOME/app
# Copy remaining files
COPY --chown=user . $HOME/app
# Expose the port and run the application
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]