-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (47 loc) · 1.69 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
.PHONY: build_%
# Current apache hadoop releases: http://hadoop.apache.org/releases.html
HADOOP_VERSION = 2.9.0
PROTOBUF_VERSION = 2.5.0
DOCKER = docker
DOCKER_REPO = muhammadmuhlas/gamabox-hadoop
all: build
### Build hadoop images with native libs.
build: build-$(HADOOP_VERSION)
build-%: hadoop-native-%.tar
$(DOCKER) build -t hadoop:$* \
--build-arg HADOOP_VERSION=$* \
.
tag: tag-$(HADOOP_VERSION)
tag-%:
$(DOCKER) tag hadoop:$* $(DOCKER_REPO):$*
push: push-$(HADOOP_VERSION)
push-%:
$(DOCKER) push $(DOCKER_REPO):$*
### Fetch source from closest mirror
hadoop-%-src.tar.gz:
curl -sfL http://www.apache.org/dyn/closer.cgi/hadoop/common/hadoop-$*/hadoop-$*-src.tar.gz | \
egrep -C 3 "We suggest" | \
perl -n -e'/href="(.*?)"/ && print $$1' | \
xargs curl -LO
### Fetch binary distribution from closest mirror
hadoop-%.tar.gz:
curl -sfL http://www.apache.org/dyn/closer.cgi/hadoop/common/hadoop-$*/hadoop-$*.tar.gz | \
egrep -C 3 "We suggest" | \
perl -n -e'/href="(.*?)"/ && print $$1' | \
xargs curl -LO
### Fetch protobuf source
protobuf-%.tar.bz2:
curl -LO https://github.com/google/protobuf/releases/download/v$*/protobuf-$*.tar.bz2
# Keep intermediate downloads.
.PRECIOUS: protobuf-%.tar.bz2 hadoop-%-src.tar.gz hadoop-%.tar.gz
### Compile native libs (~10min)
native_libs_%: hadoop-%-src.tar.gz protobuf-$(PROTOBUF_VERSION).tar.bz2
$(DOCKER) build -f Dockerfile-compile -t hadoop-nativelibs:$*\
--build-arg=HADOOP_VERSION=$* \
--build-arg=PROTOBUF_VERSION=$(PROTOBUF_VERSION) \
.
### Extract native libs from previous compile target
hadoop-native-%.tar: native_libs_% hadoop-%.tar.gz
$(DOCKER) run --rm \
-e HADOOP_VERSION=$* \
hadoop-nativelibs:$* > hadoop-native-$*.tar