From 231481d595b511f473700d7fc42389e908aed18e Mon Sep 17 00:00:00 2001 From: Pratham Mishra <99235987+Pratham-Mishra04@users.noreply.github.com> Date: Thu, 19 Jun 2025 14:45:39 +0530 Subject: [PATCH] feat: github workflow added for transport docker image --- .github/workflows/docker-build.yml | 82 ++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/docker-build.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000000..154ab3ef89 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,82 @@ +name: Build and Push HTTP Transport Docker Image + +on: + push: + tags: + - "transports/v*" # Triggers on version tags like transports/v1.0.0, transports/v2.1.0, etc. + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + REGISTRY: docker.io + ACCOUNT: maximhq + IMAGE_NAME: bifrost + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Extract and validate metadata + id: meta + run: | + # Extract tag name + TAG=${GITHUB_REF#refs/tags/} + echo "tag=${TAG}" >> $GITHUB_OUTPUT + + # Extract version from tag + VERSION=${TAG#transports/v} + + # Validate version format + if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then + echo "Error: Invalid tag format '$TAG'. Expected format: transports/vMAJOR.MINOR.PATCH" + exit 1 + fi + + # Create image tags + echo "tags<> $GITHUB_OUTPUT + echo "${{ env.REGISTRY }}/${{ env.ACCOUNT }}/${{ env.IMAGE_NAME }}:${TAG}" >> $GITHUB_OUTPUT + echo "${{ env.REGISTRY }}/${{ env.ACCOUNT }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: ./transports + file: ./transports/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: | + org.opencontainers.image.title=Bifrost LLM Gateway (HTTP) + org.opencontainers.image.description=The fastest LLM gateway written in Go. Learn more here: https://github.com/maximhq/bifrost + org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} + org.opencontainers.image.version=${{ steps.meta.outputs.tag }} + org.opencontainers.image.created=${{ github.event.head_commit.timestamp }} + org.opencontainers.image.revision=${{ github.sha }} + build-args: | + TRANSPORT_TYPE=http + platforms: linux/amd64,linux/arm64 + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Image digest + run: echo "Image pushed successfully with tags from previous step"