-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
62 lines (49 loc) · 1.57 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
# Copyright (c) Abstract Machines
PROGRAM = callhome
MG_DOCKER_IMAGE_NAME_PREFIX ?= magistrala
SOURCES = $(wildcard *.go) cmd/main.go
CGO_ENABLED ?= 0
GOARCH ?= amd64
VERSION ?= $(shell git describe --abbrev=0 --tags 2>/dev/null || echo "0.13.0")
COMMIT ?= $(shell git rev-parse HEAD)
TIME ?= $(shell date +%F_%T)
DOMAIN ?= deployments.magistrala.abstractmachines.fr
all: $(PROGRAM)
.PHONY: all clean $(PROGRAM) latest
define make_docker
docker build \
--no-cache \
--build-arg SVC=$(PROGRAM) \
--build-arg GOARCH=$(GOARCH) \
--build-arg GOARM=$(GOARM) \
--build-arg VERSION=$(VERSION) \
--build-arg COMMIT=$(COMMIT) \
--build-arg TIME=$(TIME) \
--tag=$(MG_DOCKER_IMAGE_NAME_PREFIX)/$(PROGRAM) \
-f docker/Dockerfile .
endef
define make_dev_cert
sudo openssl req -x509 -out ./docker/certbot/conf/live/$(DOMAIN)/fullchain.pem \
-keyout ./docker/certbot/conf/live/$(DOMAIN)/privkey.pem \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=localhost'
endef
$(PROGRAM): $(SOURCES)
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) \
go build -ldflags "-s -w \
-X 'github.com/absmach/magistrala.BuildTime=$(TIME)' \
-X 'github.com/absmach/magistrala.Version=$(VERSION)' \
-X 'github.com/absmach/magistrala.Commit=$(COMMIT)'" \
-o ./build/$(PROGRAM)-$(PROGRAM) cmd/main.go
clean:
rm -rf $(PROGRAM)
docker-image:
$(call make_docker)
dev-cert:
$(call make_dev_cert)
run:
docker compose -f ./docker/docker-compose.yml up
test:
go test -v --race -covermode=atomic -coverprofile cover.out ./...
latest: docker-image
docker push magistrala/callhome:latest