.PHONY: all build-backend build-frontend clean dev run

# Default target: build everything
all: build-frontend build-backend

# Build the Vue 3 frontend
build-frontend:
	cd web && npm install && npm run build

# Build the Go backend (with embedded frontend)
build-backend:
	go build -o ci-server .

# Build for Linux (cross-compile)
build-linux:
	GOOS=linux GOARCH=amd64 go build -o ci-server .

# Clean build artifacts
clean:
	rm -rf ci-server ci-server.exe web/dist data

# Run in development mode (frontend proxied via Vite)
dev:
	@echo "Start the Go server in one terminal: go run ."
	@echo "Start the Vite dev server in another: cd web && npm run dev"
	@echo "Then open http://localhost:5173"

# Run the production server (requires frontend built)
run: build-frontend
	go run .
