From c87efa39c2a84276d528f9dcfd36260923801894 Mon Sep 17 00:00:00 2001
From: Nir Gazit
Date: Thu, 14 Nov 2024 10:23:39 +0200
Subject: [PATCH] fix: dockerfile
---
.cz.toml | 7 ++++
.github/workflows/release.yml | 78 +++++++++++++++++++++++++++++++++++
Cargo.lock | 40 +++++++++---------
Cargo.toml | 6 +--
Dockerfile | 47 +++++++++------------
README.md | 68 +++++++++++++++++++++++++++++-
src/main.rs | 8 ++--
7 files changed, 199 insertions(+), 55 deletions(-)
create mode 100644 .cz.toml
create mode 100644 .github/workflows/release.yml
diff --git a/.cz.toml b/.cz.toml
new file mode 100644
index 0000000..77bfa0b
--- /dev/null
+++ b/.cz.toml
@@ -0,0 +1,7 @@
+[tool.commitizen]
+name = "cz_conventional_commits"
+tag_format = "v$version"
+major_version_zero = true
+update_changelog_on_bump = true
+version = "0.0.0"
+version_files = ["Cargo.toml:^version"]
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..5ff7384
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,78 @@
+name: Release
+
+on:
+ workflow_dispatch:
+
+jobs:
+ bump-versions:
+ name: Bump Versions
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ persist-credentials: false
+ fetch-depth: 0
+
+ - id: cz
+ name: Bump Version, Create Tag and Changelog
+ uses: commitizen-tools/commitizen-action@master
+ with:
+ github_token: ${{ secrets.GH_ACCESS_TOKEN }}
+ changelog_increment_filename: body.md
+
+ - name: Create Release
+ uses: softprops/action-gh-release@v2
+ with:
+ body_path: "body.md"
+ tag_name: ${{ env.REVISION }}
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
+
+ - name: Print Version
+ run: echo "Bumped to version ${{ steps.cz.outputs.version }}"
+
+ release:
+ name: Release
+ runs-on: ubuntu-latest
+ permissions:
+ id-token: write
+ contents: read
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - 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=ref,event=branch
+ type=ref,event=pr
+ type=sha
+ type=semver,pattern={{version}}
+ type=semver,pattern={{major}}.{{minor}}
+ type=semver,pattern={{major}}
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v4
+ with:
+ context: .
+ push: true
+ tags: ${{ steps.docker-metadata.outputs.tags }}
+ labels: ${{ steps.docker-metadata.outputs.labels }}
+ platforms: |
+ linux/amd64
+ ${{ startsWith(github.ref, 'refs/tags/') && 'linux/arm64' || '' }}
diff --git a/Cargo.lock b/Cargo.lock
index c189d6f..5c9ad01 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -408,26 +408,6 @@ dependencies = [
"slab",
]
-[[package]]
-name = "gateway"
-version = "0.1.0"
-dependencies = [
- "anyhow",
- "axum",
- "axum-extra",
- "chrono",
- "reqwest",
- "serde",
- "serde_json",
- "serde_yaml",
- "tokio",
- "tower",
- "tower-http",
- "tracing",
- "tracing-subscriber",
- "uuid",
-]
-
[[package]]
name = "getrandom"
version = "0.2.15"
@@ -560,6 +540,26 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
+[[package]]
+name = "hub"
+version = "0.0.1"
+dependencies = [
+ "anyhow",
+ "axum",
+ "axum-extra",
+ "chrono",
+ "reqwest",
+ "serde",
+ "serde_json",
+ "serde_yaml",
+ "tokio",
+ "tower",
+ "tower-http",
+ "tracing",
+ "tracing-subscriber",
+ "uuid",
+]
+
[[package]]
name = "hyper"
version = "0.14.31"
diff --git a/Cargo.toml b/Cargo.toml
index 1577ae5..04d8166 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
-name = "gateway"
-version = "0.1.0"
+name = "hub"
+version = "0.0.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -17,6 +17,6 @@ tracing-subscriber = "0.3"
serde_yaml = "0.9"
tower = { version = "0.5.1", features = ["full"]}
anyhow = "1.0.92"
-tower-http = { version = "0.6.1", features = ["full"]}
+tower-http = { version = "0.6.1", features = ["full"] }
uuid = "1.11.0"
chrono = "0.4.38"
diff --git a/Dockerfile b/Dockerfile
index fbab7e1..7759d26 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,35 +1,26 @@
-ARG RUST_VERSION=1.82.0
-ARG APP_NAME=gateway
-FROM rust:${RUST_VERSION}-slim-bookworm AS build
-ARG APP_NAME
+FROM lukemathwalker/cargo-chef:0.1.68-rust-1.82-bookworm AS chef
WORKDIR /app
-RUN --mount=type=bind,source=src,target=src \
- --mount=type=bind,source=Cargo.toml,target=Cargo.toml \
- --mount=type=bind,source=Cargo.lock,target=Cargo.lock \
- --mount=type=cache,target=/app/target/ \
- --mount=type=cache,target=/usr/local/cargo/registry/ \
- <
+Traceloop Hub
+
+
+
Open-source, high-performance LLM gateway written in Rust. Connect to any LLM provider with a single API. Observability Included.
+
+
+
+
+
+Hub is a next generation smart proxy for LLM applications. It centralizes control and tracing of all LLM calls and traces.
+It's built in Rust so it's fast and efficient. It's completely open-source and free to use.
+
+Built and maintained by Traceloop under the Apache 2.0 license.
+
+## ๐ Getting Started
+
+You can run the hub locally by running `cargo run` in the root directory, or using the docker image:
+
+```
+docker run --rm -v $(pwd)/config.yaml:/etc/config.yaml:ro -t hub
+```
+
+## ๐ฑ Contributing
+
+Whether big or small, we love contributions โค๏ธ Check out our guide to see how to [get started](https://traceloop.com/docs/hub/contributing/overview).
+
+Not sure where to get started? You can:
+
+- [Book a free pairing session with one of our teammates](mailto:nir@traceloop.com?subject=Pairing%20session&body=I'd%20like%20to%20do%20a%20pairing%20session!)!
+- Join our Slack, and ask us any questions there.
+
+## ๐ Community & Support
+
+- [Slack](https://traceloop.com/slack) (For live discussion with the community and the Traceloop team)
+- [GitHub Discussions](https://github.com/traceloop/hub/discussions) (For help with building and deeper conversations about features)
+- [GitHub Issues](https://github.com/traceloop/hub/issues) (For any bugs and errors you encounter using OpenLLMetry)
+- [Twitter](https://twitter.com/traceloopdev) (Get news fast)
diff --git a/src/main.rs b/src/main.rs
index a6e5f64..4be4dec 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,4 @@
-use gateway::{config::lib::load_config, routes, state::AppState};
+use hub::{config::lib::load_config, routes, state::AppState};
use std::sync::Arc;
use tracing::info;
@@ -6,9 +6,11 @@ use tracing::info;
async fn main() -> Result<(), anyhow::Error> {
tracing_subscriber::fmt::init();
- info!("Starting the application...");
+ info!("Starting Traceloop Hub...");
- let config = load_config("config.yaml")
+ let config_path = std::env::args().nth(1).unwrap_or("config.yaml".to_string());
+ info!("Loading configuration from {}", config_path);
+ let config = load_config(&config_path)
.map_err(|e| anyhow::anyhow!("Failed to load configuration: {}", e))?;
let state = Arc::new(
AppState::new(config).map_err(|e| anyhow::anyhow!("Failed to create app state: {}", e))?,