-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
56 lines (46 loc) · 1.39 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
# Copyright (c) Mainflux
# SPDX-License-Identifier: Apache-2.0
PROGRAM = aproxy
APROXY_DOCKER_IMAGE_NAME_PREFIX ?= amdm
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)
all: $(PROGRAM)
.PHONY: all clean $(PROGRAM)
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=$(APROXY_DOCKER_IMAGE_NAME_PREFIX)/$(PROGRAM) \
-f docker/Dockerfile .
endef
define make_docker_dev
docker build \
--no-cache \
--build-arg SVC=$(PROGRAM) \
--tag=$(APROXY_DOCKER_IMAGE_NAME_PREFIX)/$(PROGRAM) \
-f docker/Dockerfile.dev ./build
endef
$(PROGRAM): $(SOURCES)
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) \
go build -mod=vendor -ldflags "-s -w \
-X 'github.com/absmach/aproxy.BuildTime=$(TIME)' \
-X 'github.com/absmach/aproxy.Version=$(VERSION)' \
-X 'github.com/absmach/aproxy.Commit=$(COMMIT)'" \
-o ./build/$(APROXY_DOCKER_IMAGE_NAME_PREFIX)-$(PROGRAM) cmd/main.go
clean:
rm -rf $(PROGRAM)
docker-image:
$(call make_docker)
docker-dev:
$(call make_docker_dev)
run:
docker compose -f ./docker/docker-compose.yml up