-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
55 lines (45 loc) · 1.54 KB
/
Makefile
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
BINARY_NAME = "chefbrowser"
RELEASE?=dev
DOCKER_NAMESPACE?=drewhammond
DOCKER_TAG?=latest
HOST_GOOS ?= $(shell go env GOOS)
HOST_GOARCH ?= $(shell go env GOARCH)
GIT_SHA=$(shell git rev-parse HEAD)
DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
BUILD_INFO_PATH="github.com/drewhammond/chefbrowser/internal/common/version"
BUILD_INFO=-ldflags "-X $(BUILD_INFO_PATH).version=$(RELEASE) -X $(BUILD_INFO_PATH).commitHash=$(GIT_SHA) -X $(BUILD_INFO_PATH).date=$(DATE)"
GOBUILD=CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -v -trimpath $(BUILD_INFO)
CURRENT_DIR=$(shell pwd)
DIST_DIR=$(CURDIR)/dist
TARGET_ARCH?=linux/amd64
.PHONY: lint
lint:
golangci-lint -v run
.PHONY: test
test:
go test -v ./...
.PHONY: fmt
fmt:
find . -name '*.go' | grep -v pb.go | grep -v vendor | xargs gofumpt -w
.PHONY: ui-deps
ui-deps:
cd $(CURDIR)/ui && yarn install
.PHONY: build
build: build-ui build-backend
.PHONY: build-backend
build-backend:
$(GOBUILD) -o $(DIST_DIR)/$(BINARY_NAME) .
.PHONY: build-ui
build-ui:
docker build -t chefbrowser-ui --platform=$(TARGET_ARCH) --target ui-builder .
find $(CURDIR)/ui/dist -type f -not -name gitkeep -delete || true
docker run --platform=$(TARGET_ARCH) -v $(CURDIR)/ui/dist:/tmp/app --rm -t chefbrowser-ui sh -c 'cp -r ./dist/* /tmp/app/'
.PHONY: build-linux
build-linux:
GOOS=linux GOARCH=amd64 TARGET_ARCH=linux/amd64 $(MAKE) build
.PHONY: build-docker
build-docker:
docker build --no-cache -t $(DOCKER_NAMESPACE)/$(BINARY_NAME):$(DOCKER_TAG) -f Dockerfile .
.PHONY: start-ui-dev
start-ui-dev: ui-deps
cd $(CURDIR)/ui && yarn run dev