Skip to content

Commit

Permalink
Template Apache Spark containers for cross building (resolves BD2KGen…
Browse files Browse the repository at this point in the history
…omics#196)

Modifies apache-spark-{common,master,worker} for cross building to
Spark 1.5.2, 1.6.2, and 2.0.1.
  • Loading branch information
fnothaft committed Oct 9, 2016
1 parent f0852e7 commit 63eb1f8
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 68 deletions.
1 change: 1 addition & 0 deletions apache-spark-common/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.spark/
46 changes: 21 additions & 25 deletions apache-spark-common/Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
# Definitions
build_path = build
runtime_path = runtime
build_output = ${runtime_path}/apache-spark
runtime_fullpath = $(realpath ${runtime_path})
spark_versions = 1.5.2 1.6.2 2.0.1
gen_directories = $(spark_versions:=.spark)
build_tool = runtime-container.DONE
build_number ?= none
git_commit ?= $(shell git log --pretty=oneline -n 1 -- ../apache-spark-common | cut -f1 -d " ")
name = quay.io/ucsc_cgl/apache-spark-common
tag = 1.5.2--${git_commit}

# Steps
build: ${build_output} ${build_tool}
build: $(build_tool)

${build_output}: ${build_path}/Dockerfile
cd ${build_path} && docker build -no-cache -t ${name}-build:${tag} .
echo ${runtime_fullpath}
docker run -v ${runtime_fullpath}:/data ${name}-build:${tag} cp -r /opt/apache-spark /data/apache-spark
%.spark: sparkver=$(@:.spark=)
%.spark: build/Dockerfile build/download.sh.template runtime/Dockerfile.template Makefile.template
mkdir -p $@ ${@}/build ${@}/runtime
cp build/Dockerfile ${@}/build/Dockerfile
sed -e "s:SPARKVER:$(sparkver):g" build/download.sh.template > ${@}/build/download.sh
sed -e "s:SPARKVER:$(sparkver):g" runtime/Dockerfile.template > ${@}/runtime/Dockerfile
sed -e "s:SPARKVER:$(sparkver):g" Makefile.template > ${@}/Makefile

${build_tool}: ${build_output} ${runtime_path}/Dockerfile
cd ${runtime_path} && docker build -t ${name}:${tag} .
touch ${build_tool}
generate: $(gen_directories)

test: build

clean:
rm -rf runtime/apache-spark ${build_tool}
docker rmi -f ${name}-build:${tag} ${name}:${tag}
$(build_tool): generate
$(foreach subdir, $(gen_directories), cd $(subdir) && $(MAKE) build && cd ..;)
touch $(build_tool)

push: build
# Requires ~/.dockercfg
docker push ${name}:${tag}
docker push ${name}:latest
# Requires ~/.dockercfg
$(foreach subdir, $(gen_directories), cd $(subdir) && $(MAKE) push && cd ..;)

test:

clean:
-rm -rf $(gen_directories) && rm $(build_tool)
33 changes: 33 additions & 0 deletions apache-spark-common/Makefile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Definitions
build_path = build
runtime_path = runtime
build_output = ${runtime_path}/apache-spark
runtime_fullpath = $(realpath ${runtime_path})
build_tool = runtime-container.DONE
build_number ?= none
git_commit ?= $(shell git log --pretty=oneline -n 1 -- ../apache-spark-common | cut -f1 -d " ")
name = quay.io/ucsc_cgl/apache-spark-common
tag = SPARKVER--${git_commit}

# Steps
build: ${build_output} ${build_tool}

${build_output}: ${build_path}/Dockerfile
cd ${build_path} && docker build -no-cache -t ${name}-build:${tag} .
echo ${runtime_fullpath}
docker run -v ${runtime_fullpath}:/data ${name}-build:${tag} cp -r /opt/apache-spark /data/apache-spark

${build_tool}: ${build_output} ${runtime_path}/Dockerfile
cd ${runtime_path} && docker build -t ${name}:${tag} .
touch ${build_tool}

test: build

clean:
rm -rf runtime/apache-spark ${build_tool}
docker rmi -f ${name}-build:${tag} ${name}:${tag}

push: build
# Requires ~/.dockercfg
docker push ${name}:${tag}
docker push ${name}:latest
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mirror=$(python -c "from urllib2 import urlopen; import json; print json.load( urlopen('http://www.apache.org/dyn/closer.lua?path=$path&asjson=1'))['preferred']")

mkdir /opt/apache-spark && \
curl ${mirror}spark/spark-1.5.2/spark-1.5.2.tgz \
curl ${mirror}spark/spark-SPARKVER/spark-SPARKVER.tgz \
| tar --strip-components=1 -xzC /opt/apache-spark
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ RUN apt-get update && \

# add spark to path
RUN mkdir /opt/apache-spark
COPY apache-spark/spark-1.5.2-bin-custom-spark.tgz /opt/
RUN tar --strip-components=1 -xzf /opt/spark-1.5.2-bin-custom-spark.tgz -C /opt/apache-spark
COPY apache-spark/spark-SPARKVER-bin-custom-spark.tgz /opt/
RUN tar --strip-components=1 -xzf /opt/spark-SPARKVER-bin-custom-spark.tgz -C /opt/apache-spark
ENV PATH /opt/apache-spark/bin:$PATH
7 changes: 0 additions & 7 deletions apache-spark-common/runtime/run-master.sh

This file was deleted.

1 change: 1 addition & 0 deletions apache-spark-master/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.spark/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/ucsc_cgl/apache-spark-common:1.5.2--9885dd3736e1c59552e2a821b5a4690a5d23f1ab
FROM quay.io/ucsc_cgl/apache-spark-common:SPARKVER--COMMONCOMMIT

MAINTAINER Audrey Musselman-Brown, [email protected]

Expand Down
39 changes: 24 additions & 15 deletions apache-spark-master/Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
# Definitions
spark_versions = 1.5.2 1.6.2 2.0.1
common_git_commit ?= $(shell git log --pretty=oneline -n 1 -- ../apache-spark-common | cut -f1 -d " ")
gen_directories = $(spark_versions:=.spark)
build_tool = runtime-container.DONE
git_commit ?= $(shell git log --pretty=oneline -n 1 -- ../apache-spark-master | cut -f1 -d " ")
nametag = quay.io/ucsc_cgl/apache-spark-master:1.5.2--${git_commit}

build: ${build_tool}
build: $(build_tool)

${build_tool}: Dockerfile run-master.sh
%.spark: sparkver=$(@:.spark=)
%.spark: Makefile.template Dockerfile.template
mkdir -p $@
cp run-master.sh ${@}/
sed -e "s:SPARKVER:$(sparkver):g" -e "s:COMMONCOMMIT:$(common_git_commit):g" Dockerfile.template > ${@}/Dockerfile
sed -e "s:SPARKVER:$(sparkver):g" Makefile.template > ${@}/Makefile

generate: $(gen_directories)

$(build_tool): generate
# has apache-spark-common been built yet? if not, build it
# if it has been built, this command won't do anything.
cd ../apache-spark-common && make build
cd ../apache-spark-common && $(MAKE) build

# build the runtime container
docker build -t ${nametag} .
touch ${build_tool}
$(foreach subdir, $(gen_directories), cd $(subdir) && $(MAKE) build && cd ..;)
touch $(build_tool)

clean:
rm -rf ${build_tool}
docker rmi -f ${nametag}
push: build
# Requires ~/.dockercfg
$(foreach subdir, $(gen_directories), cd $(subdir) && $(MAKE) push && cd ..;)

test: build
test:

push: build
# Requires ~/.dockercfg
docker push ${nametag}
clean:
-rm -rf $(gen_directories) && rm $(build_tool)
20 changes: 20 additions & 0 deletions apache-spark-master/Makefile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
build_tool = runtime-container.DONE
git_commit ?= $(shell git log --pretty=oneline -n 1 -- ../apache-spark-master ../apache-spark-common | cut -f1 -d " ")
nametag = quay.io/ucsc_cgl/apache-spark-master:SPARKVER--${git_commit}

build: ${build_tool}

${build_tool}: Dockerfile run-master.sh
# build the runtime container
docker build -t ${nametag} .
touch ${build_tool}

clean:
rm -rf ${build_tool}
docker rmi -f ${nametag}

test: build

push: build
# Requires ~/.dockercfg
docker push ${nametag}
1 change: 1 addition & 0 deletions apache-spark-worker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.spark/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/ucsc_cgl/apache-spark-common:1.5.2--9885dd3736e1c59552e2a821b5a4690a5d23f1ab
FROM quay.io/ucsc_cgl/apache-spark-common:SPARKVER--COMMONCOMMIT

MAINTAINER Audrey Musselman-Brown, [email protected]

Expand Down
41 changes: 25 additions & 16 deletions apache-spark-worker/Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
# Definitions
spark_versions = 1.5.2 1.6.2 2.0.1
common_git_commit ?= $(shell git log --pretty=oneline -n 1 -- ../apache-spark-common | cut -f1 -d " ")
gen_directories = $(spark_versions:=.spark)
build_tool = runtime-container.DONE
git_commit ?= $(shell git log --pretty=oneline -n 1 -- ../apache-spark-worker | cut -f1 -d " ")
nametag = quay.io/ucsc_cgl/apache-spark-worker:1.5.2--${git_commit}

build: ${build_tool}
build: $(build_tool)

${build_tool}: Dockerfile run-worker.sh
%.spark: sparkver=$(@:.spark=)
%.spark: Makefile.template Dockerfile.template
mkdir -p $@
cp run-worker.sh ${@}/
sed -e "s:SPARKVER:$(sparkver):g" -e "s:COMMONCOMMIT:$(common_git_commit):g" Dockerfile.template > ${@}/Dockerfile
sed -e "s:SPARKVER:$(sparkver):g" Makefile.template > ${@}/Makefile

generate: $(gen_directories)

$(build_tool): generate
# has apache-spark-common been built yet? if not, build it
# if it has been built, this command won't do anything.
cd ../apache-spark-common && make build

# build the runtime container
docker build -t ${nametag} .
touch ${build_tool}

clean:
rm -rf ${build_tool}
docker rmi -f ${nametag}
cd ../apache-spark-common && $(MAKE) build

test: build
$(foreach subdir, $(gen_directories), cd $(subdir) && $(MAKE) build && cd ..;)
touch $(build_tool)

push: build
# Requires ~/.dockercfg
docker push ${nametag}
# Requires ~/.dockercfg
$(foreach subdir, $(gen_directories), cd $(subdir) && $(MAKE) push && cd ..;)

test:

clean:
-rm -rf $(gen_directories) && rm $(build_tool)
20 changes: 20 additions & 0 deletions apache-spark-worker/Makefile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
build_tool = runtime-container.DONE
git_commit ?= $(shell git log --pretty=oneline -n 1 -- ../apache-spark-common ../apache-spark-worker | cut -f1 -d " ")
nametag = quay.io/ucsc_cgl/apache-spark-worker:SPARKVER--${git_commit}

build: ${build_tool}

${build_tool}: Dockerfile run-worker.sh
# build the runtime container
docker build -t ${nametag} .
touch ${build_tool}

clean:
rm -rf ${build_tool}
docker rmi -f ${nametag}

test: build

push: build
# Requires ~/.dockercfg
docker push ${nametag}

0 comments on commit 63eb1f8

Please sign in to comment.