forked from davegill/wrf-coop
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile-first_part
195 lines (170 loc) · 8.5 KB
/
Dockerfile-first_part
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#
FROM centos:7
MAINTAINER Kelly Werner <[email protected]>
ENV NML_VERSION 4.4
# Set up base OS environment
RUN yum -y update
# Install SCL release package and python SCL
RUN yum -y install centos-release-scl \
&& yum -y install --setopt=tsflags=nodocs rh-python38
# Enable rh-python scl binary
COPY entrypoint.sh /usr/bin/entrypoint.sh
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT [ "/usr/bin/entrypoint.sh" ]
RUN yum -y install file gcc gcc-gfortran gcc-c++ glibc.i686 libgcc.i686 libpng-devel jasper \
jasper-devel hostname m4 make perl tar bash tcsh time wget which zlib zlib-devel \
openssh-clients openssh-server net-tools fontconfig libgfortran libXext libXrender \
sudo epel-release git flex flex-devel byacc bzip2-devel gzip-devel
# Install version 10 of GNU compiler
RUN yum -y install centos-release-scl \
&& yum -y install devtoolset-10 \
&& yum -y install devtoolset-10-gcc devtoolset-10-gcc-gfortran devtoolset-10-gcc-c++ \
&& scl enable devtoolset-10 bash \
&& scl enable devtoolset-10 tcsh
RUN yum -y install php-devel php-pear
RUN yum -y install ImageMagick ImageMagick-devel
RUN groupadd wrf -g 9999
RUN useradd -u 9999 -g wrf -G wheel -M -d /wrf wrfuser
RUN mkdir /wrf \
&& chown -R wrfuser:wrf /wrf \
&& chmod 6755 /wrf
# Build the libraries with a parallel Make
ENV J 4
# Build OpenMPI
RUN mkdir -p /wrf/libs/openmpi/BUILD_DIR
RUN source /opt/rh/devtoolset-10/enable \
&& cd /wrf/libs/openmpi/BUILD_DIR \
&& curl -L -O https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.0.tar.gz \
&& tar -xf openmpi-4.0.0.tar.gz \
&& cd openmpi-4.0.0 \
&& ./configure --prefix=/usr/local &> /wrf/libs/build_log_openmpi_config \
&& echo dummy printout to keep travis happy openmpi config \
&& make all install \
&& echo "make all install | awk 'NR % 1000 == 0'" \
&& echo "make all install &> /wrf/libs/build_log_openmpi_make" \
&& echo dummy printout to keep travis happy openmpi make \
&& cd / \
&& rm -rf /wrf/libs/openmpi/BUILD_DIR
# Build HDF5 libraries
RUN mkdir -p /wrf/libs/hdf5/BUILD_DIR
RUN source /opt/rh/devtoolset-10/enable \
&& cd /wrf/libs/hdf5/BUILD_DIR \
&& wget https://www2.mmm.ucar.edu/people/duda/files/mpas/sources/hdf5-1.10.5.tar.bz2 \
&& tar -xf hdf5-1.10.5.tar.bz2 \
&& cd hdf5-1.10.5 \
&& ./configure --enable-fortran --enable-cxx --enable-shared --prefix=/usr/local/ &> /wrf/libs/build_log_hdf5_config \
&& echo dummy printout to keep travis happy hdf5 config \
&& make install &> /wrf/libs/build_log_hdf5_make \
&& echo dummy printout to keep travis happy hdf5 make \
&& cd / \
&& rm -rf /wrf/libs/hdf5/BUILD_DIR
ENV LD_LIBRARY_PATH /usr/local/lib
# Build netCDF C libraries
RUN yum -y install libcurl-devel zlib-devel
ENV NETCDF /wrf/libs/netcdf
RUN mkdir -p ${NETCDF}/BUILD_DIR
RUN source /opt/rh/devtoolset-10/enable \
&& cd ${NETCDF}/BUILD_DIR \
&& curl -L -O https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.7.4.tar.gz \
&& curl -L -O https://github.com/Unidata/netcdf-fortran/archive/refs/tags/v4.6.0.tar.gz \
&& curl -L -O https://github.com/Unidata/netcdf4-python/archive/v1.5.3rel.tar.gz \
&& tar -xf v4.7.4.tar.gz \
&& cd netcdf-c-4.7.4 \
&& ./configure --enable-shared --prefix=${NETCDF} &> /wrf/libs/build_log_ncc_config \
&& echo dummy printout to keep travis happy ncc config \
&& make install &> /wrf/libs/build_log_ncc_make \
&& echo dummy printout to keep travis happy ncc make \
&& cd /
# Build netCDF Fortran libraries
RUN source /opt/rh/devtoolset-10/enable \
&& env \
&& cd ${NETCDF}/BUILD_DIR \
&& tar -xf v4.6.0.tar.gz \
&& cd netcdf-fortran-4.6.0/ \
&& export LD_LIBRARY_PATH=${NETCDF}/lib:/usr/local/lib:${LD_LIBRARY_PATH} \
&& CPPFLAGS=-I${NETCDF}/include LDFLAGS=-L${NETCDF}/lib ./configure --enable-shared --prefix=${NETCDF} &> /wrf/libs/build_log_ncf_config \
&& echo dummy printout to keep travis happy ncf config \
&& make install &> /wrf/libs/build_log_ncf_make \
&& echo dummy printout to keep travis happy ncf make \
&& cd /
# Install and setup Python3.8
RUN yum -y groupinstall "Development Tools"
RUN yum -y install openssl-devel bzip2-devel libffi-devel xz-devel
RUN mkdir -p /wrf/libs/python/BUILD_DIR \
&& cd /wrf/libs/python/BUILD_DIR \
&& wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz \
&& tar -xf Python-3.8.12.tgz \
&& cd Python-3.8.12 \
&& ./configure --enable-optimizations --prefix=/usr/local \
&& make altinstall \
&& cd / \
&& rm -rf /wrf/libs/python/BUILD_DIR
RUN python3.8 -m pip install numpy \
&& python3.8 -m pip install --upgrade pip \
&& python3.8 -m pip install --upgrade setuptools
RUN ldconfig -v
# Build netCDF4-python libraries
RUN source /opt/rh/devtoolset-10/enable \
&& cd ${NETCDF}/BUILD_DIR \
&& tar -xf v1.5.3rel.tar.gz \
&& cd netcdf4-python-1.5.3rel/ \
&& export LD_LIBRARY_PATH=${NETCDF}/lib:${LD_LIBRARY_PATH} \
&& export NETCDF4_DIR=${NETCDF} \
&& export HDF5_DIR=/usr/local \
&& python3.8 -m pip install wheel \
&& python3.8 setup.py build \
&& CPPFLAGS="-I${NETCDF}/include -I/usr/local/include" LDFLAGS="-L${NETCDF}/lib -L/usr/local/lib" python3.8 setup.py install \
&& echo dummy printout to keep travis happy ncf4-python install \
&& cd / \
&& rm -rf ${NETCDF}/BUILD_DIR
RUN mkdir -p /var/run/sshd \
&& ssh-keygen -A \
&& sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/g' /etc/ssh/sshd_config \
&& sed -i 's/#RSAAuthentication yes/RSAAuthentication yes/g' /etc/ssh/sshd_config \
&& sed -i 's/#PubkeyAuthentication yes/PubkeyAuthentication yes/g' /etc/ssh/sshd_config
RUN mkdir -p /wrf/WPS_GEOG /wrf/wrfinput /wrf/wrfoutput \
&& chown -R wrfuser:wrf /wrf /wrf/WPS_GEOG /wrf/wrfinput /wrf/wrfoutput /usr/local \
&& chmod 6755 /wrf /wrf/WPS_GEOG /wrf/wrfinput /wrf/wrfoutput /usr/local
# Download NCL
RUN curl -SL https://www.earthsystemgrid.org/api/v1/dataset/ncl.662.dap/file/ncl_ncarg-6.6.2-CentOS7.6_64bit_gnu485.tar.gz | tar zxC /usr/local
ENV NCARG_ROOT /usr/local
# Set environment for interactive container shells
RUN echo export LDFLAGS="-lm" >> /etc/bashrc \
&& echo export NETCDF=${NETCDF} >> /etc/bashrc \
&& echo export JASPERINC=/usr/include/jasper/ >> /etc/bashrc \
&& echo export JASPERLIB=/usr/lib64/ >> /etc/bashrc \
&& echo export LD_LIBRARY_PATH="/opt/rh/devtoolset-10/root/usr/lib/gcc/aarch64-redhat-linux/10:/usr/lib64/openmpi/lib:${NETCDF}/lib:${LD_LIBRARY_PATH}" >> /etc/bashrc \
&& echo export PATH=".:/opt/rh/devtoolset-10/root/usr/bin:/usr/lib64/openmpi/bin:${NETCDF}/bin:$PATH" >> /etc/bashrc \
&& echo export NCARG_ROOT=/usr/local >> /etc/bashrc
RUN echo setenv LDFLAGS "-lm" >> /etc/csh.cshrc \
&& echo setenv NETCDF "${NETCDF}" >> /etc/csh.cshrc \
&& echo setenv JASPERINC "/usr/include/jasper/" >> /etc/csh.cshrc \
&& echo setenv JASPERLIB "/usr/lib64/" >> /etc/csh.cshrc \
&& echo setenv LD_LIBRARY_PATH "/opt/rh/devtoolset-10/root/usr/lib/gcc/aarch64-redhat-linux/10:/usr/lib64/openmpi/lib:${NETCDF}/lib:${LD_LIBRARY_PATH}" >> /etc/csh.cshrc \
&& echo setenv PATH ".:/opt/rh/devtoolset-10/root/usr/bin:/usr/lib64/openmpi/bin:${NETCDF}/bin:$PATH" >> /etc/csh.cshrc \
&& echo setenv NCARG_ROOT /usr/local >> /etc/csh.cshrc
RUN mkdir /wrf/.ssh ; echo "StrictHostKeyChecking no" > /wrf/.ssh/config
COPY default-mca-params.conf /wrf/.openmpi/mca-params.conf
RUN mkdir -p /wrf/.openmpi
RUN chown -R wrfuser:wrf /wrf/
# all root steps completed above, now below as regular userID wrfuser
USER wrfuser
WORKDIR /wrf
# Download data
ARG argname=tutorial
RUN echo DAVE $argname
RUN if [ "$argname" = "tutorial" ] ; then curl -SL https://www2.mmm.ucar.edu/wrf/src/wps_files/geog_low_res_mandatory.tar.gz | tar -xzC /wrf/WPS_GEOG ; fi
RUN if [ "$argname" = "tutorial" ] ; then curl -SL https://www2.mmm.ucar.edu/wrf/TUTORIAL_DATA/colorado_march16.new.tar.gz | tar -xzC /wrf/wrfinput ; fi
RUN if [ "$argname" = "tutorial" ] ; then curl -SL https://www2.mmm.ucar.edu/wrf/src/namelists_v$NML_VERSION.tar.gz | tar -xzC /wrf/wrfinput ; fi
RUN if [ "$argname" = "tutorial" ] ; then curl -SL https://www2.mmm.ucar.edu/wrf/TUTORIAL_DATA/WRF_NCL_scripts.tar.gz | tar -xzC /wrf ; fi
RUN if [ "$argname" = "regtest" ] ; then curl -SL https://www2.mmm.ucar.edu/wrf/dave/data_smaller.tar.gz | tar -xzC /wrf ; fi
ENV JASPERINC /usr/include/jasper
ENV JASPERLIB /usr/lib64
ENV NETCDF_classic 1
ENV LD_LIBRARY_PATH /opt/rh/devtoolset-10/root/usr/lib/gcc/aarch64-redhat-linux/10:/usr/lib64/openmpi/lib:${NETCDF}/lib:${LD_LIBRARY_PATH}
ENV PATH .:/opt/rh/devtoolset-10/root/usr/bin:/usr/lib64/openmpi/bin:${NETCDF}/bin:$PATH
RUN ssh-keygen -f /wrf/.ssh/id_rsa -t rsa -N '' \
&& chmod 600 /wrf/.ssh/config \
&& chmod 700 /wrf/.ssh \
&& cp /wrf/.ssh/id_rsa.pub /wrf/.ssh/authorized_keys
#