This repository has been archived by the owner on Oct 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
122 lines (102 loc) · 3.35 KB
/
Dockerfile
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# stage 1: build HDF5 with the specified toolchain
ARG BASE_IMAGE="leavesask/gompi"
ARG BASE_TAG="latest"
FROM ${BASE_IMAGE}:${BASE_TAG} AS builder
USER root
# install basic buiding tools
RUN set -eu; \
\
sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' \
/etc/apk/repositories; \
apk add --no-cache \
autoconf \
automake \
make \
wget \
which
# stage 1.1: download HDF5 source
ARG HDF5_VMAJOR="1.10"
ENV HDF5_VMAJOR=${HDF5_VMAJOR}
ARG HDF5_VMINOR="5"
ENV HDF5_VMINOR=${HDF5_VMINOR}
ENV HDF5_VERSION="${HDF5_VMAJOR}.${HDF5_VMINOR}"
ENV HDF5_TARBALL="hdf5-${HDF5_VERSION}.tar.gz"
WORKDIR /tmp
RUN set -eux; \
\
# checksums are not provided due to the build-time arguments HDF5_VERSION
wget "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-${HDF5_VMAJOR}/hdf5-${HDF5_VERSION}/src/${HDF5_TARBALL}"; \
tar -xzf ${HDF5_TARBALL}
# stage 1.2: build and install HDF5
ARG HDF5_CC="mpicc"
ENV HDF5_CC=${HDF5_CC}
ARG HDF5_CXX="mpicxx"
ENV HDF5_CXX=${HDF5_CXX}
ARG HDF5_OPTIONS="--enable-cxx --enable-parallel --enable-unsupported"
ENV HDF5_OPTIONS=${HDF5_OPTIONS}
ENV HDF5_PREFIX="/opt/hdf5/${HDF5_VERSION}"
WORKDIR /tmp/hdf5-${HDF5_VERSION}
RUN set -eux; \
\
# configure HDF5 installation with specified env and options
./configure \
CC=${HDF5_CC} \
CXX=${HDF5_CXX} \
--prefix=${HDF5_PREFIX} \
${HDF5_OPTIONS} \
; \
make -j "$(nproc)"; \
make install; \
\
rm -rf hdf5-${HDF5_VERSION} ${HDF5_TARBALL}
# stage 2: build the runtime environment
ARG BASE_IMAGE
ARG BASE_TAG
FROM ${BASE_IMAGE}:${BASE_TAG}
LABEL maintainer="Wang An <wangan.cs@gmail.com>"
USER root
# install basic dev tools
RUN set -eu; \
\
sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' \
/etc/apk/repositories; \
apk add --no-cache \
cmake \
make
# renew environment variables
ARG HDF5_VMAJOR="1.10"
ARG HDF5_VMINOR="5"
ENV HDF5_VERSION="${HDF5_VMAJOR}.${HDF5_VMINOR}"
ENV HDF5_PATH="/opt/hdf5/${HDF5_VERSION}"
# copy artifacts from stage 1
COPY --from=builder ${HDF5_PATH} ${HDF5_PATH}
# set environment variables for users
ENV PATH="${HDF5_PATH}/bin:${PATH}"
ENV CPATH="${HDF5_PATH}/include:${CPATH}"
ENV LIBRARY_PATH="${HDF5_PATH}/lib:${LIBRARY_PATH}"
ENV LD_LIBRARY_PATH="${HDF5_PATH}/lib:${LD_LIBRARY_PATH}"
# transfer control to the default user
ARG USER_NAME=one
# create the first user
RUN set -eu; \
\
if ! id -u ${USER_NAME} > /dev/null 2>&1; then \
adduser -D ${USER_NAME}; \
\
echo "${USER_NAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers; \
fi
USER ${USER_NAME}
WORKDIR /home/${USER_NAME}
#-----------------------------------------------------------------------
# Build-time metadata as defined at http://label-schema.org
#-----------------------------------------------------------------------
ARG BUILD_DATE
ARG VCS_REF
ARG VCS_URL
LABEL org.label-schema.build-date=${BUILD_DATE} \
org.label-schema.name="HDF5 docker image" \
org.label-schema.description="A lightweight image for HDF5" \
org.label-schema.license="MIT" \
org.label-schema.vcs-ref=${VCS_REF} \
org.label-schema.vcs-url=${VCS_URL} \
org.label-schema.schema-version="1.0"