Files
llama-link/Makefile
T
darroyo 0d6c8c7989
CI / test (push) Failing after 13m11s
Add embedded Vue SPA admin panel with go:embed
This is the complete fix for the missing /admin/ route and frontend serving:

Backend:
- internal/web/web.go: new package with go:embed for web/dist/
- internal/api/router.go: add routes for /admin/, /admin/*, /assets/*
- internal/db/db.go: fix SQLite DSN parsing (sqlite:///path -> path)

Build system:
- Makefile: new 'embed-prep' target copies web/dist to internal/web/dist
- make build now runs embed-prep -> frontend/build automatically

Deployment:
- deploy/llamalink.service: remove invalid --host/--port flags,
  add EnvironmentFile=/etc/llamalink/env

Verified:
- /health returns 200
- /admin/ serves Vue SPA HTML
- /assets/* serves CSS and JS files from embedded FS
- sqlite:///./llamalink.db works correctly
2026-07-31 14:47:15 -04:00

129 lines
3.3 KiB
Makefile

.PHONY: build run test lint clean migrate dev prod deps fmt deb release
# 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
DIST_DIR=./dist
FRONTEND_DIR=./web/frontend
DEB_ARCH=$(shell dpkg --print-architecture 2>/dev/null || echo "amd64")
# 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 (includes frontend embed)
build: embed-prep
@echo "Building $(BINARY)..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) -o $(BUILD_DIR)/$(BINARY) ./cmd/llamalink
## embed-prep: Copy web/dist into internal/web/dist for go:embed
embed-prep: frontend/build
@echo "Preparing embedded frontend..."
@rm -rf internal/web/dist
@mkdir -p internal/web/dist
@cp -r web/dist/* internal/web/dist/
## 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 ./cmd/... ./internal/...
## 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) $(DIST_DIR)
rm -rf internal/web/dist
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 (Usage: make migrate/create NAME=add_users_table)
migrate/create:
@if [ -z "$(NAME)" ]; then echo "Usage: make migrate/create NAME=add_users_table"; exit 1; fi
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
## deb: Build .deb package (requires dpkg-deb, Linux only)
deb: build
@echo "Building .deb package..."
@./scripts/build-deb.sh $(VERSION) $(DEB_ARCH)
## release: Build all release artifacts locally
release:
@echo "Building release artifacts for $(VERSION)..."
@mkdir -p $(DIST_DIR)
$(MAKE) build
$(MAKE) deb
@echo "Release artifacts in $(DIST_DIR)/"
## 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}'