-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #478 from mmlb/build-image-from-make
## Description Adds make targets to build the docker images. ## Why is this needed Its not very obvious that a user needs to run `make crosscompile` before they can try to build the docker images (as came up in community slack yesterday). By having a proper target in the Makefile we might avoid this situation entirely. ## How Has This Been Tested? Ran `make images` ## Checklist: I have: - [x] updated the documentation and/or roadmap (if required) - [ ] added unit or e2e tests - [ ] provided instructions on how to upgrade
- Loading branch information
Showing
8 changed files
with
80 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,17 @@ | ||
# Only use the recipes defined in these makefiles | ||
MAKEFLAGS += --no-builtin-rules | ||
.SUFFIXES: | ||
# Delete target files if there's an error | ||
# This avoids a failure to then skip building on next run if the output is created by shell redirection for example | ||
# Not really necessary for now, but just good to have already if it becomes necessary later. | ||
.DELETE_ON_ERROR: | ||
# Treat the whole recipe as a one shell script/invocation instead of one-per-line | ||
.ONESHELL: | ||
# Use bash instead of plain sh | ||
SHELL := bash | ||
.SHELLFLAGS := -o pipefail -euc | ||
all: cli server worker ## Build all binaries for host OS and CPU | ||
|
||
server := cmd/tink-server/tink-server | ||
cli := cmd/tink-cli/tink-cli | ||
worker := cmd/tink-worker/tink-worker | ||
binaries := $(server) $(cli) $(worker) | ||
-include rules.mk | ||
|
||
version := $(shell git rev-parse --short HEAD) | ||
tag := $(shell git tag --points-at HEAD) | ||
ifneq (,$(tag)) | ||
version := $(tag)-$(version) | ||
endif | ||
LDFLAGS := -ldflags "-X main.version=$(version)" | ||
export CGO_ENABLED := 0 | ||
crosscompile: $(crossbinaries) ## Build all binaries for Linux and all supported CPU arches | ||
images: tink-cli-image tink-server-image tink-worker-image ## Build all docker images | ||
|
||
all: $(binaries) | ||
|
||
.PHONY: server $(binaries) cli worker test | ||
server: $(server) | ||
cli: $(cli) | ||
worker : $(worker) | ||
|
||
crossbinaries := $(addsuffix -linux-,$(binaries)) | ||
crossbinaries := $(crossbinaries:=386) $(crossbinaries:=amd64) $(crossbinaries:=arm64) $(crossbinaries:=armv6) $(crossbinaries:=armv7) | ||
crosscompile: $(crossbinaries) | ||
.PHONY: crosscompile $(crossbinaries) | ||
|
||
%-386: FLAGS=GOOS=linux GOARCH=386 | ||
%-amd64: FLAGS=GOOS=linux GOARCH=amd64 | ||
%-arm64: FLAGS=GOOS=linux GOARCH=arm64 | ||
%-armv6: FLAGS=GOOS=linux GOARCH=arm GOARM=6 | ||
%-armv7: FLAGS=GOOS=linux GOARCH=arm GOARM=7 | ||
$(binaries) $(crossbinaries): | ||
$(FLAGS) go build $(LDFLAGS) -o $@ ./$(@D) | ||
|
||
run: cmd/tink-cli/tink-cli-linux-amd64 cmd/tink-server/tink-server-linux-amd64 cmd/tink-worker/tink-worker-linux-amd64 | ||
docker-compose up -d --build db | ||
docker-compose up --build tinkerbell boots | ||
test: | ||
test: ## Run tests | ||
go clean -testcache | ||
go test ./... -v | ||
|
||
verify: | ||
verify: ## Run lint like checkers | ||
goimports -d . | ||
golint ./... | ||
|
||
protos/gen_mock: | ||
go generate ./protos/**/* | ||
goimports -w ./protos/**/mock.go | ||
|
||
grpc/gen_doc: | ||
protoc \ | ||
-I./protos \ | ||
-I./protos/third_party \ | ||
--doc_out=./doc \ | ||
--doc_opt=html,index.html \ | ||
protos/hardware/*.proto protos/template/*.proto protos/workflow/*.proto | ||
help: ## Print this help | ||
@grep --no-filename -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sed 's/:.*##/·/' | sort | column -ts '·' -c 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Only use the recipes defined in these makefiles | ||
MAKEFLAGS += --no-builtin-rules | ||
.SUFFIXES: | ||
# Delete target files if there's an error | ||
# This avoids a failure to then skip building on next run if the output is created by shell redirection for example | ||
# Not really necessary for now, but just good to have already if it becomes necessary later. | ||
.DELETE_ON_ERROR: | ||
# Treat the whole recipe as a one shell script/invocation instead of one-per-line | ||
.ONESHELL: | ||
# Use bash instead of plain sh | ||
SHELL := bash | ||
.SHELLFLAGS := -o pipefail -euc | ||
|
||
binaries := cmd/tink-cli/tink-cli cmd/tink-server/tink-server cmd/tink-worker/tink-worker | ||
version := $(shell git rev-parse --short HEAD) | ||
tag := $(shell git tag --points-at HEAD) | ||
ifneq (,$(tag)) | ||
version := $(tag)-$(version) | ||
endif | ||
LDFLAGS := -ldflags "-X main.version=$(version)" | ||
export CGO_ENABLED := 0 | ||
|
||
cli: cmd/tink-cli/tink-cli | ||
server: cmd/tink-server/tink-server | ||
worker : cmd/tink-worker/tink-worker | ||
|
||
.PHONY: server cli worker test $(binaries) | ||
crossbinaries := $(addsuffix -linux-,$(binaries)) | ||
crossbinaries := $(crossbinaries:=386) $(crossbinaries:=amd64) $(crossbinaries:=arm64) $(crossbinaries:=armv6) $(crossbinaries:=armv7) | ||
|
||
.PHONY: crosscompile $(crossbinaries) | ||
%-386: FLAGS=GOOS=linux GOARCH=386 | ||
%-amd64: FLAGS=GOOS=linux GOARCH=amd64 | ||
%-arm64: FLAGS=GOOS=linux GOARCH=arm64 | ||
%-armv6: FLAGS=GOOS=linux GOARCH=arm GOARM=6 | ||
%-armv7: FLAGS=GOOS=linux GOARCH=arm GOARM=7 | ||
$(binaries) $(crossbinaries): | ||
$(FLAGS) go build $(LDFLAGS) -o $@ ./$(@D) | ||
|
||
.PHONY: images tink-cli-image tink-server-image tink-worker-image | ||
tink-cli-image: cmd/tink-cli/tink-cli-linux-amd64 | ||
docker build -t tink-cli cmd/tink-cli/ | ||
tink-server-image: cmd/tink-server/tink-server-linux-amd64 | ||
docker build -t tink-server cmd/tink-server/ | ||
tink-worker-image: cmd/tink-worker/tink-worker-linux-amd64 | ||
docker build -t tink-worker cmd/tink-worker/ | ||
|
||
protos/gen_mock: | ||
go generate ./protos/**/* | ||
goimports -w ./protos/**/mock.go | ||
|
||
grpc/gen_doc: | ||
protoc \ | ||
-I./protos \ | ||
-I./protos/third_party \ | ||
--doc_out=./doc \ | ||
--doc_opt=html,index.html \ | ||
protos/hardware/*.proto protos/template/*.proto protos/workflow/*.proto |