From 7e047dfb4e72131b91e108c8a3bff371f3e9ca2c Mon Sep 17 00:00:00 2001 From: Anil Vishnoi Date: Wed, 15 May 2024 02:30:18 -0700 Subject: [PATCH] Add playbooks for deploying the UI stack Signed-off-by: Anil Vishnoi --- .github/workflows/images.yml | 84 +++++++++++++++++++ deploy/ansible/README.md | 8 ++ deploy/ansible/deploy-ui-stack.yml | 15 ++++ deploy/ansible/gobot/tasks/main.yml | 4 +- deploy/ansible/ui/tasks/main.yaml | 33 ++++++++ deploy/compose/dev-single-worker-with-ui.yaml | 1 + ui/apiserver/Containerfile | 2 +- 7 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 deploy/ansible/deploy-ui-stack.yml create mode 100644 deploy/ansible/ui/tasks/main.yaml diff --git a/.github/workflows/images.yml b/.github/workflows/images.yml index 9bd2190e..9c6d4a99 100644 --- a/.github/workflows/images.yml +++ b/.github/workflows/images.yml @@ -48,6 +48,90 @@ jobs: cache-to: type=gha,mode=max file: gobot/Containerfile + push_to_registries_ui: + name: Push UI container image to GHCR + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/setup-buildx-action@v3 + + - name: Extract metadata (tags, labels) for UI image + id: ui_meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/${{ github.repository }}/bot-ui + + - name: Build and push ui image + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + build-args: | + GITHUB_USER=instructlab-bot + GITHUB_TOKEN=${{ secrets.BOT_GITHUB_TOKEN }} + target: ui + push: true + tags: ${{ steps.ui_meta.outputs.tags }} + labels: ${{ steps.ui_meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + file: ui/Containerfile + + push_to_registries_ui: + name: Push apiserver container image to GHCR + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/setup-buildx-action@v3 + + - name: Extract metadata (tags, labels) for apiserver image + id: apiserver_meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/${{ github.repository }}/apiserver + + - name: Build and push apiserver image + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + build-args: | + GITHUB_USER=instructlab-bot + GITHUB_TOKEN=${{ secrets.BOT_GITHUB_TOKEN }} + target: ui + push: true + tags: ${{ steps.apiserver_meta.outputs.tags }} + labels: ${{ steps.apiserver_meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + file: ui/apiserver/Containerfile + push_to_registries_serve: name: Push serve container image to GHCR runs-on: ubuntu-latest diff --git a/deploy/ansible/README.md b/deploy/ansible/README.md index 06ac5ef4..9e50ab20 100644 --- a/deploy/ansible/README.md +++ b/deploy/ansible/README.md @@ -117,6 +117,14 @@ This playbook installs all the components in the containers. ansible-playbook -i inventory.txt -e @secrets.enc --ask-vault-pass deploy-bot-stack.yml ``` +## Install the UI stack that works with the Bot stack + +This playbook installs all the required UI components in the containers. + +```console +ansible-playbook -i inventory.txt -e @secrets.enc --ask-vault-pass deploy-ui-stack.yml +``` + ## Install the Worker stack (first time installation) This playbook installs all the required component on the host itself diff --git a/deploy/ansible/deploy-ui-stack.yml b/deploy/ansible/deploy-ui-stack.yml new file mode 100644 index 00000000..761e7322 --- /dev/null +++ b/deploy/ansible/deploy-ui-stack.yml @@ -0,0 +1,15 @@ +# Description: This file is used to deploy the UI stack on the bot node. +# It assumes that the gobot and redis is already deployed on the bot node. +- name: Deploy UI stack on bot node + hosts: botNode + roles: + - role: geerlingguy.docker + become: true + - role: packages + become: true + - role: nexodus + become: true + - role: ui + become: true + vars_files: + - vars.yml diff --git a/deploy/ansible/gobot/tasks/main.yml b/deploy/ansible/gobot/tasks/main.yml index 6de84c3b..5f3baabd 100644 --- a/deploy/ansible/gobot/tasks/main.yml +++ b/deploy/ansible/gobot/tasks/main.yml @@ -12,6 +12,8 @@ image: ghcr.io/instructlab/instructlab-bot/instructlab-gobot:main state: started pull: always + ports: + - 8081:8081 env: ILBOT_GITHUB_INTEGRATION_ID: "{{ app_id }}" # Github App Id after bot's registration. ILBOT_GITHUB_APP_PRIVATE_KEY: "{{ private_key }}" # Private key generate for the bot app @@ -19,7 +21,7 @@ ILBOT_WEBHOOK_PROXY_URL: "{{ webhook_proxy_url }}" # Webhook URL set for the bot application to receive webhook events ILBOT_REDIS: "{{ redis_ip }}:6379" # Redis address to push and pull the jobs and results ILBOT_HTTP_ADDRESS: "127.0.0.1" # Bot's local http server ip address - ILBOT_HTTP_PORT: "8080" # Bot's local http server port + ILBOT_HTTP_PORT: "8081" # Bot's local http server port # List of teams that are allowed to run bot commands on the PR ILBOT_MAINTAINERS: "taxonomy-triagers,taxonomy-approvers,taxonomy-maintainers,labrador-org-maintainers,instruct-lab-bot-maintainers" ILBOT_REQUIRED_LABELS: "skill,knowledge" # Labels required on each PR to run any bot command. diff --git a/deploy/ansible/ui/tasks/main.yaml b/deploy/ansible/ui/tasks/main.yaml new file mode 100644 index 00000000..2c2620a8 --- /dev/null +++ b/deploy/ansible/ui/tasks/main.yaml @@ -0,0 +1,33 @@ +--- +- name: Log into GHCR + community.docker.docker_login: + registry_url: ghcr.io + username: instructlab-bot + password: "{{ github_token }}" + reauthorize: true + +- name: Start the apiserver container + community.docker.docker_container: + name: apiserver + image: ghcr.io/instructlab/instructlab-bot/apiserver:main + state: started + pull: always + env: + LISTEN_ADDRESS: "${LISTEN_ADDRESS:-:3000}" + REDIS_SERVER: "${REDIS_SERVER:-redis:6379}" + API_USER: "${API_USER:-kitteh}" + API_PASS: "${API_PASS:-floofykittens}" + DEBUG_MODE: "${DEBUG_MODE:-true}" + TEST_MODE: "${TEST_MODE:-true}" + BOT_URL: "${BOT_URL:-http://instructlab-bot:8081}" + ports: + - 3000:3000 + +- name: Start the ui container + community.docker.docker_container: + name: ui + image: ghcr.io/instructlab/instructlab-bot/bot-ui:main + state: started + pull: always + ports: + - 8080:8080 diff --git a/deploy/compose/dev-single-worker-with-ui.yaml b/deploy/compose/dev-single-worker-with-ui.yaml index 809c3482..ac54e988 100644 --- a/deploy/compose/dev-single-worker-with-ui.yaml +++ b/deploy/compose/dev-single-worker-with-ui.yaml @@ -37,6 +37,7 @@ services: API_PASS: "${API_PASS:-floofykittens}" DEBUG_MODE: "${DEBUG_MODE:-true}" TEST_MODE: "${TEST_MODE:-true}" + BOT_URL: "${BOT_URL:-http://bot:8081}" ports: - 3000:3000 diff --git a/ui/apiserver/Containerfile b/ui/apiserver/Containerfile index e1f096ee..47501c4b 100644 --- a/ui/apiserver/Containerfile +++ b/ui/apiserver/Containerfile @@ -40,4 +40,4 @@ WORKDIR /data COPY --from=builder /app/instructlab-bot/ui/apiserver/apiserver /usr/local/bin/apiserver # Run the apiserver binary with environment variables -CMD /usr/local/bin/apiserver --listen-address=${LISTEN_ADDRESS:-localhost:3000} --redis-server=${REDIS_SERVER:-localhost:6379} --api-user=${API_USER:-kitteh} --api-pass=${API_PASS:-floofykittens} --debug=${DEBUG_MODE:-false} --test-mode=${TEST_MODE:-false} +CMD /usr/local/bin/apiserver --listen-address=${LISTEN_ADDRESS:-localhost:3000} --bot-url ${BOT_URL:-http://instructlab-bot:8081} --redis-server=${REDIS_SERVER:-localhost:6379} --api-user=${API_USER:-kitteh} --api-pass=${API_PASS:-floofykittens} --debug=${DEBUG_MODE:-false} --test-mode=${TEST_MODE:-false}