-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
48 lines (40 loc) · 1.29 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
include .env
VERSION := $(shell git describe --tags --always --dirty)
BUILD_IMAGE ?= $(GOLANG_IMAGE_NAME):$(GOLANG_IMAGE_VERSION)
SRC_DIRS := cmd pkg
ALL_PROTOCALS := grpc rest
ROOT_PKG := $(PROJECT)
CMD_DIR := $(ROOT_PKG)/$(CMD_PKG)
BUILDABLE_DIRS := $(notdir $(patsubst %/,%, $(wildcard $(CMD_PKG)/*/)))
all: build
.PHONY: build
build: $(addprefix build-, $(BUILDABLE_DIRS))
build-%:
@$(MAKE) TARGET=$* perform-build
.PHONY: perform-build
perform-build: bin/$(TARGET)
bin/$(TARGET):
@echo "Building $@ in container..."
@docker run \
--rm \
-v "$$(pwd):/go/src/$(ROOT_PKG)" \
-v "$$(pwd)/.go:/go" \
-v "$$(pwd)/bin:/go/bin" \
-w /go/src/$(ROOT_PKG) \
$(BUILD_IMAGE) \
/bin/sh -c " \
VERSION=$(VERSION) \
TARGET=$(TARGET) \
CMD_PKG=$(CMD_PKG) \
./build/build.sh \
"
.PHONY: clean
clean:
@docker run \
--rm \
-v "$$(pwd):/go/src/$(ROOT_PKG)" \
-w /go/src/$(ROOT_PKG) \
$(BUILD_IMAGE) \
/bin/sh -c " \
rm -f bin/* \
"