From 658bbf2f17eb4e0868a658d27a702e1eb3e8e58f Mon Sep 17 00:00:00 2001 From: Adil Hafeez Date: Tue, 4 Feb 2025 15:04:09 -0800 Subject: [PATCH] Publish both arm64 and amd64 in docker on main (#392) --- .github/workflows/docker-push.yml | 95 ++++++++++++++++----- demos/spotify/README.md | 1 + demos/spotify/arch_config.yaml | 137 ++++++++++++++++++++++++++++++ demos/spotify/docker-compose.yaml | 21 +++++ demos/spotify/run_demo.sh | 47 ++++++++++ 5 files changed, 282 insertions(+), 19 deletions(-) create mode 100644 demos/spotify/README.md create mode 100644 demos/spotify/arch_config.yaml create mode 100644 demos/spotify/docker-compose.yaml create mode 100644 demos/spotify/run_demo.sh diff --git a/.github/workflows/docker-push.yml b/.github/workflows/docker-push.yml index ebf1d6da..ae1cbfe8 100644 --- a/.github/workflows/docker-push.yml +++ b/.github/workflows/docker-push.yml @@ -1,40 +1,97 @@ name: Publish Docker image +env: + DOCKER_IMAGE: katanemo/archgw + on: - release: - types: [published] + push: + branches: + - main jobs: - push_to_registry: - name: Push Docker image to Docker Hub - runs-on: ubuntu-latest - permissions: - packages: write - contents: read - attestations: write - id-token: write + # Build ARM64 image on native ARM64 runner + build-arm64: + runs-on: [linux-arm64] steps: - - name: Check out the repo + - name: Checkout Repository uses: actions/checkout@v4 - name: Log in to Docker Hub - uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Extract metadata (tags, labels) for Docker id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + uses: docker/metadata-action@v5 with: - images: katanemo/archgw + images: ${{ env.DOCKER_IMAGE }} + tags: | + type=raw,value=latest # Force the tag to be "latest" - - name: Build and push Docker image - id: push - uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + - name: Build and Push ARM64 Image + uses: docker/build-push-action@v5 with: context: . file: ./arch/Dockerfile + platforms: linux/arm64 push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + tags: ${{ steps.meta.outputs.tags }}-arm64 + + # Build AMD64 image on GitHub's AMD64 runner + build-amd64: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.DOCKER_IMAGE }} + tags: | + type=raw,value=latest # Force the tag to be "latest" + + - name: Build and Push AMD64 Image + uses: docker/build-push-action@v5 + with: + context: . + file: ./arch/Dockerfile + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }}-amd64 + + + # Combine ARM64 and AMD64 images into a multi-arch manifest + create-manifest: + runs-on: ubuntu-latest + needs: [build-arm64, build-amd64] # Wait for both builds + steps: + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.DOCKER_IMAGE }} + tags: | + type=raw,value=latest # Force the tag to be "latest" + + - name: Create Multi-Arch Manifest + run: | + # Combine the architecture-specific images into a "latest" manifest + docker buildx imagetools create -t ${{ steps.meta.outputs.tags }} \ + ${{ env.DOCKER_IMAGE }}:latest-arm64 \ + ${{ env.DOCKER_IMAGE }}:latest-amd64 diff --git a/demos/spotify/README.md b/demos/spotify/README.md new file mode 100644 index 00000000..14ac5964 --- /dev/null +++ b/demos/spotify/README.md @@ -0,0 +1 @@ +This demo shows how you can use spotify's public APIs using http auth header token. diff --git a/demos/spotify/arch_config.yaml b/demos/spotify/arch_config.yaml new file mode 100644 index 00000000..c003f631 --- /dev/null +++ b/demos/spotify/arch_config.yaml @@ -0,0 +1,137 @@ +version: v0.1 +listener: + address: 127.0.0.1 + port: 8080 #If you configure port 443, you'll need to update the listener with tls_certificates + message_format: huggingface + +endpoints: + spotify: + endpoint: api.spotify.com + protocol: https + +system_prompt: | + I have the following JSON data representing a list of albums from Spotify: + + { + "items": [ + { + "album_type": "album", + "artists": [ + { + "external_urls": { + "spotify": "https://open.spotify.com/artist/06HL4z0CvFAxyc27GXpf02" + }, + "href": "https://api.spotify.com/v1/artists/06HL4z0CvFAxyc27GXpf02", + "id": "06HL4z0CvFAxyc27GXpf02", + "name": "Taylor Swift", + "type": "artist", + "uri": "spotify:artist:06HL4z0CvFAxyc27GXpf02" + } + ], + "available_markets": [ /* ... markets omitted for brevity ... */ ], + "external_urls": { + "spotify": "https://open.spotify.com/album/1Mo4aZ8pdj6L1jx8zSwJnt" + }, + "href": "https://api.spotify.com/v1/albums/1Mo4aZ8pdj6L1jx8zSwJnt", + "id": "1Mo4aZ8pdj6L1jx8zSwJnt", + "images": [ + { + "height": 300, + "url": "https://i.scdn.co/image/ab67616d00001e025076e4160d018e378f488c33", + "width": 300 + }, + { + "height": 64, + "url": "https://i.scdn.co/image/ab67616d000048515076e4160d018e378f488c33", + "width": 64 + }, + { + "height": 640, + "url": "https://i.scdn.co/image/ab67616d0000b2735076e4160d018e378f488c33", + "width": 640 + } + ], + "name": "THE TORTURED POETS DEPARTMENT", + "release_date": "2024-04-18", + "release_date_precision": "day", + "total_tracks": 16, + "type": "album", + "uri": "spotify:album:1Mo4aZ8pdj6L1jx8zSwJnt" + } + ] + } + + Please convert this JSON into Markdown with the following layout for each album: + + - Display the album image (using Markdown image syntax) first. + - On the next line immediately after the image, display the album title, artist name (use the first artist listed), and the release date, all separated by a hyphen or another clear delimiter. + - On the next line, provide the Spotify link (using Markdown link syntax). + + For example, the output should look similar to this (using the data above): + + ![Album Image](https://i.scdn.co/image/ab67616d00001e025076e4160d018e378f488c33) + **THE TORTURED POETS DEPARTMENT** + Taylor Swift - 2024-04-18 + [Listen on Spotify](https://open.spotify.com/album/1Mo4aZ8pdj6L1jx8zSwJnt) +
+ + Make sure your output is valid Markdown. And don't say "formatted in Markdown". Thanks! + +llm_providers: + - name: OpenAI + provider_interface: openai + access_key: $OPENAI_API_KEY + model: gpt-4o + default: true + +prompt_targets: + - name: get_new_releases + description: Get a list of new album releases featured in Spotify (shown, for example, on a Spotify player’s “Browse” tab). + parameters: + - name: country + description: the country where the album is released + required: true + type: str + in_path: true + - name: limit + type: integer + description: The maximum number of results to return + default: "5" + endpoint: + name: spotify + path: /v1/browse/new-releases + http_headers: + Authorization: "Bearer $SPOTIFY_CLIENT_KEY" + + - name: search_for_item + description: Get information about albums, artists, playlists, tracks, shows, episodes or audiobooks. You can search for an item by its name, creator, or topic. + parameters: + - name: q + description: Your search query, which can include keywords related to the item name, its creator, or its topic. + required: true + type: str + - name: type + type: str + description: The type of the item to search for (e.g., album, artist, playlist, track, show, episode, audiobook). + enum: + - album + - artist + - playlist + - track + - show + - episode + - audiobook + required: true + - name: market + type: str + description: A country code + default: US + - name: limit + type: integer + description: The maximum number of results to return + default: "5" + endpoint: + name: spotify + path: /v1/search + http_headers: + Authorization: "Bearer $SPOTIFY_CLIENT_KEY" diff --git a/demos/spotify/docker-compose.yaml b/demos/spotify/docker-compose.yaml new file mode 100644 index 00000000..32e52c40 --- /dev/null +++ b/demos/spotify/docker-compose.yaml @@ -0,0 +1,21 @@ +services: + chatbot_ui: + build: + context: ../shared/chatbot_ui + ports: + - "18080:8080" + environment: + # this is only because we are running the sample app in the same docker container environemtn as archgw + - CHAT_COMPLETION_ENDPOINT=http://host.docker.internal:10000/v1 + extra_hosts: + - "host.docker.internal:host-gateway" + volumes: + - ./arch_config.yaml:/app/arch_config.yaml + + jaeger: + build: + context: ../shared/jaeger + ports: + - "16686:16686" + - "4317:4317" + - "4318:4318" diff --git a/demos/spotify/run_demo.sh b/demos/spotify/run_demo.sh new file mode 100644 index 00000000..eb47dce6 --- /dev/null +++ b/demos/spotify/run_demo.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -e + +# Function to start the demo +start_demo() { + # Step 1: Check if .env file exists + if [ -f ".env" ]; then + echo ".env file already exists. Skipping creation." + else + # Step 2: Create `.env` file and set OpenAI key + if [ -z "$OPENAI_API_KEY" ]; then + echo "Error: OPENAI_API_KEY environment variable is not set for the demo." + exit 1 + fi + + echo "Creating .env file..." + echo "OPENAI_API_KEY=$OPENAI_API_KEY" > .env + echo ".env file created with OPENAI_API_KEY." + fi + + # Step 3: Start Arch + echo "Starting Arch with arch_config.yaml..." + archgw up arch_config.yaml + + # Step 4: Start developer services + echo "Starting Network Agent using Docker Compose..." + docker compose up -d # Run in detached mode +} + +# Function to stop the demo +stop_demo() { + # Step 1: Stop Docker Compose services + echo "Stopping Network Agent using Docker Compose..." + docker compose down + + # Step 2: Stop Arch + echo "Stopping Arch..." + archgw down +} + +# Main script logic +if [ "$1" == "down" ]; then + stop_demo +else + # Default action is to bring the demo up + start_demo +fi