diff --git a/Dockerfile b/Dockerfile index 3fdcdad5..55e5363f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -98,6 +98,9 @@ EXPOSE 80 # Set the PYTHONPATH environment variable ENV PYTHONPATH=/app/src +# Define an argument for vlm_url with a default value +ENV VLLM_URL=https://inference.codegate.ai + # Set the container's default entrypoint EXPOSE 8989 -ENTRYPOINT ["/app/scripts/entrypoint.sh", "/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 096c8535..44c6cb5e 100755 --- a/scripts/entrypoint.sh +++ b/scripts/entrypoint.sh @@ -1,18 +1,45 @@ #!/bin/bash +DEFAULT_VLLM_URL="https://inference.codegate.ai" +VLLM_URL=${VLLM_URL:-$DEFAULT_VLLM_URL} -# 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 +# Parse arguments +BACKUP_PATH=$1 +BACKUP_MODE=$2 + +# 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