-
Notifications
You must be signed in to change notification settings - Fork 69
/
Makefile
138 lines (101 loc) · 4.87 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
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
136
137
138
.DEFAULT_GOAL := help
GIT_ROOT ?= $(shell git rev-parse --show-toplevel)
GIT_COMMIT := $(shell git describe --match=NeVeRmAtCh --tags --always --dirty | cut -c 1-7)
BUILD_DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
ifndef VERSION
VERSION := $(shell git describe --tags `git rev-list --tags --max-count=1` | sed 's/v\(\)/\1/')
endif
PKG := github.com/bentoml/yatai
VERSION_BUILDFLAGS := -X '$(PKG)/api-server/version.GitCommit=$(GIT_COMMIT)' -X '$(PKG)/api-server/version.Version=$(VERSION)' -X '$(PKG)/api-server/version.BuildDate=$(BUILD_DATE)'
DOCKER_REGISTRY := quay.io/bentoml
BUILDER_IMG := $(DOCKER_REGISTRY)/yatai-builder:1.0
UI_BUILDER_IMG := $(DOCKER_REGISTRY)/yatai-ui-builder:1.0
YATAI_IMG := $(DOCKER_REGISTRY)/yatai:$(GIT_COMMIT)
GOMOD_CACHE ?= "$(GOPATH)/pkg/mod"
BASE_CNTR_ARGS := -u root \
--privileged --rm --net=host \
-v ${GOMOD_CACHE}:/go/pkg/mod \
-v $(realpath /etc/localtime):/etc/localtime:ro \
-v $(PWD):/code \
-w /code
BUILDER_CNTR_ARGS := $(BASE_CNTR_ARGS) $(BUILDER_IMG)
BUILDER_CNTR_CMD := docker run $(BUILDER_CNTR_ARGS)
BUILDER_CNTR_TTY_CMD := docker run -it $(BUILDER_CNTR_ARGS)
UI_BUILDER_CNTR_ARGS := $(BASE_CNTR_ARGS) $(UI_BUILDER_IMG)
UI_BUILDER_CNTR_CMD := docker run $(UI_BUILDER_CNTR_ARGS)
UI_BUILDER_CNTR_TTY_CMD := docker run -it $(UI_BUILDER_CNTR_ARGS)
pull-ui-builder-image:
docker pull $(UI_BUILDER_IMG) || true
pull-builder-image:
docker pull $(BUILDER_IMG) || true
docker-build-ui: pull-ui-builder-image ## Docker build UI
$(UI_BUILDER_CNTR_CMD) sh -c "cd dashboard; ln -s /cache/node_modules ./node_modules; yarn build"
echo "build ui done"
docker-golint: pull-builder-image ## Docker golint
$(BUILDER_CNTR_CMD) ./scripts/ci/golint.sh
docker-gofmt-chk: pull-builder-image ## Docker gofmt-check
$(BUILDER_CNTR_CMD) ./scripts/ci/gofmt-check.sh
docker-gofmt-fmt: pull-builder-image ## Docker gofmt
$(BUILDER_CNTR_CMD) ./scripts/ci/gofmt.sh -w
docker-eslint: pull-ui-builder-image ## Docker eslint
$(UI_BUILDER_CNTR_CMD) sh -c "cd dashboard; ln -s /cache/node_modules ./node_modules; yarn lint"
docker-ui-typecheck: pull-ui-builder-image ## Docker typecheck
$(UI_BUILDER_CNTR_CMD) sh -c "cd dashboard; ln -s /cache/node_modules ./node_modules; yarn typecheck"
docker-build-api-server: ## Build api-server binary
@mkdir -p ./bin
@mkdir -p /tmp/buildx-cache/
@docker buildx build -f Dockerfile-builder --build-arg VERSION_BUILDFLAGS="$(VERSION_BUILDFLAGS)" --output bin --cache-from type=local,src=/tmp/buildx-cache --cache-to type=local,mode=max,dest=/tmp/buildx-cache-new .
build-api-server:
mkdir -p ./bin
go build -ldflags "$(VERSION_BUILDFLAGS)" -o ./bin/api-server ./api-server/main.go
build-s3-client-image:
docker build -t quay.io/bentoml/s3-client:0.0.1 -f Dockerfile-s3-client .
docker push quay.io/bentoml/s3-client:0.0.1
build-builder-image: ## Build builder image
docker build -f Dockerfile-builder -t $(BUILDER_IMG) . || exit 1
docker push $(BUILDER_IMG)
build-ui-builder-image: pull-ui-builder-image ## Build UI builder image
docker build -f Dockerfile-ui-builder -t $(UI_BUILDER_IMG) . || exit 1
docker push $(UI_BUILDER_IMG)
build-image: ## Build Yatai image
docker build -t $(YATAI_IMG) .
docker push $(YATAI_IMG)
tag-release: ## Tag Yatai image as release
docker tag $(YATAI_IMG) $(DOCKER_REGISTRY)/yatai:$(VERSION)
docker push $(DOCKER_REGISTRY)/yatai:$(VERSION)
build: docker-build-ui docker-build-api-server build-image ## Build pipeline
ui-builder-cli:
$(UI_BUILDER_CNTR_TTY_CMD) sh
help: ## Show all Makefile targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
yatai-dev: ## Run yatai(be and fe) in development mode
@make -j2 be-run fe-run
be-deps: ## Fetch Golang deps
@echo "Downloading go modules..."
@go mod download
build-api-server-dev: ## Build api-server binary in development mode
@go build -gcflags="all=-N -l" -ldflags "$(VERSION_BUILDFLAGS)" -o ./bin/api-server ./api-server/main.go
show-api-server-version:
@./bin/api-server version
run-api-server: build-api-server-dev show-api-server-version ## Run api-server in development mode
@./bin/api-server serve
fe-deps: ## Fetch frontend deps
@cd dashboard && yarn
fe-build: ## Build frontend for production
@cd dashboard && yarn build
fe-run: ## Run frontend components
@cd dashboard && yarn start
install-docs-deps: ## Install documentation dependencies
@echo Installing docs dependencies...
@pip install -r requirements/docs-requirements.txt
# Docs
watch-docs: install-docs-deps ## Build and watch documentation
sphinx-autobuild docs/source docs/build/html --watch $(GIT_ROOT)/docs/source --host 0.0.0.0
spellcheck-docs: ## Spell check documentation
sphinx-build -b spelling -W ./docs/source ./docs/build
linkcheck-docs: ## Check documentation links
sphinx-build -b linkcheck -W ./docs/source ./docs/build
start-dev:
./scripts/start-dev.sh
stop-dev:
telepresence leave yatai-yatai-system