From bdd98b86a16f808f89389242afc6666c6bf163e5 Mon Sep 17 00:00:00 2001 From: doronkopit5 Date: Sun, 2 Mar 2025 19:31:14 +0200 Subject: [PATCH 1/9] lets see times --- .github/workflows/ci.yml | 61 +++++++++++++++++++++++++++++++++++- .github/workflows/docker.yml | 2 ++ Dockerfile | 39 ++++++++++++++++++----- 3 files changed, 93 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f3fa597..70b69d3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ env: CARGO_TERM_COLOR: always jobs: - build: + build-and-test: runs-on: ubuntu-latest steps: @@ -23,3 +23,62 @@ jobs: run: cargo build --verbose - name: Run tests run: cargo test --verbose + + build: + needs: build-and-test + strategy: + matrix: + platform: [amd64, arm64] + include: + - platform: amd64 + runs-on: ubuntu-latest + docker-platform: linux/amd64 + - platform: arm64 + runs-on: Linux-ARM64 + docker-platform: linux/arm64 + + runs-on: ${{ matrix.runs-on }} + steps: + - name: Checkout + uses: actions/checkout@v4 + + - 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 the GitHub Container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Extract metadata for Docker + id: docker-metadata + uses: docker/metadata-action@v4 + with: + images: | + ghcr.io/traceloop/hub # GitHub + traceloop/hub # Docker Hub + tags: | + type=sha + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: false + tags: ${{ steps.docker-metadata.outputs.tags }} + labels: ${{ steps.docker-metadata.outputs.labels }} + platforms: | + linux/amd64, linux/arm64 + cache-from: type=gha + cache-to: type=gha,mode=max \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 88ddc79..63b266b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -57,6 +57,8 @@ jobs: labels: ${{ steps.docker-metadata.outputs.labels }} platforms: | linux/amd64, linux/arm64 + cache-from: type=gha + cache-to: type=gha,mode=max deploy: name: Deploy to Traceloop runs-on: ubuntu-latest diff --git a/Dockerfile b/Dockerfile index eae16df..7cedff4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,39 @@ -FROM rust:1.82-bookworm AS builder - +FROM lukemathwalker/cargo-chef:latest-rust-1.82 AS chef WORKDIR /app + +# Planner stage - analyze dependencies +FROM chef AS planner +COPY . . +RUN cargo chef prepare --recipe-path recipe.json + +# Builder stage with dependency caching +FROM chef AS builder +COPY --from=planner /app/recipe.json recipe.json +# Build dependencies - this is the key caching layer +RUN cargo chef cook --release --recipe-path recipe.json +# Now build application code COPY . . RUN cargo build --release --bin hub -FROM debian:bookworm-slim AS runtime -RUN apt-get update && apt-get install -y openssl ca-certificates +# Runtime stage - using Alpine for smaller image +FROM alpine:3.19 AS runtime +# Install SSL certificates and minimal dependencies +RUN apk add --no-cache ca-certificates openssl libgcc + +# Create a non-root user to run the application +RUN addgroup -S app && adduser -S app -G app WORKDIR /app -COPY --from=builder /app/target/release/hub /usr/local/bin -WORKDIR /etc -ENV PORT 3000 +# Only copy the built binary +COPY --from=builder /app/target/release/hub /usr/local/bin/ +RUN chmod +x /usr/local/bin/hub + +# Set environment variables +ENV PORT=3000 EXPOSE 3000 -ENTRYPOINT ["/usr/local/bin/hub"] +# Use non-root user for better security +USER app + +# Set the entrypoint +ENTRYPOINT ["/usr/local/bin/hub"] \ No newline at end of file From 2cb1acb2db94bded3bad0a66971853a9153c1464 Mon Sep 17 00:00:00 2001 From: doronkopit5 Date: Sun, 2 Mar 2025 19:53:05 +0200 Subject: [PATCH 2/9] separate --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70b69d3..59f1ffa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,7 +78,6 @@ jobs: push: false tags: ${{ steps.docker-metadata.outputs.tags }} labels: ${{ steps.docker-metadata.outputs.labels }} - platforms: | - linux/amd64, linux/arm64 + platforms: ${{ matrix.docker-platform }} cache-from: type=gha cache-to: type=gha,mode=max \ No newline at end of file From f68efc48d2b466fc8ea4d68c1ff1df5a20d4fbce Mon Sep 17 00:00:00 2001 From: doronkopit5 Date: Sun, 2 Mar 2025 20:03:44 +0200 Subject: [PATCH 3/9] just ubuntu --- .github/workflows/ci.yml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 59f1ffa..b796f19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,18 +26,7 @@ jobs: build: needs: build-and-test - strategy: - matrix: - platform: [amd64, arm64] - include: - - platform: amd64 - runs-on: ubuntu-latest - docker-platform: linux/amd64 - - platform: arm64 - runs-on: Linux-ARM64 - docker-platform: linux/arm64 - - runs-on: ${{ matrix.runs-on }} + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 @@ -78,6 +67,7 @@ jobs: push: false tags: ${{ steps.docker-metadata.outputs.tags }} labels: ${{ steps.docker-metadata.outputs.labels }} - platforms: ${{ matrix.docker-platform }} + platforms: | + linux/amd64, linux/arm64 cache-from: type=gha cache-to: type=gha,mode=max \ No newline at end of file From 14476ef8578d47e393d42ac85c0a2afda2df26b8 Mon Sep 17 00:00:00 2001 From: doronkopit5 Date: Sun, 2 Mar 2025 20:54:03 +0200 Subject: [PATCH 4/9] just test time changes --- src/providers/azure/provider.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/providers/azure/provider.rs b/src/providers/azure/provider.rs index 31b64e5..79725c8 100644 --- a/src/providers/azure/provider.rs +++ b/src/providers/azure/provider.rs @@ -167,12 +167,12 @@ impl Provider for AzureProvider { let status = response.status(); if status.is_success() { response.json().await.map_err(|e| { - eprintln!("Azure OpenAI Embeddings API response error: {}", e); + eprintln!("Azure Embeddings API response error: {}", e); StatusCode::INTERNAL_SERVER_ERROR }) } else { eprintln!( - "Azure OpenAI Embeddings API request error: {}", + "Azure Embeddings API request error: {}", response.text().await.unwrap() ); Err(StatusCode::from_u16(status.as_u16()).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)) From 5ee2831a317519ed9e2cc9b235de167042f33657 Mon Sep 17 00:00:00 2001 From: doronkopit5 Date: Sun, 2 Mar 2025 21:46:29 +0200 Subject: [PATCH 5/9] rev --- src/providers/azure/provider.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/providers/azure/provider.rs b/src/providers/azure/provider.rs index 79725c8..31b64e5 100644 --- a/src/providers/azure/provider.rs +++ b/src/providers/azure/provider.rs @@ -167,12 +167,12 @@ impl Provider for AzureProvider { let status = response.status(); if status.is_success() { response.json().await.map_err(|e| { - eprintln!("Azure Embeddings API response error: {}", e); + eprintln!("Azure OpenAI Embeddings API response error: {}", e); StatusCode::INTERNAL_SERVER_ERROR }) } else { eprintln!( - "Azure Embeddings API request error: {}", + "Azure OpenAI Embeddings API request error: {}", response.text().await.unwrap() ); Err(StatusCode::from_u16(status.as_u16()).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR)) From 79c92c65da7e1e5e39e0a41094cc05156f33d0bc Mon Sep 17 00:00:00 2001 From: doronkopit5 Date: Tue, 13 May 2025 11:55:46 +0300 Subject: [PATCH 6/9] test on ci --- .github/workflows/ci.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b796f19..6e06e29 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,13 +24,6 @@ jobs: - name: Run tests run: cargo test --verbose - build: - needs: build-and-test - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx From 9c2d6642bdf112f677594080738c4123c0eaa138 Mon Sep 17 00:00:00 2001 From: doronkopit5 Date: Tue, 13 May 2025 12:24:25 +0300 Subject: [PATCH 7/9] test again --- .github/workflows/ci.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e06e29..fb3c1b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ env: CARGO_TERM_COLOR: always jobs: - build-and-test: + build: runs-on: ubuntu-latest steps: @@ -24,6 +24,13 @@ jobs: - name: Run tests run: cargo test --verbose + build-and-test: + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx From 8a255455917ab7994a211c42b6373e561cebcc77 Mon Sep 17 00:00:00 2001 From: doronkopit5 Date: Tue, 13 May 2025 19:09:08 +0300 Subject: [PATCH 8/9] try like this --- .github/workflows/ci.yml | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb3c1b1..51d3d0d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,15 +24,23 @@ jobs: - name: Run tests run: cargo test --verbose - build-and-test: + docker-build-test: + name: Docker Build and needs: build - runs-on: ubuntu-latest + strategy: + matrix: + include: + - platform: amd64 + runs-on: ubuntu-latest + docker-platform: linux/amd64 + - platform: arm64 + runs-on: ubuntu-22.04-arm # GitHub's public ARM runner + docker-platform: linux/arm64 + runs-on: ${{ matrix.runs-on }} steps: - name: Checkout uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -60,14 +68,15 @@ jobs: type=sha type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - - name: Build and push Docker image - uses: docker/build-push-action@v4 + - name: Build Docker image + uses: docker/build-push-action@v5 with: context: . push: false + platforms: ${{ matrix.docker-platform }} tags: ${{ steps.docker-metadata.outputs.tags }} labels: ${{ steps.docker-metadata.outputs.labels }} - platforms: | - linux/amd64, linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max \ No newline at end of file + cache-from: type=gha,scope=${{ matrix.platform }} + cache-to: type=gha,mode=max,scope=${{ matrix.platform }} + sbom: false + provenance: false \ No newline at end of file From e767cb434e03c42425869e0f5b362d2d776edfc1 Mon Sep 17 00:00:00 2001 From: doronkopit5 Date: Tue, 13 May 2025 19:43:26 +0300 Subject: [PATCH 9/9] lets see --- src/pipelines/pipeline.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pipelines/pipeline.rs b/src/pipelines/pipeline.rs index 36301fd..ca94c78 100644 --- a/src/pipelines/pipeline.rs +++ b/src/pipelines/pipeline.rs @@ -102,7 +102,7 @@ pub async fn chat_completions( } } - tracer.log_error("No matching model found".to_string()); + tracer.log_error("No matching model found ".to_string()); eprintln!("No matching model found for: {}", payload.model); Err(StatusCode::NOT_FOUND) }