1
+ # Makefile for Bifrost
2
+
3
+ # Variables
4
+ CONFIG_FILE ?= transports/config.example.json
5
+ PORT ?= 8080
6
+ POOL_SIZE ?= 300
7
+ PLUGINS ?= maxim
8
+ PROMETHEUS_LABELS ?=
9
+
10
+ # Colors for output
11
+ RED =\033[0;31m
12
+ GREEN =\033[0;32m
13
+ YELLOW =\033[1;33m
14
+ BLUE =\033[0;34m
15
+ CYAN =\033[0;36m
16
+ NC =\033[0m # No Color
17
+
18
+ .PHONY : help dev dev-ui build run install-air clean test install-ui
19
+
20
+ # Default target
21
+ help : # # Show this help message
22
+ @echo " $( BLUE) Bifrost Development - Available Commands:$( NC) "
23
+ @echo " "
24
+ @grep -E ' ^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | sort | awk ' BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-15s$(NC) %s\n", $$1, $$2}'
25
+ @echo " "
26
+ @echo " $( YELLOW) Environment Variables:$( NC) "
27
+ @echo " CONFIG_FILE Path to config file (default: transports/config.example.json)"
28
+ @echo " PORT Server port (default: 8080)"
29
+ @echo " POOL_SIZE Connection pool size (default: 300)"
30
+ @echo " PLUGINS Comma-separated plugins to load (default: maxim)"
31
+ @echo " PROMETHEUS_LABELS Labels for Prometheus metrics"
32
+
33
+
34
+ install-ui :
35
+ @which node > /dev/null || (echo " $( RED) Error: Node.js is not installed. Please install Node.js first.$( NC) " && exit 1)
36
+ @which npm > /dev/null || (echo " $( RED) Error: npm is not installed. Please install npm first.$( NC) " && exit 1)
37
+ @echo " $( GREEN) Node.js and npm are installed$( NC) "
38
+ @cd ui && npm install
39
+ @which next > /dev/null || (echo " $( YELLOW) Installing nextjs...$( NC) " && npm install -g next)
40
+ @echo " $( GREEN) UI deps are in sync$( NC) "
41
+
42
+ install-air : # # Install air for hot reloading (if not already installed)
43
+ @which air > /dev/null || (echo " $( YELLOW) Installing air for hot reloading...$( NC) " && go install github.com/air-verse/air@latest)
44
+ @echo " $( GREEN) Air is ready$( NC) "
45
+
46
+ dev-http : install-ui install-air # # Start complete development environment (UI + API with proxy)
47
+ @echo " $( GREEN) Starting Bifrost complete development environment...$( NC) "
48
+ @echo " $( YELLOW) This will start:$( NC) "
49
+ @echo " 1. UI development server (localhost:3000)"
50
+ @echo " 2. API server with UI proxy (localhost:$( PORT) /ui)"
51
+ @echo " $( CYAN) Access everything at: http://localhost:$( PORT) /ui$( NC) "
52
+ @echo " "
53
+ @echo " $( YELLOW) Starting UI development server...$( NC) "
54
+ @cd ui && npm run dev &
55
+ @sleep 3
56
+ @echo " $( YELLOW) Starting API server with UI proxy...$( NC) "
57
+ @cd transports/bifrost-http && BIFROST_UI_DEV=true air -c .air.toml -- \
58
+ -port " $( PORT) " \
59
+ -plugins " $( PLUGINS) " \
60
+ $(if $(PROMETHEUS_LABELS ) ,-prometheus-labels "$(PROMETHEUS_LABELS ) ")
61
+
62
+ build : # # Build bifrost-http binary
63
+ @echo " $( GREEN) Building bifrost-http...$( NC) "
64
+ @cd transports/bifrost-http && go build -o ../../tmp/bifrost-http .
65
+ @echo " $( GREEN) Built: tmp/bifrost-http$( NC) "
66
+
67
+ run : build # # Build and run bifrost-http (no hot reload)
68
+ @echo " $( GREEN) Running bifrost-http...$( NC) "
69
+ @./tmp/bifrost-http \
70
+ -config " $( CONFIG_FILE) " \
71
+ -port " $( PORT) " \
72
+ -pool-size $(POOL_SIZE ) \
73
+ -plugins " $( PLUGINS) " \
74
+ $(if $(PROMETHEUS_LABELS ) ,-prometheus-labels "$(PROMETHEUS_LABELS ) ")
75
+
76
+
77
+ clean : # # Clean build artifacts and temporary files
78
+ @echo " $( YELLOW) Cleaning build artifacts...$( NC) "
79
+ @rm -rf tmp/
80
+ @rm -f transports/bifrost-http/build-errors.log
81
+ @rm -rf transports/bifrost-http/tmp/
82
+ @echo " $( GREEN) Clean complete$( NC) "
83
+
84
+ test : # # Run tests for bifrost-http
85
+ @echo " $( GREEN) Running bifrost-http tests...$( NC) "
86
+ @cd transports/bifrost-http && go test -v ./...
87
+
88
+ test-core : # # Run core tests
89
+ @echo " $( GREEN) Running core tests...$( NC) "
90
+ @cd core && go test -v ./...
91
+
92
+ test-plugins : # # Run plugin tests
93
+ @echo " $( GREEN) Running plugin tests...$( NC) "
94
+ @cd plugins && find . -name " *.go" -path " */tests/*" -o -name " *_test.go" | head -1 > /dev/null && \
95
+ for dir in $$ (find . -name " *_test.go" -exec dirname {} \; | sort -u); do \
96
+ echo " Testing $$ dir..." ; \
97
+ cd $$ dir && go test -v ./... && cd - > /dev/null; \
98
+ done || echo " No plugin tests found"
99
+
100
+ test-all : test-core test-plugins test # # Run all tests
101
+
102
+ # Quick start with example config
103
+ quick-start : # # Quick start with example config and maxim plugin
104
+ @echo " $( GREEN) Quick starting Bifrost with example configuration...$( NC) "
105
+ @$(MAKE ) dev CONFIG_FILE=transports/config.example.json PLUGINS=maxim
106
+
107
+ # Docker targets
108
+ docker-build : # # Build Docker image
109
+ @echo " $( GREEN) Building Docker image...$( NC) "
110
+ @cd transports && docker build -t bifrost .
111
+ @echo " $( GREEN) Docker image built: bifrost$( NC) "
112
+
113
+ docker-run : # # Run Docker container
114
+ @echo " $( GREEN) Running Docker container...$( NC) "
115
+ @docker run -p $(PORT ) :$(PORT ) \
116
+ -v $(PWD ) /$(CONFIG_FILE ) :/app/config/config.json \
117
+ --env-file <( env | grep -E ' ^(OPENAI|ANTHROPIC|AZURE|AWS|COHERE|VERTEX)_' ) \
118
+ bifrost
119
+
120
+ # Linting and formatting
121
+ lint : # # Run linter for Go code
122
+ @echo " $( GREEN) Running golangci-lint...$( NC) "
123
+ @golangci-lint run ./...
124
+
125
+ fmt : # # Format Go code
126
+ @echo " $( GREEN) Formatting Go code...$( NC) "
127
+ @gofmt -s -w .
128
+ @goimports -w .
129
+
130
+ # Git hooks and development setup
131
+ setup-git-hooks : # # Set up Git hooks for development
132
+ @echo " $( GREEN) Setting up Git hooks...$( NC) "
133
+ @echo " #!/bin/sh\nmake fmt\nmake lint" > .git/hooks/pre-commit
134
+ @chmod +x .git/hooks/pre-commit
135
+ @echo " $( GREEN) Git hooks installed$( NC) "
0 commit comments