-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·59 lines (47 loc) · 2.07 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
# Variables
DOCKER_IMAGE_NAME := senzing/data-encryption-aes256cbc-sample
DOCKER_IMAGE_TAG ?= $(GIT_REPOSITORY_NAME):$(GIT_VERSION)
GIT_REPOSITORY_NAME := $(shell basename `git rev-parse --show-toplevel`)
GIT_VERSION := $(shell git describe --always --tags --long --dirty | sed -e 's/\-0//' -e 's/\-g.......//')
TARGET_DIRECTORY := ./target
# -----------------------------------------------------------------------------
# The first "make" target runs as default.
# -----------------------------------------------------------------------------
.PHONY: default
default: help
# -----------------------------------------------------------------------------
# Docker-based builds
# -----------------------------------------------------------------------------
.PHONY: docker-build
docker-build:
docker build \
--tag $(DOCKER_IMAGE_NAME) \
--tag $(DOCKER_IMAGE_NAME):$(GIT_VERSION) \
.
# -----------------------------------------------------------------------------
# Package
# -----------------------------------------------------------------------------
.PHONY: package
package: docker-build
@mkdir -p $(TARGET_DIRECTORY) || true
@CONTAINER_ID=$$(docker create $(DOCKER_IMAGE_NAME)); \
docker cp $$CONTAINER_ID:/results/. $(TARGET_DIRECTORY)/; \
docker rm -v $$CONTAINER_ID
# -----------------------------------------------------------------------------
# Clean up targets
# -----------------------------------------------------------------------------
.PHONY: docker-rmi-for-build
docker-rmi-for-build:
-docker rmi --force \
$(DOCKER_IMAGE_NAME):$(GIT_VERSION) \
$(DOCKER_IMAGE_NAME)
.PHONY: clean
clean: docker-rmi-for-build
@rm -rf $(TARGET_DIRECTORY) || true
# -----------------------------------------------------------------------------
# Help
# -----------------------------------------------------------------------------
.PHONY: help
help:
@echo "List of make targets:"
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs