2018-03-20 07:09:44 +08:00
|
|
|
BUILD_DIR = build
|
2018-11-01 01:53:25 +08:00
|
|
|
SERVICES = users things http normalizer ws coap influxdb-writer influxdb-reader mongodb-writer mongodb-reader cassandra-writer cassandra-reader cli
|
2018-03-20 07:09:44 +08:00
|
|
|
DOCKERS = $(addprefix docker_,$(SERVICES))
|
2018-09-20 02:20:12 +08:00
|
|
|
DOCKERS_DEV = $(addprefix docker_dev_,$(SERVICES))
|
2018-03-20 07:09:44 +08:00
|
|
|
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
|
2018-09-20 02:20:12 +08:00
|
|
|
docker build --no-cache --build-arg SVC_NAME=$(subst docker_,,$(1)) --tag=mainflux/$(subst docker_,,$(1)) -f docker/Dockerfile .
|
|
|
|
endef
|
|
|
|
|
|
|
|
define make_docker_dev
|
|
|
|
docker build --build-arg SVC_NAME=$(subst docker_dev_,,$(1)) --tag=mainflux/$(subst docker_dev_,,$(1)) -f docker/Dockerfile.dev ./build
|
2018-03-13 16:26:59 +08:00
|
|
|
endef
|
|
|
|
|
2018-08-17 01:52:43 +08:00
|
|
|
all: $(SERVICES) mqtt
|
2018-03-19 17:14:43 +08:00
|
|
|
|
2018-09-20 02:20:12 +08:00
|
|
|
.PHONY: all $(SERVICES) dockers dockers_dev latest release mqtt
|
2018-03-13 16:26:59 +08:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf ${BUILD_DIR}
|
2018-08-17 01:52:43 +08:00
|
|
|
rm -rf mqtt/node_modules
|
2018-03-13 16:26:59 +08:00
|
|
|
|
|
|
|
install:
|
|
|
|
cp ${BUILD_DIR}/* $(GOBIN)
|
|
|
|
|
2018-08-27 18:17:41 +08:00
|
|
|
test:
|
|
|
|
GOCACHE=off go test -v -race -tags test $(shell go list ./... | grep -v 'vendor\|cmd')
|
|
|
|
|
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
|
|
|
|
2018-08-24 21:33:40 +08:00
|
|
|
$(SERVICES):
|
2018-04-18 20:13:38 +08:00
|
|
|
$(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-20 15:29:19 +08:00
|
|
|
docker build --tag=mainflux/mqtt -f mqtt/Dockerfile .
|
2018-04-18 20:13:38 +08:00
|
|
|
|
2018-09-20 02:20:12 +08:00
|
|
|
$(DOCKERS_DEV):
|
|
|
|
$(call make_docker_dev,$(@))
|
|
|
|
|
|
|
|
dockers_dev: $(DOCKERS_DEV)
|
|
|
|
|
2018-08-17 01:52:43 +08:00
|
|
|
mqtt:
|
|
|
|
cd mqtt && npm install
|
|
|
|
|
2018-09-13 21:40:40 +08:00
|
|
|
define docker_push
|
2018-04-18 20:13:38 +08:00
|
|
|
for svc in $(SERVICES); do \
|
2018-09-13 21:40:40 +08:00
|
|
|
docker push mainflux/$$svc:$(1); \
|
2018-04-18 20:13:38 +08:00
|
|
|
done
|
2018-09-13 21:40:40 +08:00
|
|
|
docker push mainflux/dashflux:$(1)
|
|
|
|
docker push mainflux/mqtt:$(1)
|
|
|
|
endef
|
|
|
|
|
|
|
|
latest: dockers
|
|
|
|
$(call docker_push,latest)
|
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); \
|
|
|
|
done
|
2018-05-11 05:53:25 +08:00
|
|
|
docker tag mainflux/dashflux mainflux/dashflux:$(version)
|
2018-05-11 07:13:33 +08:00
|
|
|
docker tag mainflux/mqtt mainflux/mqtt:$(version)
|
2018-09-13 21:40:40 +08:00
|
|
|
$(call docker_push,$(version))
|
2018-08-17 01:52:43 +08:00
|
|
|
|
2018-10-24 23:13:29 +08:00
|
|
|
rundev:
|
2018-08-17 01:52:43 +08:00
|
|
|
cd scripts && ./run.sh
|
2018-10-24 23:13:29 +08:00
|
|
|
|
|
|
|
run:
|
|
|
|
docker-compose -f docker/docker-compose.yml up
|