-
-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathMakefile
More file actions
72 lines (58 loc) · 1.92 KB
/
Makefile
File metadata and controls
72 lines (58 loc) · 1.92 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
# Variables
GOHOSTOS:=$(shell go env GOHOSTOS)
GOHOSTARCH:=$(shell go env GOHOSTARCH)
GOPATH:=$(shell go env GOPATH)
VERSION=$(shell git describe --tags --always)
BUILD_TIME=$(shell date +%Y-%m-%dT%H:%M:%S)
GIT_COMMIT=$(shell git rev-parse HEAD)
# Docker variables
DOCKER_REGISTRY?=sn0wl1n
IMAGE_NAME?=ech0
IMAGE_TAG?=latest
OS?=$(if $(GOHOSTOS),$(GOHOSTOS),linux)
ARCH?=$(if $(GOHOSTARCH),$(GOHOSTARCH),amd64)
.PHONY: help air-install run dev web-dev lint fmt test wire wire-check build-image push-image
AIR_BIN := $(shell command -v air 2>/dev/null || echo "$(GOPATH)/bin/air")
help:
@echo "Available targets:"
@echo " make run - Run backend in serve mode"
@echo " make dev - Run backend with Air hot reload"
@echo " make air-install - Install Air to GOPATH/bin"
@echo " make web-dev - Run frontend dev server"
@echo " make lint - Run golangci-lint checks"
@echo " make fmt - Run golangci-lint formatters"
@echo " make test - Run Go tests"
@echo " make wire - Generate DI code via Wire"
@echo " make wire-check - Verify Wire code is up-to-date"
@echo " make build-image - Build Docker image"
@echo " make push-image - Push Docker image"
air-install:
go install github.com/air-verse/air@latest
run:
go run ./cmd/ech0 serve
dev:
@if [ ! -x "$(AIR_BIN)" ]; then \
echo "air not found, installing..."; \
$(MAKE) air-install; \
fi
"$(AIR_BIN)" -c .air.toml
web-dev:
cd web && pnpm dev
lint:
golangci-lint run
fmt:
golangci-lint fmt
test:
go test ./...
wire:
go generate ./internal/di
wire-check: wire
git diff --exit-code -- internal/di/wire_gen.go
build-image:
@echo "Building image for platform: $(OS)/$(ARCH)"
docker build --platform $(OS)/$(ARCH) \
--build-arg TARGETOS=$(OS) \
--build-arg TARGETARCH=$(ARCH) \
-t $(DOCKER_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG) -f build.Dockerfile .
push-image:
docker push $(DOCKER_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)