-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
95 lines (77 loc) · 1.82 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
BUILD_IMAGE:=$(shell mktemp -u tmp.XXXXXXXXXX | tr A-Z a-z)
BUILD:=$(shell mktemp -u tmp.XXXXXXXXXX | tr A-Z a-z)
EXPORT:=$(shell mktemp -u tmp.XXXXXXXXXX | tr A-Z a-z)
UID:=$(shell id -u)
GID:=$(shell id -g)
NAME:=ipmitool
ifdef DOCKER_REPOSITORY
NAME:=$(DOCKER_REPOSITORY)
endif
ifdef CIRCLECI
ifdef CIRCLE_TAG
ifndef VERSION
VERSION:=$(CIRCLE_TAG)
endif
endif
ifdef CIRCLE_SHA1
ifndef VERSION
VERSION:=$(CIRCLE_SHA1)
endif
endif
ifdef CIRCLE_BRANCH
ifneq ($(CIRCLE_BRANCH),master)
ifndef BRANCH
BRANCH:=$(CIRCLE_BRANCH)
endif
endif
endif
else
ifdef TRAVIS_TAG
ifndef VERSION
VERSION:=$(TRAVIS_TAG)
endif
endif
ifdef TRAVIS_COMMIT
ifndef VERSION
VERSION:=$(TRAVIS_COMMIT)
endif
endif
ifdef TRAVIS_BRANCH
ifneq ($(TRAVIS_BRANCH),master)
ifndef BRANCH
BRANCH:=$(TRAVIS_BRANCH)
endif
endif
endif
endif
ifdef VERSION
$(info Building version: $(VERSION))
endif
ifndef BRANCH
BRANCH:=latest
endif
$(info Building from branch: $(BRANCH))
ifdef REBUILD
DOCKER_OPTS:=--no-cache
endif
.PHONY: build-ipmitool ipmitool
all: build-ipmitool ipmitool
build-ipmitool:
docker build $(DOCKER_OPTS) --tag=$(BUILD_IMAGE) build/
docker volume create $(EXPORT)
docker run --mount=source=$(EXPORT),target=/export --tty --rm docker.io/library/alpine:3.7 /bin/chown -R $(UID):$(GID) /export
ifdef S
docker run --name=$(BUILD) --user=$(UID):$(GID) --mount=source=$(EXPORT),target=/export --volume=$(S):/tmp/ipmitool-0:ro --tty $(BUILD_IMAGE)
else
docker run --name=$(BUILD) --user=$(UID):$(GID) --mount=source=$(EXPORT),target=/export --tty $(BUILD_IMAGE)
endif
docker cp $(BUILD):/export/ run/install/
docker rm $(BUILD)
docker volume rm $(EXPORT)
docker rmi $(BUILD_IMAGE)
ipmitool: build-ipmitool
find run/install/ -exec touch --date=@0 {} \;
docker build --tag=$(NAME):$(BRANCH) run/
ifdef VERSION
docker tag $(NAME):$(BRANCH) $(NAME):$(VERSION)
endif