Skip to content

Commit 1bafc88

Browse files
authored
Merge pull request #464 from sourceryinstitute/Docker-from-master
Dockerfile to in cloud with jupyter-CAF-kernel
2 parents 5681485 + 1fedcf2 commit 1bafc88

File tree

5 files changed

+190
-0
lines changed

5 files changed

+190
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.log
2+
log.*
3+
.git
4+
.gitignore
5+
hooks
6+
*~
7+
Untitled*.ipynb
8+
Makefile
9+
#*#
10+
\#*\#
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
FROM jupyter/minimal-notebook:da2c5a4d00fa
2+
3+
MAINTAINER Izaak Beekman <[email protected]>
4+
5+
USER root
6+
ENV GCC_VERSION 7.2.0
7+
8+
ENV NB_USER jovyan
9+
ENV NB_UID 1000
10+
ENV HOME /home/${NB_USER}
11+
12+
RUN DEBIAN_FRONTEND=noninteractive transientBuildDeps="file" \
13+
&& set -v \
14+
&& cat /etc/issue \
15+
&& uname -a \
16+
&& echo "${DEBIAN_FRONTEND}" \
17+
&& apt-get update -y \
18+
&& apt-get install -y \
19+
software-properties-common \
20+
&& add-apt-repository ppa:ubuntu-toolchain-r/test -y \
21+
&& apt-get update -y \
22+
&& apt-get install -y \
23+
build-essential \
24+
gcc-7=${GCC_VERSION}-1ubuntu1~16.04 \
25+
gfortran-7=${GCC_VERSION}-1ubuntu1~16.04 \
26+
g++-7=${GCC_VERSION}-1ubuntu1~16.04 \
27+
mpich \
28+
${transientBuildDeps} \
29+
&& update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/gfortran gfortran /usr/bin/gfortran-7 \
30+
&& update-alternatives --set gcc "/usr/bin/gcc-7" \
31+
&& gcc --version \
32+
&& gfortran --version \
33+
&& mpiexec --version \
34+
&& mpifort --version \
35+
&& mpicc --version \
36+
&& apt-get clean \
37+
&& apt-get purge -y --auto-remove ${transientBuildDeps} \
38+
&& rm -rf /var/lib/apt/lists/* /var/log/* /tmp/*
39+
40+
# Build-time metadata as defined at http://label-schema.org
41+
ARG BUILD_DATE
42+
ARG VCS_REF
43+
ARG VCS_URL
44+
ARG VCS_VERSION=latest
45+
LABEL org.label-schema.schema-version="1.0" \
46+
org.label-schema.build-date="${BUILD_DATE}" \
47+
org.label-schema.name="" \
48+
org.label-schema.description="Coarray Fortran compiler with GFortran ${GCC_VERSION}, OpenCoarrays and MPICH backend" \
49+
org.label-schema.url="https://github.com/sourceryinstitute/OpenCoarrays#readme/" \
50+
org.label-schema.vcs-ref="${VCS_REF}" \
51+
org.label-schema.vcs-url="${VCS_URL}" \
52+
org.label-schema.version="${VCS_VERSION}" \
53+
org.label-schema.vendor="SourceryInstitute" \
54+
org.label-schema.license="BSD" \
55+
org.label-schema.docker.cmd="docker run -i -t -p 8888:8888 sourceryinstitute/opencoarrays-notebook"
56+
57+
ARG RUN_TESTS=false
58+
59+
RUN DEBIAN_FRONTEND=noninteractive transientBuildDeps="cmake git" \
60+
&& set -v \
61+
&& echo "${DEBIAN_FRONTEND}" \
62+
&& apt-get update && apt-get install -y \
63+
${transientBuildDeps} \
64+
&& cmake --version \
65+
&& gcc --version \
66+
&& gfortran --version \
67+
&& git clone --single-branch https://github.com/sourceryinstitute/OpenCoarrays \
68+
&& mkdir OpenCoarrays/build \
69+
&& cd OpenCoarrays/build \
70+
&& FC="$(which gfortran)" CC="$(which gcc)" cmake -DCMAKE_BUILD_TYPE=Release .. \
71+
&& make -j "$(nproc)" install \
72+
&& if [ "${RUN_TESTS}" = "true" ] ; then ctest --output-on-failure ; fi \
73+
&& cd ../.. \
74+
&& caf --version \
75+
&& cafrun --version \
76+
&& rm -rf OpenCoarrays \
77+
&& apt-get clean \
78+
&& apt-get purge -y --auto-remove ${transientBuildDeps} \
79+
&& rm -rf /var/lib/apt/lists/* /var/log/* /tmp/*
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
SHELL := /usr/local/bin/bash -o pipefail
2+
NAME = sourceryinstitute/opencoarrays-notebook
3+
#UBADGER_ENDPOINT = "https://hooks.microbadger.com/images/sourceryinstitute/jupyter-caf-kernel/CEL6DIVw-OVbUIXieZhZwvDXl3I="
4+
GIT_MASTER_HEAD_SHA:=$(shell git rev-parse --short=12 --verify HEAD)
5+
6+
.PHONY: help build push run runclean clean
7+
.DEFAULT_GOAL := help
8+
9+
# Add the following 'help' target to your Makefile
10+
# And add help text after each target name starting with '\#\#'
11+
12+
help: ## This help message
13+
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/\\x1b[36m\1\\x1b[m:\2/' | column -c2 -t -s :)"
14+
15+
build: $(subst /,_,$(NAME))-build.stamp ## Build docker file. Depending on which packages are rebuilt this may take a long time
16+
17+
$(subst /,_,$(NAME))-build.stamp: Dockerfile .dockerignore hooks/build ## Target for doing & timestamping the build
18+
touch $@
19+
hooks/build 2>&1 | tee $(subst stamp,log,$@) || rm -rf $@
20+
docker tag $(NAME):latest $(NAME):$(GIT_MASTER_HEAD_SHA)
21+
22+
push: $(subst /,_,$(NAME))-push.stamp ## Push prebuild docker image up to hub.docker.com
23+
24+
$(subst /,_,$(NAME))-push.stamp: $(subst /,_,$(NAME))-build.stamp Dockerfile .dockerignore hooks/build ## Target for doing & timestamping the push
25+
touch $@
26+
docker push $(NAME):latest | tee $(subst stamp,log,$@) || rm -rf $@
27+
docker push $(NAME):$(GIT_MASTER_HEAD_SHA) | tee -a $(subst stamp,log,$@) || rm -rf $@
28+
-curl -X POST "$(UBADGER_ENDPOINT)"
29+
30+
run: ## Target to run jupyter-hub docker server
31+
docker run -i -t -p 8888:8888 $(NAME) | tee $(subst /,_,$(NAME))-run.log
32+
33+
runclean: ## Target to run jupyter-hub docker server, discarding changes
34+
docker run --rm -i -t -p 8888:8888 $(NAME) | tee $(subst /,_,$(NAME))-runclean.log
35+
36+
clean:
37+
-rm -rf $(subst /,_,$(NAME))*.stamp
38+
-find . -name 'Untitled*.ipynd' -exec rm -f {} \;
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
# See https://github.com/rossf7/label-schema-automated-build
3+
# or https://medium.com/microscaling-systems/labelling-automated-builds-on-docker-hub-f3d073fb8e1#.wgkzfdnfr
4+
# for more details.
5+
6+
# $IMAGE_NAME var is injected into the build so the tag is correct.
7+
8+
set -o verbose
9+
set -o pipefail
10+
set -o errexit
11+
set -x
12+
13+
git fetch -v --all --tags
14+
git fetch -v --all --depth=9999999 --update-shallow
15+
git tag --list
16+
git branch
17+
18+
d_repo='sourceryinstitute/OpenCoarrays'
19+
d_git_remotes=($(git remote show))
20+
echo "${#d_git_remotes[@]} git remotes found."
21+
n_remotes=${#d_git_remotes[@]}
22+
if (( n_remotes > 0 )) ; then
23+
echo "Using remote: ${d_git_remotes[0]}"
24+
d_vcs_url="$(git remote -v | awk 'FNR == 1 {print $2}')"
25+
fi
26+
27+
if [[ -z "${d_vcs_url:-}" ]]; then
28+
d_vcs_url="https://github.com/${DOCKER_REPO:-${d_repo}}"
29+
fi
30+
31+
branch_name="$(git symbolic-ref -q HEAD)" || true
32+
branch_name="${branch_name##refs/heads/}"
33+
branch_name="${branch_name:-DETACHED-HEAD}"
34+
35+
d_vcs_describe="$(git describe --tags --always || true)"
36+
d_tag="${IMAGE_NAME##*:}"
37+
d_tag="${d_tag:-${branch_name}-$(date +%s)}"
38+
d_vcs_tag="$(git rev-parse --short=12 --verify HEAD)"
39+
40+
if [[ ${IMAGE_NAME:-} ]]; then
41+
export RUN_TESTS=false
42+
else
43+
export RUN_TESTS=${RUN_TESTS:-false}
44+
fi
45+
46+
47+
opencoarrays_version="${d_vcs_describe}"
48+
if [[ -n "${open_coarrays_version:-}" ]]; then
49+
opencoarrays_version=1.9.2
50+
fi
51+
52+
echo "Build hook running"
53+
docker build --build-arg OPENCOARRAYS_VERSION="${opencoarrays_version}" \
54+
--build-arg RUN_TESTS=${RUN_TESTS} \
55+
--build-arg BUILD_DATE="$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
56+
--build-arg VCS_REF="${SOURCE_COMMIT:-$(git rev-parse --short HEAD)}" \
57+
--build-arg VCS_URL="${d_vcs_url}" \
58+
--build-arg VCS_VERSION="${d_vcs_describe:-${d_tag}}" \
59+
--rm \
60+
--pull \
61+
-t "${IMAGE_NAME:-$(tr '[:upper:]' '[:lower:]' <<< "${d_repo}:latest")}" .
62+
docker tag "${IMAGE_NAME:-$(tr '[:upper:]' '[:lower:]' <<< "${d_repo}:latest")}" "${IMAGE_NAME:-$(tr '[:upper:]' '[:lower:]' <<< "${d_repo}:${d_vcs_tag}")}"

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ codecov.yml export-ignore
3535
makefile export-ignore
3636
Makefile export-ignore
3737
make.inc* export-ignore
38+
.Dockerfiles export-ignore
3839

3940
# Experimental conduits/backends
4041
src/gasnet export-ignore

0 commit comments

Comments
 (0)