From 43994f9c9af61402d7a38d06172dde1aa0883407 Mon Sep 17 00:00:00 2001 From: Yolanda Robla Date: Mon, 9 Dec 2024 18:23:20 +0000 Subject: [PATCH 1/2] feat: allow to expose vllm_ur as parameter in Docker Closes: #239 --- Dockerfile | 6 ++++- scripts/entrypoint.sh | 60 +++++++++++++++++++++++++++++++------------ 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3fdcdad5..783396e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -98,6 +98,10 @@ EXPOSE 80 # Set the PYTHONPATH environment variable ENV PYTHONPATH=/app/src +# Define an argument for vlm_url with a default value +ARG VLLM_URL=https://inference.codegate.ai +ENV VLLM_URL=${VLLM_URL} + # Set the container's default entrypoint EXPOSE 8989 -ENTRYPOINT ["/app/scripts/entrypoint.sh", "/tmp/weaviate_backup", "backup"] +ENTRYPOINT ["/app/scripts/entrypoint.sh", "${VLLM_URL}", "/tmp/weaviate_backup", "backup"] diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index 096c8535..5c7444bc 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -1,18 +1,46 @@ #!/bin/bash -# Check if the backup directory exists and handle the restore -if [ -d "$1" ] && [ -d "$1/$2" ]; then - echo "Restoring backup from $1/$2..." - # Your restore logic here, e.g., running a Python script or restoring a database - python -m src.codegate.cli restore-backup --backup-path "$1" --backup-name "$2" -else - echo "No backup found at $1/$2. Skipping restore." -fi - -# Step 2: Start the Nginx server with FE -echo "Starting the dashboard.. " -exec nginx -g 'daemon off;' & - -# Step 3: Start the main application (serve) -echo "Starting the application..." -exec python -m src.codegate.cli serve --port 8989 --host 0.0.0.0 --vllm-url https://inference.codegate.ai --model-base-path /app/models +DEFAULT_VLLM_URL="https://inference.codegate.ai" + +# Parse arguments +VLLM_URL=${1:-$DEFAULT_VLLM_URL} +BACKUP_PATH=$2 +BACKUP_MODE=$3 + +# Function to restore backup if paths are provided +restore_backup() { + if [ -n "$BACKUP_PATH" ] && [ -n "$BACKUP_MODE" ]; then + if [ -d "$BACKUP_PATH" ] && [ -d "$BACKUP_PATH/$BACKUP_MODE" ]; then + echo "Restoring backup from $BACKUP_PATH/$BACKUP_MODE..." + python -m src.codegate.cli restore-backup --backup-path "$BACKUP_PATH" --backup-name "$BACKUP_MODE" + else + echo "No backup found at $BACKUP_PATH/$BACKUP_MODE. Skipping restore." + fi + else + echo "Backup path or mode not provided. Skipping restore." + fi +} + +# Function to start Nginx server for the dashboard +start_dashboard() { + echo "Starting the dashboard..." + nginx -g 'daemon off;' & +} + +# Function to start the main application +start_application() { + echo "Starting the application with VLLM URL: $VLLM_URL" + exec python -m src.codegate.cli serve --port 8989 --host 0.0.0.0 --vllm-url "$VLLM_URL" --model-base-path /app/models +} + +# Main execution flow +echo "Initializing entrypoint script..." + +# Step 1: Restore backup if applicable +restore_backup + +# Step 2: Start the dashboard +start_dashboard + +# Step 3: Start the main application +start_application \ No newline at end of file From 39e3cfc019cb91bcfaf31fb887e69d76557bcc83 Mon Sep 17 00:00:00 2001 From: Yolanda Robla Date: Mon, 9 Dec 2024 18:54:59 +0000 Subject: [PATCH 2/2] properly expose url --- Dockerfile | 5 ++--- scripts/entrypoint.sh | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 783396e4..55e5363f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -99,9 +99,8 @@ EXPOSE 80 ENV PYTHONPATH=/app/src # Define an argument for vlm_url with a default value -ARG VLLM_URL=https://inference.codegate.ai -ENV VLLM_URL=${VLLM_URL} +ENV VLLM_URL=https://inference.codegate.ai # Set the container's default entrypoint EXPOSE 8989 -ENTRYPOINT ["/app/scripts/entrypoint.sh", "${VLLM_URL}", "/tmp/weaviate_backup", "backup"] +ENTRYPOINT ["/app/scripts/entrypoint.sh", "/tmp/weaviate_backup", "backup"] \ No newline at end of file diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh index 5c7444bc..44c6cb5e 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -1,11 +1,10 @@ #!/bin/bash - DEFAULT_VLLM_URL="https://inference.codegate.ai" +VLLM_URL=${VLLM_URL:-$DEFAULT_VLLM_URL} # Parse arguments -VLLM_URL=${1:-$DEFAULT_VLLM_URL} -BACKUP_PATH=$2 -BACKUP_MODE=$3 +BACKUP_PATH=$1 +BACKUP_MODE=$2 # Function to restore backup if paths are provided restore_backup() {