Initial commit: LlamaLink Go rewrite
Complete rewrite from Python/FastAPI to Go/Gin: - Go backend: auth (API keys + bcrypt), llama.cpp subprocess manager, hot-swap multi-model, rate limiting, quota system, webhooks - Vue 3 SPA admin panel (src/) with Tailwind CSS - Deployment: Docker multi-stage, docker-compose, nginx, systemd - GORM/SQLite models: ApiKey, Model, UsageLog, Quota, Webhook - REST API: /api/v1/admin/* (keys, models, chat, usage, health) - Embedded frontend via go:embed (build output at web/dist/) Removed legacy Python artifacts (app/, tests/, pyproject.toml, etc.)
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
.PHONY: build run test lint clean migrate dev prod deps fmt
|
||||
|
||||
# Binary name
|
||||
BINARY=llamalink
|
||||
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
|
||||
BUILD_TIME=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
|
||||
LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)"
|
||||
|
||||
# Directories
|
||||
BUILD_DIR=./bin
|
||||
FRONTEND_DIR=./web/frontend
|
||||
|
||||
# Go parameters
|
||||
GOCMD=go
|
||||
GOBUILD=$(GOCMD) build $(LDFLAGS)
|
||||
GOTEST=$(GOCMD) test
|
||||
GOGET=$(GOCMD) get
|
||||
GOMOD=$(GOCMD) mod
|
||||
GOFMT=gofmt
|
||||
GOLINT=golangci-lint
|
||||
|
||||
# Default target
|
||||
all: deps build
|
||||
|
||||
## build: Build the binary
|
||||
build:
|
||||
@echo "Building $(BINARY)..."
|
||||
@mkdir -p $(BUILD_DIR)
|
||||
$(GOBUILD) -o $(BUILD_DIR)/$(BINARY) ./cmd/llamalink
|
||||
|
||||
## run: Build and run
|
||||
run: build
|
||||
@echo "Running..."
|
||||
$(BUILD_DIR)/$(BINARY)
|
||||
|
||||
## dev: Run in development mode
|
||||
dev:
|
||||
LLAMALINK_ENV=development $(GOCMD) run ./cmd/llamalink
|
||||
|
||||
## test: Run tests
|
||||
test:
|
||||
$(GOTEST) -v -race -coverprofile=coverage.out ./...
|
||||
|
||||
## test/integration: Run integration tests
|
||||
test/integration:
|
||||
$(GOTEST) -v -tags=integration ./tests/integration/...
|
||||
|
||||
## lint: Run linters
|
||||
lint:
|
||||
$(GOLINT) run ./...
|
||||
|
||||
## fmt: Format code
|
||||
fmt:
|
||||
$(GOFMT) -s -w .
|
||||
|
||||
## deps: Download dependencies
|
||||
deps:
|
||||
$(GOMOD) download
|
||||
$(GOMOD) tidy
|
||||
|
||||
## clean: Remove build artifacts
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR)
|
||||
rm -f coverage.out
|
||||
rm -f *.db
|
||||
|
||||
## migrate/up: Run database migrations up
|
||||
migrate/up:
|
||||
migrate -path internal/db/migrations -database "$(DATABASE_URL)" up
|
||||
|
||||
## migrate/down: Run database migrations down
|
||||
migrate/down:
|
||||
migrate -path internal/db/migrations -database "$(DATABASE_URL)" down
|
||||
|
||||
## migrate/create: Create a new migration
|
||||
migrate/create NAME=add_users_table:
|
||||
migrate create -path internal/db/migrations -ext .sql -dir internal/db/migrations $(NAME)
|
||||
|
||||
## frontend/install: Install frontend dependencies
|
||||
frontend/install:
|
||||
cd $(FRONTEND_DIR) && npm install
|
||||
|
||||
## frontend/dev: Run frontend dev server
|
||||
frontend/dev:
|
||||
cd $(FRONTEND_DIR) && npm run dev
|
||||
|
||||
## frontend/build: Build frontend for production
|
||||
frontend/build:
|
||||
cd $(FRONTEND_DIR) && npm run build
|
||||
|
||||
## docker/build: Build Docker image
|
||||
docker/build:
|
||||
docker build -t llamalink:latest -f deploy/Dockerfile .
|
||||
|
||||
## docker/run: Run Docker container
|
||||
docker/run:
|
||||
docker-compose -f deploy/docker-compose.yml up
|
||||
|
||||
## docker/build/run: Build and run with docker-compose
|
||||
docker/build/run: docker/build docker/run
|
||||
|
||||
## help: Show this help
|
||||
help:
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
||||
Reference in New Issue
Block a user