2018-03-20 07:09:44 +08:00
|
|
|
BUILD_DIR = build
|
2018-05-11 05:53:25 +08:00
|
|
|
SERVICES = users clients http normalizer ws coap
|
2018-03-20 07:09:44 +08:00
|
|
|
DOCKERS = $(addprefix docker_,$(SERVICES))
|
|
|
|
CGO_ENABLED ?= 0
|
|
|
|
GOOS ?= linux
|
2018-03-13 16:26:59 +08:00
|
|
|
|
|
|
|
define compile_service
|
2018-03-20 07:09:44 +08:00
|
|
|
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) go build -ldflags "-s -w" -o ${BUILD_DIR}/mainflux-$(1) cmd/$(1)/main.go
|
2018-03-13 16:26:59 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
define make_docker
|
|
|
|
docker build --build-arg SVC_NAME=$(subst docker_,,$(1)) --tag=mainflux/$(subst docker_,,$(1)) -f docker/Dockerfile .
|
|
|
|
endef
|
|
|
|
|
2018-04-18 20:13:38 +08:00
|
|
|
all: $(SERVICES)
|
2018-03-19 17:14:43 +08:00
|
|
|
|
2018-04-18 20:13:38 +08:00
|
|
|
.PHONY: all $(SERVICES) dockers latest release
|
2018-03-13 16:26:59 +08:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf ${BUILD_DIR}
|
|
|
|
|
|
|
|
install:
|
|
|
|
cp ${BUILD_DIR}/* $(GOBIN)
|
|
|
|
|
2018-04-18 20:13:38 +08:00
|
|
|
proto:
|
2018-05-11 05:53:25 +08:00
|
|
|
protoc --go_out=plugins=grpc:. *.proto
|
2018-04-18 20:13:38 +08:00
|
|
|
|
|
|
|
$(SERVICES): proto
|
|
|
|
$(call compile_service,$(@))
|
|
|
|
|
2018-03-22 20:10:11 +08:00
|
|
|
$(DOCKERS):
|
2018-03-13 16:26:59 +08:00
|
|
|
$(call make_docker,$(@))
|
|
|
|
|
2018-03-22 20:10:11 +08:00
|
|
|
dockers: $(DOCKERS)
|
2018-05-11 05:53:25 +08:00
|
|
|
docker build --tag=mainflux/dashflux -f dashflux/docker/Dockerfile dashflux
|
2018-05-11 07:13:33 +08:00
|
|
|
docker build --tag=mainflux/mqtt -f mqtt/Dockerfile mqtt
|
2018-04-18 20:13:38 +08:00
|
|
|
|
|
|
|
latest: dockers
|
|
|
|
for svc in $(SERVICES); do \
|
|
|
|
docker push mainflux/$$svc; \
|
|
|
|
done
|
2018-05-10 16:39:48 +08:00
|
|
|
docker push mainflux/dashflux
|
2018-05-11 07:13:33 +08:00
|
|
|
docker push mainflux/mqtt
|
2018-05-10 16:39:48 +08:00
|
|
|
|
2018-04-18 20:13:38 +08:00
|
|
|
release:
|
|
|
|
$(eval version = $(shell git describe --abbrev=0 --tags))
|
|
|
|
git checkout $(version)
|
|
|
|
$(MAKE) dockers
|
|
|
|
for svc in $(SERVICES); do \
|
|
|
|
docker tag mainflux/$$svc mainflux/$$svc:$(version); \
|
|
|
|
docker push mainflux/$$svc:$(version); \
|
|
|
|
done
|
2018-05-11 05:53:25 +08:00
|
|
|
docker tag mainflux/dashflux mainflux/dashflux:$(version)
|
|
|
|
docker push mainflux/dashflux:$(version)
|
2018-05-11 07:13:33 +08:00
|
|
|
docker tag mainflux/mqtt mainflux/mqtt:$(version)
|
|
|
|
docker push mainflux/mqtt:$(version)
|