-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
135 lines (106 loc) · 2.8 KB
/
Makefile
File metadata and controls
135 lines (106 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
.PHONY: all ui build build-backend run docker test clean deps docker-build docker-run docker-run-single docker-stop docker-clean
# Variables
BINARY_NAME=lawrence
BUILD_DIR=bin
UI_DIR=ui
DATA_DIR=data
all: ui build
# Install dependencies
deps:
go mod download
cd $(UI_DIR) && npm install
# Build UI
ui:
cd $(UI_DIR) && npm install && npm run build
# Build Go binary
build: ui
@echo "Building $(BINARY_NAME)..."
@mkdir -p $(BUILD_DIR)
go build -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/all-in-one
# Build Go binary without UI (for testing)
build-backend:
@echo "Building $(BINARY_NAME) (backend only)..."
@mkdir -p $(BUILD_DIR)
go build -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/all-in-one
# Build for Linux (for Docker)
build-linux:
@echo "Building $(BINARY_NAME) for Linux..."
@mkdir -p $(BUILD_DIR)
GOOS=linux GOARCH=amd64 go build -o $(BUILD_DIR)/$(BINARY_NAME)-linux ./cmd/all-in-one
# Run locally
run: build
@mkdir -p $(DATA_DIR)
./$(BUILD_DIR)/$(BINARY_NAME)
# Run with config
run-config: build
@mkdir -p $(DATA_DIR)
./$(BUILD_DIR)/$(BINARY_NAME) --config lawrence.yaml
# Build Docker image (legacy)
docker:
docker build -t lawrence/all-in-one:latest .
# Run Docker container (legacy - use docker-run for compose)
docker-run-single:
docker run -p 8080:8080 -p 4317:4317 -p 4318:4318 \
-v $(PWD)/$(DATA_DIR):/data \
lawrence/all-in-one:latest
# Run tests
test:
go test -v ./...
# Run tests with coverage
test-coverage:
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
# Format code
fmt:
go fmt ./...
# Lint code
lint:
golangci-lint run
# Clean build artifacts
clean:
rm -rf $(BUILD_DIR)
rm -rf $(UI_DIR)/dist
rm -rf $(DATA_DIR)
rm -f coverage.out coverage.html
# Development mode (watch and reload)
dev:
air
# Install development tools
install-tools:
go install github.com/air-verse/air@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# =============================================================================
# Docker Commands
# =============================================================================
# Build Docker image
docker-build:
docker build -t lawrence-oss:latest .
# Run with Docker Compose
docker-run:
docker compose up -d
# Stop all containers
docker-stop:
docker compose down
# Clean up Docker resources
docker-clean:
docker compose down -v
docker system prune -f
docker volume prune -f
# Build and run in one command
docker-quick:
docker compose up -d --build
# View logs
docker-logs:
docker compose logs -f
# View logs for backend only
docker-logs-backend:
docker compose logs -f lawrence
# View logs for UI only
docker-logs-ui:
docker compose logs -f ui
# Shell into backend container
docker-shell:
docker compose exec lawrence sh
# Shell into UI container
docker-shell-ui:
docker compose exec ui sh