forked from elizaOS/eliza
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
30cc542
commit 7a31251
Showing
4 changed files
with
211 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
steps: | ||
# Build the base image | ||
- name: 'gcr.io/cloud-builders/docker' | ||
env: | ||
- 'DOCKER_BUILDKIT=1' | ||
args: | ||
- 'build' | ||
- '-t' | ||
- 'us-east1-docker.pkg.dev/${PROJECT_ID}/qi-agents/base:latest' | ||
- '.' | ||
|
||
# Push the base image | ||
- name: 'gcr.io/cloud-builders/docker' | ||
args: | ||
- 'push' | ||
- 'us-east1-docker.pkg.dev/${PROJECT_ID}/qi-agents/base:latest' | ||
|
||
# Tag with commit hash | ||
- name: 'gcr.io/cloud-builders/docker' | ||
args: | ||
- 'tag' | ||
- 'us-east1-docker.pkg.dev/${PROJECT_ID}/qi-agents/base:latest' | ||
- 'us-east1-docker.pkg.dev/${PROJECT_ID}/qi-agents/base:${SHORT_SHA}' | ||
|
||
- name: 'gcr.io/cloud-builders/docker' | ||
args: | ||
- 'push' | ||
- 'us-east1-docker.pkg.dev/${PROJECT_ID}/qi-agents/base:${SHORT_SHA}' | ||
|
||
options: | ||
env: | ||
- 'DOCKER_BUILDKIT=1' | ||
logging: CLOUD_LOGGING_ONLY | ||
machineType: 'E2_HIGHCPU_8' | ||
|
||
images: | ||
- 'us-east1-docker.pkg.dev/${PROJECT_ID}/qi-agents/base:latest' | ||
- 'us-east1-docker.pkg.dev/${PROJECT_ID}/qi-agents/base:${SHORT_SHA}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
steps: | ||
# Setup character files | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
entrypoint: 'bash' | ||
args: | ||
- '-c' | ||
- | | ||
echo "Setting up deployment for ${_DEPLOYMENT_ID}" | ||
mkdir -p /app/characters | ||
gsutil cp gs://qi-agents-service/${_DEPLOYMENT_ID}/*.character.json /app/characters/ | ||
# Create or update instance with random zone selection | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
entrypoint: 'bash' | ||
args: | ||
- '-c' | ||
- | | ||
ZONES=("a" "b" "c" "d" "f") | ||
RANDOM_ZONE="${ZONES[$((RANDOM % ${#ZONES[@]}))]}" | ||
ZONE="us-east1-$RANDOM_ZONE" | ||
if [[ $(gcloud compute instances list --filter="name=${_DEPLOYMENT_ID}" --format="get(name)") ]]; then | ||
echo "Updating existing instance ${_DEPLOYMENT_ID}" | ||
gcloud compute instances update-container ${_DEPLOYMENT_ID} \ | ||
--container-image us-east1-docker.pkg.dev/${PROJECT_ID}/qi-agents/base:latest \ | ||
--container-mount-host-path mount-path=/app/characters,host-path=/app/characters \ | ||
--container-env BUCKET_PATH=${_DEPLOYMENT_ID} \ | ||
--zone $ZONE | ||
else | ||
echo "Creating new instance ${_DEPLOYMENT_ID}" | ||
gcloud compute instances create-with-container ${_DEPLOYMENT_ID} \ | ||
--container-image us-east1-docker.pkg.dev/${PROJECT_ID}/qi-agents/base:latest \ | ||
--machine-type ${_MACHINE_TYPE} \ | ||
--zone $ZONE \ | ||
--network agents-vpc \ | ||
--subnet agents-subnet-primary \ | ||
--no-address \ | ||
--boot-disk-size 30GB \ | ||
--container-mount-host-path mount-path=/app/characters,host-path=/app/characters \ | ||
--container-env BUCKET_PATH=${_DEPLOYMENT_ID} \ | ||
--scopes=cloud-platform \ | ||
--service-account=${_SERVICE_ACCOUNT} \ | ||
--metadata-from-file startup-script=startup.sh \ | ||
--tags=agent-vm | ||
fi | ||
substitutions: | ||
_MACHINE_TYPE: e2-small | ||
_SERVICE_ACCOUNT: qi-agents-service@qi-agents-as-a-service.iam.gserviceaccount.com | ||
_DEPLOYMENT_ID: "" | ||
_VERSION: "" | ||
|
||
options: | ||
logging: CLOUD_LOGGING_ONLY | ||
machineType: 'E2_HIGHCPU_8' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
set -e | ||
set -x | ||
|
||
echo "Starting initialization script..." | ||
|
||
# Create data directory | ||
AGENT_DATA_DIR="/var/lib/qi-agents" | ||
echo "Creating data directory in $AGENT_DATA_DIR..." | ||
sudo mkdir -p "$AGENT_DATA_DIR/data" || { | ||
echo "Failed to create data directory" | ||
exit 1 | ||
} | ||
|
||
# Set permissions | ||
echo "Setting directory permissions..." | ||
sudo chmod -R 777 "$AGENT_DATA_DIR" || { | ||
echo "Failed to set permissions" | ||
exit 1 | ||
} | ||
|
||
# Get deployment ID from metadata | ||
DEPLOYMENT_ID=$(curl -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/name") | ||
echo "Deployment ID: ${DEPLOYMENT_ID}" | ||
|
||
# Configure gcloud auth | ||
echo "Configuring gcloud auth..." | ||
gcloud auth configure-docker us-east1-docker.pkg.dev --quiet | ||
|
||
echo "Startup completed successfully" |