diff --git a/Dockerfile b/Dockerfile index a32b53f..29d1e7e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,69 +1,18 @@ -# Stage 1: Base -FROM nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04 as base +ARG BASE_IMAGE +FROM ${BASE_IMAGE} SHELL ["/bin/bash", "-o", "pipefail", "-c"] ENV DEBIAN_FRONTEND=noninteractive \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=on \ - SHELL=/bin/bash - -# Install Ubuntu packages -RUN apt update && \ - apt -y upgrade && \ - apt install -y --no-install-recommends \ - software-properties-common \ - python3.10-venv \ - python3-pip \ - python3-dev \ - python3-tk \ - bash \ - dos2unix \ - git \ - git-lfs \ - ncdu \ - nginx \ - net-tools \ - openssh-server \ - libglib2.0-0 \ - libsm6 \ - libgl1 \ - libxrender1 \ - libxext6 \ - ffmpeg \ - wget \ - curl \ - psmisc \ - rsync \ - vim \ - zip \ - unzip \ - htop \ - screen \ - tmux \ - pkg-config \ - libcairo2-dev \ - libgoogle-perftools4 \ - libtcmalloc-minimal4 \ - apt-transport-https \ - ca-certificates && \ - update-ca-certificates && \ - apt clean && \ - rm -rf /var/lib/apt/lists/* && \ - echo "en_US.UTF-8 UTF-8" > /etc/locale.gen - -ENV PATH="/usr/local/cuda/bin:${PATH}" - -# Set Python -RUN ln -s /usr/bin/python3.10 /usr/bin/python - -# Stage 2: Install Web UI and python modules -FROM base as setup + SHELL=/bin/bash \ + PATH="/usr/local/cuda/bin:${PATH}" # Install Torch ARG INDEX_URL ARG TORCH_VERSION WORKDIR / -RUN python3 -m venv /venv && \ +RUN python3 -m venv --system-site-packages /venv && \ source /venv/bin/activate && \ pip3 install torch==${TORCH_VERSION} --index-url ${INDEX_URL} && \ deactivate @@ -92,38 +41,9 @@ RUN source /venv/bin/activate && \ pip3 install -U autoawq && \ deactivate -# Install rclone -RUN curl https://rclone.org/install.sh | bash - -# Install runpodctl -ARG RUNPODCTL_VERSION -RUN wget "https://github.com/runpod/runpodctl/releases/download/${RUNPODCTL_VERSION}/runpodctl-linux-amd64" -O runpodctl && \ - chmod a+x runpodctl && \ - mv runpodctl /usr/local/bin - -# Install croc -RUN curl https://getcroc.schollz.com | bash - -# Install speedtest CLI -RUN curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | bash && \ - apt install speedtest - -# Install Jupyter, gdown and OhMyRunPod -RUN pip3 install -U --no-cache-dir jupyterlab \ - jupyterlab_widgets \ - ipykernel \ - ipywidgets \ - gdown \ - OhMyRunPod - -# Install RunPod File Uploader -RUN curl -sSL https://github.com/kodxana/RunPod-FilleUploader/raw/main/scripts/installer.sh -o installer.sh && \ - chmod +x installer.sh && \ - ./installer.sh - # NGINX Proxy COPY nginx/nginx.conf /etc/nginx/nginx.conf -COPY nginx/api.html nginx/502.html /usr/share/nginx/html/ +COPY nginx/api.html /usr/share/nginx/html/ # Remove existing SSH host keys RUN rm -f /etc/ssh/ssh_host_* diff --git a/docker-bake.hcl b/docker-bake.hcl index 999cc3b..42bd3d8 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -7,7 +7,7 @@ variable "APP" { } variable "RELEASE" { - default = "1.15.1" + default = "1.16.0" } variable "CU_VERSION" { @@ -19,10 +19,10 @@ target "default" { tags = ["${USERNAME}/${APP}:${RELEASE}"] args = { RELEASE = "${RELEASE}" + BASE_IMAGE = "ashleykza/runpod-base:1.0.0-cuda12.1.1-torch2.2.1" INDEX_URL = "https://download.pytorch.org/whl/cu${CU_VERSION}" TORCH_VERSION = "2.2.1+cu${CU_VERSION}" OOBABOOGA_COMMIT = "91a7370a655881c55274284509a546ffd644dc16" - RUNPODCTL_VERSION = "v1.14.2" VENV_PATH = "/workspace/venvs/text-generation-webui" } } diff --git a/nginx/502.html b/nginx/502.html deleted file mode 100644 index 39b00f3..0000000 --- a/nginx/502.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - Port Not Up Yet - - -
-
-

The port is not up yet

-
NOTE: This is not necessarily an error
-

Check your container logs for the following:

- -

If the container is READY

- - -
-
- - diff --git a/scripts/fix_venv.sh b/scripts/fix_venv.sh deleted file mode 100755 index 9a7bfbe..0000000 --- a/scripts/fix_venv.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -if [ "$#" -ne 2 ]; then - echo "Usage: $0 " - echo " eg: $0 /venv /workspace/venv" - exit 1 -fi - -OLD_PATH=${1} -NEW_PATH=${2} - -echo "Fixing venv. Old Path: ${OLD_PATH} New Path: ${NEW_PATH}" - -cd ${NEW_PATH}/bin -sed -i "s|VIRTUAL_ENV=\"${OLD_PATH}\"|VIRTUAL_ENV=\"${NEW_PATH}\"|" activate -sed -i "s|#\!${OLD_PATH}/bin/python3|#\!${NEW_PATH}/bin/python3|" * diff --git a/scripts/start.sh b/scripts/start.sh deleted file mode 100644 index 21068e1..0000000 --- a/scripts/start.sh +++ /dev/null @@ -1,170 +0,0 @@ -#!/usr/bin/env bash -# ---------------------------------------------------------------------------- # -# Function Definitions # -# ---------------------------------------------------------------------------- # - -start_nginx() { - echo "Starting Nginx service..." - service nginx start -} - -execute_script() { - local script_path=$1 - local script_msg=$2 - if [[ -f ${script_path} ]]; then - echo "${script_msg}" - bash ${script_path} - fi -} - -generate_ssh_host_keys() { - if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then - ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -q -N '' - fi - - if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then - ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -q -N '' - fi - - if [ ! -f /etc/ssh/ssh_host_ecdsa_key ]; then - ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -q -N '' - fi - - if [ ! -f /etc/ssh/ssh_host_ed25519_key ]; then - ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -q -N '' - fi -} - -setup_ssh() { - echo "Setting up SSH..." - mkdir -p ~/.ssh - - # Add SSH public key from environment variable to ~/.ssh/authorized_keys - # if the PUBLIC_KEY environment variable is set - if [[ ${PUBLIC_KEY} ]]; then - echo -e "${PUBLIC_KEY}\n" >> ~/.ssh/authorized_keys - fi - - chmod 700 -R ~/.ssh - - # Generate SSH host keys if they don't exist - generate_ssh_host_keys - - service ssh start - - echo "SSH host keys:" - cat /etc/ssh/*.pub -} - -export_env_vars() { - echo "Exporting environment variables..." - printenv | grep -E '^RUNPOD_|^PATH=|^_=' | awk -F = '{ print "export " $1 "=\"" $2 "\"" }' >> /etc/rp_environment - echo 'source /etc/rp_environment' >> ~/.bashrc -} - -start_jupyter() { - # Default to not using a password - JUPYTER_PASSWORD="" - - # Allow a password to be set by providing the JUPYTER_PASSWORD environment variable - if [[ ${JUPYTER_LAB_PASSWORD} ]]; then - JUPYTER_PASSWORD=${JUPYTER_LAB_PASSWORD} - fi - - echo "Starting Jupyter Lab..." - mkdir -p /workspace/logs - cd / && \ - nohup jupyter lab --allow-root \ - --no-browser \ - --port=8888 \ - --ip=* \ - --FileContentsManager.delete_to_trash=False \ - --ContentsManager.allow_hidden=True \ - --ServerApp.terminado_settings='{"shell_command":["/bin/bash"]}' \ - --ServerApp.token=${JUPYTER_PASSWORD} \ - --ServerApp.allow_origin=* \ - --ServerApp.preferred_dir=/workspace &> /workspace/logs/jupyter.log & - echo "Jupyter Lab started" -} - -start_runpod_uploader() { - echo "Starting RunPod Uploader..." - nohup /usr/local/bin/runpod-uploader &> /workspace/logs/runpod-uploader.log & - echo "RunPod Uploader started" -} - -configure_filezilla() { - # Only proceed if there is a public IP - if [[ ! -z "${RUNPOD_PUBLIC_IP}" ]]; then - # Server information - hostname="${RUNPOD_PUBLIC_IP}" - port="${RUNPOD_TCP_PORT_22}" - - # Generate a random password - password=$(openssl rand -base64 12) - - # Set the password for the root user - echo "root:${password}" | chpasswd - - # Update SSH configuration - ssh_config="/etc/ssh/sshd_config" - - # Enable PasswordAuthentication - grep -q "^PasswordAuthentication" ${ssh_config} && \ - sed -i "s/^PasswordAuthentication.*/PasswordAuthentication yes/" ${ssh_config} || \ - echo "PasswordAuthentication yes" >> ${ssh_config} - - # Enable PermitRootLogin - grep -q "^PermitRootLogin" ${ssh_config} && \ - sed -i "s/^PermitRootLogin.*/PermitRootLogin yes/" ${ssh_config} || \ - echo "PermitRootLogin yes" >> ${ssh_config} - - # Restart the SSH service - service ssh restart - - # Create FileZilla XML configuration for SFTP - filezilla_config_file="/workspace/filezilla_sftp_config.xml" - cat > ${filezilla_config_file} << EOF - - - - - ${hostname} - ${port} - 1 - 0 - root - $(echo -n ${password} | base64) - 1 - Auto - 0 - Generated Server - /workspace - 0 - 0 - - - - -EOF - echo "FileZilla SFTP configuration file created at: ${filezilla_config_file}" - else - echo "RUNPOD_PUBLIC_IP is not set. Skipping FileZilla configuration." - fi -} - -# ---------------------------------------------------------------------------- # -# Main Program # -# ---------------------------------------------------------------------------- # - -echo "Container Started, configuration in progress..." -start_nginx -setup_ssh -start_jupyter -start_runpod_uploader -execute_script "/pre_start.sh" "Running pre-start script..." -configure_filezilla -export_env_vars -execute_script "/post_start.sh" "Running post-start script..." -echo "Container is READY!" -sleep infinity