Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
insert_final_newline = false
end_of_line = lf
charset = utf-8

[*.{js,jsx,ts,tsx,mjs,json,md,css,scss,html}]
insert_final_newline = false
28 changes: 16 additions & 12 deletions .github/workflows/release-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ name: Release Pipeline
# Triggers automatically on push to main when any version file changes
on:
push:
branches: ["main"]
branches: ["main"]

# Prevent concurrent runs
concurrency:
group: release-pipeline
cancel-in-progress: false
cancel-in-progress: false
Comment thread
akshaydeo marked this conversation as resolved.

jobs:
# Check if pipeline should be skipped based on first line of commit message
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y jq

- name: Detect what needs release
id: detect
run: ./.github/workflows/scripts/detect-all-changes.sh "auto"
Expand Down Expand Up @@ -140,7 +140,7 @@ jobs:
- name: Release framework
id: release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: ./.github/workflows/scripts/release-framework.sh "${{ needs.detect-changes.outputs.framework-version }}"

plugins-release:
Expand Down Expand Up @@ -268,7 +268,7 @@ jobs:
IMAGE_NAME: bifrost
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -291,6 +291,8 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
build-args: |
VERSION=${{ needs.detect-changes.outputs.transport-version }}
file: ./transports/Dockerfile
push: true
tags: ${{ steps.tags.outputs.tags }}
Expand All @@ -311,7 +313,7 @@ jobs:
IMAGE_NAME: bifrost
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -336,12 +338,14 @@ jobs:
context: .
file: ./transports/Dockerfile
push: true
build-args: |
VERSION=${{ needs.detect-changes.outputs.transport-version }}
tags: ${{ steps.tags.outputs.tags }}
platforms: linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max

# Docker manifest
# Docker manifest
docker-manifest:
needs: [check-skip, detect-changes, docker-build-amd64, docker-build-arm64]
if: "always() && needs.check-skip.outputs.should-skip != 'true' && needs.docker-build-amd64.result == 'success' && needs.docker-build-arm64.result == 'success'"
Expand All @@ -352,8 +356,8 @@ jobs:
IMAGE_NAME: bifrost
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
Expand All @@ -362,8 +366,8 @@ jobs:

- name: Create and push multi-arch manifest
run: |
./.github/workflows/scripts/create-docker-manifest.sh "${{ needs.detect-changes.outputs.transport-version }}"
./.github/workflows/scripts/create-docker-manifest.sh "${{ needs.detect-changes.outputs.transport-version }}"

# Notification
notify:
needs: [check-skip, detect-changes, core-release, framework-release, plugins-release, bifrost-http-release, docker-manifest]
Expand All @@ -375,7 +379,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y jq

- name: Discord Notification
- name: Discord Notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
Expand Down
20 changes: 14 additions & 6 deletions .github/workflows/scripts/build-executables.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@
set -euo pipefail

# Cross-compile Go binaries for multiple platforms
# Usage: ./build-executables.sh
# Usage: ./build-executables.sh <version>

echo "🔨 Building Go executables..."
# Require version argument (matches usage)
if [[ -z "${1:-}" ]]; then
echo "Usage: $0 <version>" >&2
exit 1
fi
VERSION="$1"

echo "🔨 Building Go executables with version: $VERSION"

# Get the script directory and project root
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
Expand All @@ -14,6 +21,7 @@ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
rm -rf "$PROJECT_ROOT/dist"
mkdir -p "$PROJECT_ROOT/dist"


# Define platforms
platforms=(
"darwin/amd64"
Expand Down Expand Up @@ -55,8 +63,8 @@ for platform in "${platforms[@]}"; do
fi

env GOWORK=off CGO_ENABLED=1 GOOS="$GOOS" GOARCH="$GOARCH" CC="$CC_COMPILER" CXX="$CXX_COMPILER" \
go build -trimpath -tags "netgo,osusergo" \
-ldflags "-s -w -buildid=" \
go build -trimpath -tags "netgo,osusergo,sqlite_static" \
-ldflags "-s -w -buildid= -extldflags '-static' -X main.Version=${VERSION}" \
-o "$PROJECT_ROOT/dist/$PLATFORM_DIR/$GOARCH/$output_name" .

elif [[ "$GOOS" = "windows" ]]; then
Expand All @@ -66,7 +74,7 @@ for platform in "${platforms[@]}"; do
fi

env GOWORK=off CGO_ENABLED=1 GOOS="$GOOS" GOARCH="$GOARCH" CC="$CC_COMPILER" CXX="$CXX_COMPILER" \
go build -trimpath -ldflags "-s -w -buildid=" \
go build -trimpath -ldflags "-s -w -buildid= -X main.Version=${VERSION}" \
-o "$PROJECT_ROOT/dist/$PLATFORM_DIR/$GOARCH/$output_name" .

else # Darwin (macOS)
Expand All @@ -79,7 +87,7 @@ for platform in "${platforms[@]}"; do
fi

env GOWORK=off CGO_ENABLED=1 GOOS="$GOOS" GOARCH="$GOARCH" CC="$CC_COMPILER" CXX="$CXX_COMPILER" \
go build -trimpath -ldflags "-s -w -buildid=" \
go build -trimpath -ldflags "-s -w -buildid= -X main.Version=${VERSION}" \
-o "$PROJECT_ROOT/dist/$PLATFORM_DIR/$GOARCH/$output_name" .
fi

Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/scripts/release-bifrost-http.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ declare -A PLUGIN_VERSIONS
for plugin_dir in plugins/*/; do
if [ -d "$plugin_dir" ]; then
plugin_name=$(basename "$plugin_dir")

# Check if VERSION parameter contains prerelease suffix
if [[ "$VERSION" == *"-"* ]]; then
# VERSION has prerelease, so include all versions but prefer stable
ALL_TAGS=$(git tag -l "plugins/${plugin_name}/v*" | sort -V)
STABLE_TAGS=$(echo "$ALL_TAGS" | grep -v '\-')
PRERELEASE_TAGS=$(echo "$ALL_TAGS" | grep '\-')

if [ -n "$STABLE_TAGS" ]; then
# Get the highest stable version
LATEST_PLUGIN_TAG=$(echo "$STABLE_TAGS" | tail -1)
Expand All @@ -71,7 +71,7 @@ for plugin_dir in plugins/*/; do
LATEST_PLUGIN_TAG=$(git tag -l "plugins/${plugin_name}/v*" | grep -v '\-' | sort -V | tail -1)
echo "latest plugin tag (stable only): $LATEST_PLUGIN_TAG"
fi

if [ -z "$LATEST_PLUGIN_TAG" ]; then
# No matching release found, use version from file
PLUGIN_VERSION="v$(tr -d '\n\r' < "${plugin_dir}version")"
Expand All @@ -80,7 +80,7 @@ for plugin_dir in plugins/*/; do
PLUGIN_VERSION=${LATEST_PLUGIN_TAG#plugins/${plugin_name}/}
echo " 📦 $plugin_name: $PLUGIN_VERSION (latest release)"
fi

PLUGIN_VERSIONS["$plugin_name"]="$PLUGIN_VERSION"
fi
done
Expand All @@ -92,7 +92,7 @@ echo "🔍 Checking for additional plugins in transport go.mod..."
while IFS= read -r plugin_line; do
plugin_name=$(echo "$plugin_line" | awk -F'/' '{print $NF}' | awk '{print $1}')
current_version=$(echo "$plugin_line" | awk '{print $NF}')

# Only add if we don't already have this plugin
if [[ -z "${PLUGIN_VERSIONS[$plugin_name]:-}" ]]; then
echo " 📦 $plugin_name: $current_version (from transport go.mod)"
Expand All @@ -117,7 +117,7 @@ PLUGINS_USED=()
cd transports
for plugin_name in "${!PLUGIN_VERSIONS[@]}"; do
plugin_version="${PLUGIN_VERSIONS[$plugin_name]}"

# Check if transport depends on this plugin
if grep -q "github.com/maximhq/bifrost/plugins/$plugin_name" go.mod; then
echo " 📦 Using $plugin_name plugin $plugin_version"
Expand All @@ -131,7 +131,7 @@ done
echo " 🔧 Updating core to $CORE_VERSION"
go_get_with_backoff "github.com/maximhq/bifrost/core@$CORE_VERSION"

echo " 📦 Updating framework to $FRAMEWORK_VERSION"
echo " 📦 Updating framework to $FRAMEWORK_VERSION"
go_get_with_backoff "github.com/maximhq/bifrost/framework@$FRAMEWORK_VERSION"

go mod tidy
Expand All @@ -157,7 +157,7 @@ if ! git diff --cached --quiet; then
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
echo "🔧 Committing and pushing changes..."
git commit -m "transports: update dependencies --skip-pipeline"
git commit -m "transports: update dependencies --skip-pipeline"
git push -u origin HEAD
else
echo "ℹ️ No staged changes to commit"
Expand All @@ -169,7 +169,7 @@ bash ./.github/workflows/scripts/install-cross-compilers.sh

# Build Go executables
echo "🔨 Building executables..."
bash ./.github/workflows/scripts/build-executables.sh
bash ./.github/workflows/scripts/build-executables.sh $VERSION

# Configure and upload to R2
echo "📤 Uploading binaries..."
Expand Down
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
"tailwindFunctions": [
"cn",
"classNames"
]
],
"endOfLine": "lf"
}
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Variables
HOST ?= localhost
PORT ?= 8080
APP_DIR ?=
APP_DIR ?=
PROMETHEUS_LABELS ?=
LOG_STYLE ?= json
LOG_LEVEL ?= info
Expand All @@ -16,7 +16,7 @@ BLUE=\033[0;34m
CYAN=\033[0;36m
NC=\033[0m # No Color

.PHONY: all help dev build run install-air clean test install-ui setup-workspace work-init work-clean docs docker-build
.PHONY: all help dev build-ui build run install-air clean test install-ui setup-workspace work-init work-clean docs docker-build

all: help

Expand Down Expand Up @@ -77,13 +77,13 @@ build: build-ui ## Build bifrost-http binary
@echo "$(GREEN)Built: tmp/bifrost-http$(NC)"

docker-build: build-ui ## Build Docker image
@echo "$(GREEN)Building Docker image...$(NC)"
@echo "$(GREEN)Building Docker image...$(NC)"
@docker build -f transports/Dockerfile -t bifrost .
@echo "$(GREEN)Docker image built: bifrost$(NC)"

docker-run: ## Run Docker container
@echo "$(GREEN)Running Docker container...$(NC)"
@docker run -e APP_PORT=$(PORT) -e APP_HOST=0.0.0.0 -p $(PORT):$(PORT) -e LOG_LEVEL=$(LOG_LEVEL) -e LOG_STYLE=$(LOG_STYLE) -v $(shell pwd):/app/data bifrost
@docker run -e APP_PORT=$(PORT) -e APP_HOST=0.0.0.0 -p $(PORT):$(PORT) -e LOG_LEVEL=$(LOG_LEVEL) -e LOG_STYLE=$(LOG_STYLE) -v $(shell pwd):/app/data bifrost

docs: ## Prepare local docs
@echo "$(GREEN)Preparing local docs...$(NC)"
Expand Down
17 changes: 9 additions & 8 deletions transports/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# --- UI Build Stage: Build the Next.js frontend ---
FROM node:24-alpine AS ui-builder
FROM node:24-alpine3.22 AS ui-builder
Comment thread
akshaydeo marked this conversation as resolved.
WORKDIR /app

# Copy UI package files and install dependencies
Expand All @@ -15,7 +15,7 @@ RUN node scripts/fix-paths.js
# Skip the copy-build step since we'll copy the files in the Go build stage

# --- Go Build Stage: Compile the Go binary ---
FROM golang:1.24-alpine AS builder
FROM golang:1.24-alpine3.22 AS builder
WORKDIR /app

# Install dependencies including gcc for CGO and sqlite
Expand All @@ -36,12 +36,13 @@ COPY --from=ui-builder /app/out ./bifrost-http/ui

# Build the binary with CGO enabled and static SQLite linking
ENV GOWORK=off
ARG VERSION=unknown
RUN go build \
-ldflags="-w -s -extldflags '-static'" \
-a -trimpath \
-tags "sqlite_static" \
-o /app/main \
./bifrost-http
-ldflags="-w -s -extldflags '-static' -X main.Version=${VERSION}" \
-a -trimpath \
-tags "sqlite_static" \
-o /app/main \
./bifrost-http
Comment thread
akshaydeo marked this conversation as resolved.

# Compress binary with upx
RUN upx --best --lzma /app/main
Expand All @@ -50,7 +51,7 @@ RUN upx --best --lzma /app/main
RUN test -f /app/main || (echo "Build failed" && exit 1)

# --- Runtime Stage: Minimal runtime image ---
FROM alpine:3.19
FROM alpine:3.22
WORKDIR /app

# Create data directory and set up user
Expand Down
16 changes: 8 additions & 8 deletions transports/bifrost-http/handlers/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ func NewCacheHandler(plugin schemas.Plugin, logger schemas.Logger) *CacheHandler
}

func (h *CacheHandler) RegisterRoutes(r *router.Router) {
r.DELETE("/api/cache/clear/{request-id}", h.ClearCache)
r.DELETE("/api/cache/clear-by-key/{cache-key}", h.ClearCacheByKey)
r.DELETE("/api/cache/clear/{requestId}", h.clearCache)
r.DELETE("/api/cache/clear-by-key/{cacheKey}", h.clearCacheByKey)
}
Comment thread
akshaydeo marked this conversation as resolved.

func (h *CacheHandler) ClearCache(ctx *fasthttp.RequestCtx) {
requestID, ok := ctx.UserValue("request-id").(string)
func (h *CacheHandler) clearCache(ctx *fasthttp.RequestCtx) {
requestID, ok := ctx.UserValue("requestId").(string)
if !ok {
SendError(ctx, fasthttp.StatusBadRequest, "Invalid request ID", h.logger)
return
Expand All @@ -40,13 +40,13 @@ func (h *CacheHandler) ClearCache(ctx *fasthttp.RequestCtx) {
return
}

SendJSON(ctx, map[string]interface{}{
SendJSON(ctx, map[string]any{
"message": "Cache cleared successfully",
}, h.logger)
}

func (h *CacheHandler) ClearCacheByKey(ctx *fasthttp.RequestCtx) {
cacheKey, ok := ctx.UserValue("cache-key").(string)
func (h *CacheHandler) clearCacheByKey(ctx *fasthttp.RequestCtx) {
cacheKey, ok := ctx.UserValue("cacheKey").(string)
if !ok {
SendError(ctx, fasthttp.StatusBadRequest, "Invalid cache key", h.logger)
return
Expand All @@ -56,7 +56,7 @@ func (h *CacheHandler) ClearCacheByKey(ctx *fasthttp.RequestCtx) {
return
}

SendJSON(ctx, map[string]interface{}{
SendJSON(ctx, map[string]any{
"message": "Cache cleared successfully",
}, h.logger)
}
Loading