diff --git a/docker/docker-compose-nollama.yaml b/docker/docker-compose-nollama.yaml new file mode 100644 index 0000000..ef7bd8d --- /dev/null +++ b/docker/docker-compose-nollama.yaml @@ -0,0 +1,3 @@ +include: + - ./sui/compose.yaml + - ./nexus/compose.yaml diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 706fdff..296619f 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -1,4 +1,3 @@ -version: "3.8" include: - ./sui/compose.yaml - ./ollama/compose.yaml diff --git a/docker/nexus/compose.yaml b/docker/nexus/compose.yaml index e0c41e3..88834e5 100644 --- a/docker/nexus/compose.yaml +++ b/docker/nexus/compose.yaml @@ -1,5 +1,3 @@ -version: "3.8" - services: tools: container_name: tools @@ -12,6 +10,11 @@ services: restart: unless-stopped environment: OLLAMA_HOST: ${MODEL_URL} + logging: + driver: "json-file" + options: + max-file: "10" + max-size: "1g" depends_on: build-suitools: condition: service_completed_successfully @@ -30,6 +33,11 @@ services: INSTALL_RUST: "true" command: > bash -c "source .venv/bin/activate && python start_events.py" + logging: + driver: "json-file" + options: + max-file: "10" + max-size: "1g" environment: RPC_URL: ${RPC_URL} WS_URL: ${WS_URL} diff --git a/docker/nexusctl.py b/docker/nexusctl.py index 5528537..a087f9f 100644 --- a/docker/nexusctl.py +++ b/docker/nexusctl.py @@ -74,7 +74,7 @@ def detect_gpu_and_set_env(): print("NVIDIA GPU detected") os.environ["OLLAMA_DEVICE_DRIVER"] = "nvidia" os.environ["OLLAMA_DEVICE_COUNT"] = "all" - os.environ["OLLAMA_DEVICE_CAPABILITIES"] = "[gpu]" + os.environ["OLLAMA_DEVICE_CAPABILITIES"] = "gpu" else: print("No GPU detected") os.environ["OLLAMA_DEVICE_DRIVER"] = "" @@ -86,7 +86,7 @@ def detect_gpu_and_set_env(): print("NVIDIA GPU detected") os.environ["OLLAMA_DEVICE_DRIVER"] = "nvidia" os.environ["OLLAMA_DEVICE_COUNT"] = "all" - os.environ["OLLAMA_DEVICE_CAPABILITIES"] = "[gpu]" + os.environ["OLLAMA_DEVICE_CAPABILITIES"] = "gpu" else: print("No GPU detected") os.environ["OLLAMA_DEVICE_DRIVER"] = "" @@ -155,7 +155,6 @@ def start_ollama_serve(): def change_to_docker_directory(): try: - print(os.getcwd()) os.chdir("./docker") print(f"Changed working directory to: {os.getcwd()}") except FileNotFoundError: @@ -197,6 +196,38 @@ def docker_compose_up(): print(f"Failed to run Docker Compose up: {e}") sys.exit(1) +def docker_compose_build(): + change_to_docker_directory() + os_type = platform.system() + + compose_file = "docker-compose.yaml" + if os_type == "Darwin": + # Use a different compose file for macOS + compose_file = "docker-compose-nollama.yaml" + print("Using docker-compose-nollama.yaml for macOS") + + # Override the MODEL_URL environment variable on macOS + os.environ["MODEL_URL"] = "http://host.docker.internal:11434" + + # Load environment variables from the .env file + load_env_file(".env") + + # Ensure the environment has the updated MODEL_URL for macOS + env_vars = os.environ.copy() + if os_type == "Darwin": + env_vars["MODEL_URL"] = "http://host.docker.internal:11434" + + try: + # Use subprocess.run with env argument to override environment variables + subprocess.run( + ["docker", "compose", "-f", compose_file, "build"], + check=True, + env=env_vars # Pass our modified environment with correct MODEL_URL + ) + except subprocess.CalledProcessError as e: + print(f"Failed to run Docker Compose build: {e}") + sys.exit(1) + def docker_compose_down(): change_to_docker_directory() os_type = platform.system() @@ -263,10 +294,9 @@ def stop_ollama_serve(): else: print(f"PID file {OLLAMA_PID_FILE} not found. Ollama server may not be running.") - def main(): parser = argparse.ArgumentParser(description="Control the Docker Compose deployment and overall environment.") - parser.add_argument("command", choices=["start", "stop", "delete"], help="Command to execute: start, stop, delete") + parser.add_argument("command", choices=["start", "stop", "delete", "create"], help="Command to execute: start, stop, delete, create") args = parser.parse_args() # Check Docker Compose version @@ -286,6 +316,8 @@ def main(): elif args.command == "delete": docker_compose_down() docker_delete_volumes() + elif args.command == "create": + docker_compose_build() if __name__ == "__main__": main() diff --git a/docker/ollama/compose.yaml b/docker/ollama/compose.yaml index 51bc64e..1371569 100644 --- a/docker/ollama/compose.yaml +++ b/docker/ollama/compose.yaml @@ -1,16 +1,14 @@ -version: "3.8" - services: ollama: image: talus-network/ollama:${LLAMA_MODEL_VERSION_TAG} container_name: ollama - # deploy: - # resources: - # reservations: - # devices: - # - driver: nvidia - # count: all - # capabilities: [gpu] + deploy: + resources: + reservations: + devices: + - driver: ${OLLAMA_DEVICE_DRIVER} + count: ${OLLAMA_DEVICE_COUNT} + capabilities: ["${OLLAMA_DEVICE_CAPABILITIES}"] build: context: "." args: diff --git a/docker/sui/compose.yaml b/docker/sui/compose.yaml index 7c6a978..cfe706e 100644 --- a/docker/sui/compose.yaml +++ b/docker/sui/compose.yaml @@ -1,5 +1,3 @@ -version: "3" - services: build-suitools: restart: "no" @@ -39,7 +37,6 @@ services: - RPC_URL=${RPC_URL} volumes: - - ./genesis/files:/opt/sui/genesis - shared:/app/shared - ./bin/publish_package.sh:/opt/sui/publish_package.sh:ro - ./genesis/static/client.yaml:/opt/sui/config/client.yaml:rw @@ -64,15 +61,12 @@ services: volumes: - validator1-db:/opt/sui/db:rw - genesis:/opt/sui/config - # - ./genesis/files/validator1-8080.yaml:/opt/sui/config/validator.yaml:ro - # - ./genesis/files/genesis.blob:/opt/sui/config/genesis.blob:ro command: [ "/usr/local/bin/sui-node", "--config-path", "/opt/sui/config/validator1-8080.yaml", ] - # command: ["tail", "-f", "/dev/null"] restart: on-failure logging: @@ -99,8 +93,6 @@ services: volumes: - validator2-db:/opt/sui/db:rw - genesis:/opt/sui/config - # - ./genesis/files/validator2-8080.yaml:/opt/sui/config/validator.yaml:ro - # - ./genesis/files/genesis.blob:/opt/sui/config/genesis.blob:ro command: [ "/usr/local/bin/sui-node", @@ -132,8 +124,6 @@ services: volumes: - validator3-db:/opt/sui/db:rw - genesis:/opt/sui/config - # - ./genesis/files/validator3-8080.yaml:/opt/sui/config/validator.yaml:ro - # - ./genesis/files/genesis.blob:/opt/sui/config/genesis.blob:ro command: [ "/usr/local/bin/sui-node", @@ -165,8 +155,6 @@ services: volumes: - validator4-db:/opt/sui/db:rw - genesis:/opt/sui/config - # - ./genesis/files/validator4-8080.yaml:/opt/sui/config/validator.yaml:ro - # - ./genesis/files/genesis.blob:/opt/sui/config/genesis.blob:ro command: [ "/usr/local/bin/sui-node", @@ -203,7 +191,6 @@ services: - fullnode1-db:/opt/sui/db:rw - genesis:/opt/sui/config - ./genesis/static/fullnode.yaml:/opt/sui/config/fullnode.yaml:ro - # - ./genesis/files/genesis.blob:/opt/sui/config/genesis.blob:ro - ./genesis/static/client.yaml:/opt/sui/config/client.yaml:rw healthcheck: test: @@ -262,7 +249,6 @@ services: volumes: - genesis:/opt/sui/config - ./genesis/static/client.yaml:/opt/sui/config/client.yaml:rw - # - ./genesis/files/genesis.blob:/opt/sui/config/genesis.blob:ro - ./genesis/static/sui.keystore:/opt/sui/config/sui.keystore:ro command: [ diff --git a/examples/example.just b/examples/example.just index d9acd1f..f8017eb 100644 --- a/examples/example.just +++ b/examples/example.just @@ -7,20 +7,15 @@ default: # Runs an example that prompts the user for a description of their post. [no-cd] ig-post-planner: - #!/usr/bin/env bash - source .venv/bin/activate - python3 examples/main.py "ig_post_planner" + docker exec -it examples /bin/bash -c "source .venv/bin/activate && python examples/main.py ig_post_planner" # Runs an example that prompts the user for description of their trip. [no-cd] trip-planner: - #!/usr/bin/env bash - source .venv/bin/activate - python3 examples/main.py "trip_planner" + docker exec -it examples /bin/bash -c "source .venv/bin/activate && python examples/main.py trip_planner" # Runs an example that prompts the user for description of their cluster. [no-cd] cli-cluster: - #!/usr/bin/env bash - source .venv/bin/activate - python3 examples/main.py "cli_cluster" + docker exec -it examples /bin/bash -c "source .venv/bin/activate && python examples/main.py cli_cluster" +