# read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker # you will also find guides on how best to write your Dockerfile FROM debian:bullseye-slim # Install prerequisites RUN apt-get update -y && \ apt-get install -y apt-transport-https ca-certificates gnupg curl # Add the Cloud SDK distribution URI as a package source RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.asc] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list # Import the Google Cloud public key RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | tee /usr/share/keyrings/cloud.google.asc # Update the package list and install the Google Cloud CLI RUN apt-get update -y && apt-get install -y google-cloud-sdk # You can include additional commands to configure or use the gcloud CLI here # For example, you can authenticate with your service account key file: COPY your-service-account-key.json /tmp/key.json ENV GOOGLE_APPLICATION_CREDENTIALS=/tmp/key.json RUN gcloud auth activate-service-account --key-file=${GOOGLE_APPLICATION_CREDENTIALS} # ... further instructions ... ENV NVIDIA_VISIBLE_DEVICES all ENV NVIDIA_DRIVER_CAPABILITIES compute,utility ENV NVIDIA_REQUIRE_CUDA "cuda>=8.0" ENV LD_LIBRARY_PATH=/usr/local/cuda-11.8/targets/x86_64-linux/lib:/usr/local/cuda-11.8/targets/x86_64-linux/include:/usr/local/cuda/include:/usr/local/cuda-11.8:/usr/local/cuda/lib:/usr/local/cuda/lib64:$LD_LIBRARY_PATH #RUN dpkg --add-architecture amd64 #RUN apt-get update && \ # apt-get install -y --no-install-recommends gnupg2 curl ca-certificates #RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/7fa2af80.pub # Import the NVIDIA GPG key #RUN apt-get update && apt-get install -y gnupg2 curl # Fetch the 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 the NVIDIA repository to the APT sources list #RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub #RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub #RUN echo "deb https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64 /" > /etc/apt/sources.list.d/cuda.list # Install FFmpeg RUN apt-get update && \ apt-get install -y python3-pip ffmpeg #libcublas-11-8 libcudnn8=8.6.0.163-1+cuda11.8 #libcudnn8=8.8.0.121-1+cuda11.8 # Set the working directory to /code WORKDIR /app # Copy the requirements file into the container at /code/ #COPY ./requirements.txt /app/requirements.txt # Copy the FastAP application code into the container COPY ./ /app #COPY ./interface.html /app/interface.html #COPY ./styles.css /app/styles.css # Install the required Python packages from requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # Create a non-root user (optional but recommended for security) RUN useradd -m -u 1000 user # Switch to the non-root user USER user # Define environment variables ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Change the working directory to /home/user/app WORKDIR $HOME/app # Copy the rest of the application files into the container COPY --chown=user . $HOME/app # Expose port 80 for the FastAPI application EXPOSE 7860 # Specify the command to run your application (modify as needed) CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]