-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (65 loc) · 2.23 KB
/
Makefile
File metadata and controls
77 lines (65 loc) · 2.23 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
.PHONY: dev backend frontend build clean install vet lint update docker-build
# Version info (auto-detected from git tags, can be overridden)
IMAGE_NAME ?= jjeffers/awscogs
VERSION ?= $(shell git describe --tags --match 'v*' --abbrev=0 2>/dev/null || echo "0.0.0-dev")
GIT_COMMIT ?= $(shell git rev-parse HEAD 2>/dev/null || echo "unknown")
BUILD_TIME ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
# Linker flags for version injection
LDFLAGS = -X github.com/johnjeffers/awscogs/backend/internal/version.Version=$(VERSION) \
-X github.com/johnjeffers/awscogs/backend/internal/version.GitCommit=$(GIT_COMMIT) \
-X github.com/johnjeffers/awscogs/backend/internal/version.BuildTime=$(BUILD_TIME)
# Run both backend and frontend for local development
dev: install
@trap 'kill 0' EXIT; \
$(MAKE) backend & \
$(MAKE) frontend & \
wait
# Run the Go backend
backend:
cd backend && go run ./cmd/awscogs
# Run the React frontend dev server
frontend:
cd frontend && npm run dev
# Install dependencies
install:
cd frontend && npm install
cd backend && go mod download
# Update dependencies to latest versions
update:
cd backend && go get -u ./... && go mod tidy
cd frontend && npx npm-check-updates -u && npm install
# Build for production (single binary with embedded frontend)
build:
cd frontend && npm run build
rm -rf backend/internal/api/dist
cp -r frontend/dist backend/internal/api/dist
cd backend && go build -ldflags='$(LDFLAGS)' -o bin/awscogs ./cmd/awscogs
# Run go vet and staticcheck on backend
vet:
cd backend && go vet ./...
cd backend && staticcheck ./...
# Format and lint both frontend and backend
lint:
cd backend && go fmt ./...
cd backend && go vet ./...
cd backend && staticcheck ./...
cd frontend && npm run format
cd frontend && npm run lint
cd frontend && npm run typecheck
# Clean build artifacts
clean:
rm -rf backend/bin
rm -rf backend/internal/api/dist
mkdir -p backend/internal/api/dist
touch backend/internal/api/dist/.gitkeep
rm -rf frontend/dist
rm -rf frontend/node_modules
# Build Docker image
docker-build:
docker build \
--build-arg VERSION=$(VERSION) \
--build-arg GIT_COMMIT=$(GIT_COMMIT) \
--build-arg BUILD_TIME=$(BUILD_TIME) \
-t $(IMAGE_NAME):$(VERSION) \
-t $(IMAGE_NAME):latest \
.