From b93cd043ab52b1221f5b2900e7928e15ecde4093 Mon Sep 17 00:00:00 2001 From: cannuri <91494156+cannuri@users.noreply.github.com> Date: Wed, 19 Mar 2025 13:56:49 +0100 Subject: [PATCH] Add updating instructions; check for non running docker containers (#58) * docs: Update README with instructions for updating Archon via Docker and local Python installation * fix: Improve container management in run_docker.py - Check for existing containers, stop if running, and force remove if necessary --- README.md | 36 ++++++++++++++++++++++++++++++++++++ run_docker.py | 38 ++++++++++++++++++++++++++++++++------ 2 files changed, 68 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e855e07d..e66f83f5 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,42 @@ streamlit run streamlit_ui.py 4. Access the Streamlit UI at http://localhost:8501. +### Updating Archon + +#### Option 1: Docker +To get the latest updates for Archon when using Docker: + +```bash +# Pull the latest changes from the repository (from within the archon directory) +git pull + +# Rebuild and restart the containers with the latest changes +python run_docker.py +``` + +The `run_docker.py` script will automatically: +- Detect and remove any existing Archon containers (whether running or stopped) +- Rebuild the containers with the latest code +- Start fresh containers with the updated version + +#### Option 2: Local Python Installation +To get the latest updates for Archon when using local Python installation: + +```bash +# Pull the latest changes from the repository (from within the archon directory) +git pull + +# Install any new dependencies +source venv/bin/activate # On Windows: venv\Scripts\activate +pip install -r requirements.txt + +# Restart the Streamlit UI +# (If you're already running it, stop with Ctrl+C first) +streamlit run streamlit_ui.py +``` + +This ensures you're always running the most recent version of Archon with all the latest features and bug fixes. + ### Setup Process After installation, follow the guided setup process in the Intro section of the Streamlit UI: diff --git a/run_docker.py b/run_docker.py index bd15fa88..967dbb96 100644 --- a/run_docker.py +++ b/run_docker.py @@ -75,19 +75,45 @@ def main(): print("Error building main Archon container") return 1 - # Check if the container is already running + # Check if the container exists (running or stopped) try: result = subprocess.run( - ["docker", "ps", "-q", "--filter", "name=archon-container"], + ["docker", "ps", "-a", "-q", "--filter", "name=archon-container"], check=True, capture_output=True, text=True ) if result.stdout.strip(): - print("\n=== Stopping existing Archon container ===") - run_command(["docker", "stop", "archon-container"]) - run_command(["docker", "rm", "archon-container"]) - except subprocess.SubprocessError: + print("\n=== Removing existing Archon container ===") + container_id = result.stdout.strip() + print(f"Found container with ID: {container_id}") + + # Check if the container is running + running_check = subprocess.run( + ["docker", "ps", "-q", "--filter", "id=" + container_id], + check=True, + capture_output=True, + text=True + ) + + # If running, stop it first + if running_check.stdout.strip(): + print("Container is running. Stopping it first...") + stop_result = run_command(["docker", "stop", container_id]) + if stop_result != 0: + print("Warning: Failed to stop container gracefully, will try force removal") + + # Remove the container with force flag to ensure it's removed + print("Removing container...") + rm_result = run_command(["docker", "rm", "-f", container_id]) + if rm_result != 0: + print("Error: Failed to remove container. Please remove it manually with:") + print(f" docker rm -f {container_id}") + return 1 + + print("Container successfully removed") + except subprocess.SubprocessError as e: + print(f"Error checking for existing containers: {e}") pass # Run the Archon container