CosmicAC Repository Setup
Clone all CosmicAC repositories in the correct order and run the automated dependency installation and configuration script.
CosmicAC Repository Setup
Application Components (Execution Order)
The following components need to be deployed in this specific order:
| Order | Repository | Branch (Staging) | Branch (Current) | Description |
|---|---|---|---|---|
| 1 | cosmicac-wrk-ork | stg | dev | Orchestrator worker |
| 2 | cosmicac-app-node | stg | dev | Main application node |
| 3 | cosmicac-ui | stg | dev | User interface |
| 4 | cosmicac-wrk-server-k8s-nvidia | stg | dev | K8s NVIDIA server worker |
| 5 | cosmicac-proxy-inference | stg | dev | Inference proxy |
| 6 | tether-wrk-ext-sendgrid | stg | dev | SendGrid email service |
Note: The default branch for staging is stg, but we are currently using dev branch.
Clone Repositories (Manual Step)
All repositories are cloned directly into the user's home directory /home/cosmicac:
cd ~
# Clone in execution order (using dev branch for now)
git clone -b main https://github.com/tetherto/cosmicac-wrk-ork.git
git clone -b main https://github.com/tetherto/cosmicac-app-node.git
git clone -b main https://github.com/tetherto/cosmicac-ui.git
git clone -b main https://github.com/tetherto/cosmicac-wrk-server-k8s-nvidia.git
git clone -b main https://github.com/tetherto/cosmicac-proxy-inference.git
git clone -b main https://github.com/tetherto/tether-wrk-ext-sendgrid.gitWhen switching to staging branch: Replace -b dev with -b stg in the commands above.
Automated Repository Setup
After cloning, run the setup automation script to install dependencies and configure each repository.
Setup Script: setup-repos.sh
Create this script in ~/setup-repos.sh:
#!/bin/bash
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Define repositories in execution order
REPOS=(
"cosmicac-wrk-ork"
"cosmicac-app-node"
"cosmicac-ui"
"cosmicac-wrk-server-k8s-nvidia"
"cosmicac-proxy-inference"
"tether-wrk-ext-sendgrid"
)
BASE_DIR="${1:-$(pwd)}"
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN} CosmicAC Repository Setup Script${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
echo "Base directory: $BASE_DIR"
echo ""
setup_repo() {
local repo=$1
local repo_path="$BASE_DIR/$repo"
local steps=2
# cosmicac-ui requires build step
if [ "$repo" = "cosmicac-ui" ]; then
steps=3
fi
echo -e "${YELLOW}----------------------------------------${NC}"
echo -e "${YELLOW}Setting up: $repo${NC}"
echo -e "${YELLOW}----------------------------------------${NC}"
if [ ! -d "$repo_path" ]; then
echo -e "${RED}ERROR: Repository not found at $repo_path${NC}"
echo -e "${RED}Please clone the repository first.${NC}"
return 1
fi
cd "$repo_path"
# Step 1: Install dependencies
echo -e "${GREEN}[1/$steps] Installing dependencies...${NC}"
if [ -f "package-lock.json" ]; then
echo "Found package-lock.json, running npm ci..."
npm ci
else
echo "No package-lock.json found, running npm install..."
npm install
fi
# Step 2: Run setup-config.sh if present
echo -e "${GREEN}[2/$steps] Running setup-config.sh...${NC}"
if [ -f "setup-config.sh" ]; then
chmod +x setup-config.sh
./setup-config.sh
else
echo "No setup-config.sh found, skipping..."
fi
# Step 3: Build (only for cosmicac-ui)
if [ "$repo" = "cosmicac-ui" ]; then
echo -e "${GREEN}[3/$steps] Building UI...${NC}"
npm run build
fi
echo -e "${GREEN}✓ $repo setup complete${NC}"
echo ""
cd "$BASE_DIR"
}
# Main execution
echo "Starting setup for ${#REPOS[@]} repositories..."
echo ""
FAILED=()
for repo in "${REPOS[@]}"; do
if ! setup_repo "$repo"; then
FAILED+=("$repo")
fi
done
echo ""
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN} Setup Complete${NC}"
echo -e "${GREEN}========================================${NC}"
if [ ${#FAILED[@]} -gt 0 ]; then
echo ""
echo -e "${RED}The following repositories failed setup:${NC}"
for repo in "${FAILED[@]}"; do
echo -e "${RED} - $repo${NC}"
done
exit 1
else
echo ""
echo -e "${GREEN}All repositories set up successfully!${NC}"
echo ""
echo "Next steps:"
echo " 1. Copy stg.ecosystem.config.js to ~/"
echo " 2. Copy autobase-connect.js to ~/"
echo " 3. Start with: pm2 start stg.ecosystem.config.js"
fiMake the Script Executable and Run
chmod +x ~/setup-repos.sh
# Run the setup from home directory
cd ~
./setup-repos.sh