51 lines
1.8 KiB
Bash
51 lines
1.8 KiB
Bash
#!/bin/bash
|
|
# Launches the gpt-researcher application using Docker
|
|
|
|
# Define the project directory relative to the script's location
|
|
PROJECT_DIR="./gpt-researcher"
|
|
ENV_FILE="$PROJECT_DIR/.env"
|
|
|
|
# Define the docs directory relative to the *script's parent* directory
|
|
# Assumes gptr_docs is located alongside the 'systems' directory (e.g., ../gptr_docs)
|
|
SCRIPT_DIR=$(dirname "$(realpath "$0")") # Directory where the script resides
|
|
PARENT_DIR=$(dirname "$SCRIPT_DIR") # Parent directory (e.g., where 'systems' folder is)
|
|
DOCS_DIR_HOST="$PARENT_DIR/gptr_docs" # Assumed host path for docs
|
|
DOCS_DIR_CONTAINER="/my-docs" # Path inside the container
|
|
|
|
# Check if project directory exists
|
|
if [ ! -d "$PROJECT_DIR" ]; then
|
|
echo "Error: Project directory '$PROJECT_DIR' not found."
|
|
exit 1
|
|
fi
|
|
|
|
# Check if .env file exists in the project directory
|
|
if [ ! -f "$ENV_FILE" ]; then
|
|
echo "Error: Environment file '$ENV_FILE' not found."
|
|
exit 1
|
|
fi
|
|
|
|
# Check if the host docs directory exists
|
|
if [ ! -d "$DOCS_DIR_HOST" ]; then
|
|
echo "Error: Host documents directory '$DOCS_DIR_HOST' not found."
|
|
echo "Please create it or modify the DOCS_DIR_HOST variable in the script."
|
|
exit 1
|
|
fi
|
|
|
|
# --- Docker Launch Command ---
|
|
echo "Launching gpt-researcher via Docker..."
|
|
echo "Using host volume: $DOCS_DIR_HOST"
|
|
|
|
# Use exec to replace the shell process with the docker command
|
|
# This ensures signals (like Ctrl+C) are passed correctly to the container
|
|
# Added --rm to automatically remove the container on exit
|
|
exec docker run -it --rm --name gpt-researcher \
|
|
-p 8000:8000 \
|
|
--env-file "$ENV_FILE" \
|
|
-v "$DOCS_DIR_HOST":"$DOCS_DIR_CONTAINER" \
|
|
gpt-researcher "$@" # Pass any extra script arguments to the container command
|
|
|
|
# --- End Docker Launch Command ---
|
|
|
|
# Note: 'exec' means the script won't reach here unless docker run fails immediately
|
|
echo "Docker container failed to start."
|
|
exit 1 |