Skip to content

Commit

Permalink
ci/cd: add option in workflow to skip image rebuild in deployment (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie-XIAO authored Dec 7, 2024
1 parent 19c0874 commit 0e9f2d3
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 19 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/deploy-app.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
name: Deploy app
name: Deploy App

on:
workflow_dispatch:
inputs:
skip-rebuild-images:
description: Whether to skip rebuilding images
required: false
type: boolean
default: true

jobs:
deploy-app:
Expand Down Expand Up @@ -34,7 +40,7 @@ jobs:
run: |
cd deploy
printf "%s" "${{ secrets.VERITAS_TRIAL_SERVICE_KEY }}" > /tmp/veritas-trial-service.json
make gh-actions command=./deploy-app.sh
make gh-actions command="./deploy-app.sh --skip-rebuild-images=${{ inputs.skip-rebuild-images }}"
rm /tmp/veritas-trial-service.json
- name: Create PR
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/deploy-chromadb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ name: Deploy ChromaDB

on:
workflow_dispatch:
inputs:
skip-rebuild-images-app:
description: Whether to skip rebuilding images for app deployment
required: false
type: boolean
default: true
skip-rebuild-images-pipeline:
description: Whether to skip rebuilding images for pipeline deployment
required: false
type: boolean
default: true

jobs:
deploy-chromadb:
Expand Down Expand Up @@ -36,9 +47,9 @@ jobs:
run: |
cd deploy
printf "%s" "${{ secrets.VERITAS_TRIAL_SERVICE_KEY }}" > /tmp/veritas-trial-service.json
make gh-actions command=./deploy-chromadb.sh
make gh-actions command=./deploy-pipeline.sh
make gh-actions command=./deploy-app.sh
make gh-actions command="./deploy-chromadb.sh"
make gh-actions command="./deploy-pipeline.sh --skip-rebuild-images=${{ inputs.skip-rebuild-images-pipeline }}"
make gh-actions command="./deploy-app.sh --skip-rebuild-images=${{ inputs.skip-rebuild-images-app }}"
rm /tmp/veritas-trial-service.json
- name: Create PR
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/deploy-pipeline.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
name: Deploy pipeline
name: Deploy Pipeline

on:
workflow_dispatch:
inputs:
skip-rebuild-images:
description: Whether to skip rebuilding images
required: false
type: boolean
default: true

jobs:
deploy-pipeline:
Expand Down Expand Up @@ -34,7 +40,7 @@ jobs:
run: |
cd deploy
printf "%s" "${{ secrets.VERITAS_TRIAL_SERVICE_KEY }}" > /tmp/veritas-trial-service.json
make gh-actions command=./deploy-pipeline.sh
make gh-actions command="./deploy-pipeline.sh --skip-rebuild-images=${{ inputs.skip-rebuild-images }}"
rm /tmp/veritas-trial-service.json
- name: Create PR
Expand Down
8 changes: 4 additions & 4 deletions deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ make run
The deployment uses Ansible. It will deploy the Docker images of the application and create/update the Kubernetes cluster to run the application. Inside the container, run:

```bash
./deploy-app.sh # Deploy app (preferred to trigger GitHub Actions workflow)
./destroy-app.sh # Destroy app
./deploy-app.sh --skip-rebuild-images=false # Deploy app
./destroy-app.sh # Destroy app
```

## Pipeline

The deployment uses Ansible and Vertex AI pipeline. It will deploy the Docker images of the pipeline and run `/src/data-pipeline/` and `/src/embedding-model/` steps. Inside the container, run:

```bash
./deploy-pipeline.sh # Deploy pipeline (preferred to trigger GitHub Actions workflow)
./deploy-pipeline.sh --skip-rebuild-images=false # Deploy pipeline
```


Expand All @@ -30,6 +30,6 @@ The deployment uses Ansible and Vertex AI pipeline. It will deploy the Docker im
The deployment uses Terraform, as suggested in [ChromaDB docs](https://docs.trychroma.com/deployment/gcp). It will deploy a VM instance that runs ChromaDB service. Note that redeploying ChromaDB requires redeploying the app and the pipeline as well. The following script will not do that, but the corresponding workflow in GitHub Actions will. Inside the container, run:

```bash
./deploy-chromadb.sh # Deploy ChromaDB instance (preferred to trigger GitHub Actions workflow)
./deploy-chromadb.sh # Deploy ChromaDB instance
./destroy-chromadb.sh # Destroy ChromaDB instance
```
28 changes: 27 additions & 1 deletion deploy/deploy-app.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
#!/bin/bash

ansible-playbook app/deploy-images.yaml -i inventory.yaml
usage() {
echo "Usage: $0 [--skip-rebuild-images=true|false]"
exit 1
}

SKIP_REBUILD_IMAGES="true" # Skip rebuilding images by default

if [[ $# -gt 1 ]]; then
usage
elif [[ $# -eq 1 ]]; then
case "$1" in
--skip-rebuild-images=true)
SKIP_REBUILD_IMAGES="true"
;;
--skip-rebuild-images=false)
SKIP_REBUILD_IMAGES="false"
;;
*)
echo "Invalid argument: $1"
usage
;;
esac
fi

if [[ "${SKIP_REBUILD_IMAGES}" == "false" ]]; then
ansible-playbook app/deploy-images.yaml -i inventory.yaml
fi
CHROMADB_HOST=$(cat chromadb/.instance-ip) ansible-playbook app/deploy-k8s.yaml -i inventory.yaml --extra-vars cluster_state=present
2 changes: 0 additions & 2 deletions deploy/deploy-chromadb.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash

set -ex

cd chromadb
terraform init

Expand Down
28 changes: 27 additions & 1 deletion deploy/deploy-pipeline.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
#!/bin/bash

ansible-playbook pipeline/deploy-images.yaml -i inventory.yaml
usage() {
echo "Usage: $0 [--skip-rebuild-images=true|false]"
exit 1
}

SKIP_REBUILD_IMAGES="true" # Skip rebuilding images by default

if [[ $# -gt 1 ]]; then
usage
elif [[ $# -eq 1 ]]; then
case "$1" in
--skip-rebuild-images=true)
SKIP_REBUILD_IMAGES="true"
;;
--skip-rebuild-images=false)
SKIP_REBUILD_IMAGES="false"
;;
*)
echo "Invalid argument: $1"
usage
;;
esac
fi

if [[ "${SKIP_REBUILD_IMAGES}" == "false" ]]; then
ansible-playbook pipeline/deploy-images.yaml -i inventory.yaml
fi
./pipeline/pipeline.py
2 changes: 0 additions & 2 deletions deploy/destroy-app.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/bin/bash

CHROMADB_HOST=$(cat chromadb/.instance-ip)

ansible-playbook app/deploy-k8s.yaml -i inventory.yaml --extra-vars cluster_state=absent
2 changes: 0 additions & 2 deletions deploy/destroy-chromadb.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash

set -ex

cd chromadb
terraform init

Expand Down

0 comments on commit 0e9f2d3

Please sign in to comment.