Skip to content

Commit

Permalink
Per #2281, adding new files for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jprestop committed Oct 7, 2022
1 parent 28f408e commit df73b85
Show file tree
Hide file tree
Showing 3 changed files with 421 additions and 9 deletions.
202 changes: 202 additions & 0 deletions internal/scripts/docker/Dockerfile.gcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
#
# Specify version of gcc docker image to obtain
#
ARG GCC_VERSION=9.5.0

#
# This Dockerfile checks out MET from GitHub and compiles the specified branch or tag from source.
#
ARG SOURCE_BRANCH=feature_2281_linker_actions

FROM gcc:${GCC_VERSION}
MAINTAINER Julie Prestopnik <[email protected]>

#
# Set up the environment needed for MET
#

#
# Define the compilers.
#
ENV CC /usr/local/bin/gcc
ENV CXX /usr/local/bin/g++
ENV FC /usr/local/bin/gfortran
ENV F77 /usr/local/bin/gfortran

#
# Define package URL's.
#
ENV HDF4_URL http://www.hdfgroup.org/ftp/HDF/releases/HDF4.2r3/src/HDF4.2r3.tar.gz
ENV HDFEOS_URL https://dtcenter.ucar.edu/dfiles/code/METplus/MET/docker_data/HDF-EOS2.16v1.00.tar.Z

ENV HDF5_URL https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8/hdf5-1.8.18/src/hdf5-1.8.18.tar.gz

ENV NETCDF4C_URL https://github.com/Unidata/netcdf-c/archive/v4.4.1.1.zip
ENV NETCDF4CXX_URL https://github.com/Unidata/netcdf-cxx4/archive/v4.3.0.tar.gz

ENV BUFRLIB_URL https://dtcenter.ucar.edu/dfiles/code/METplus/MET/docker_data/BUFRLIB_v10-2-3.tar
ENV GSFONT_URL https://dtcenter.ucar.edu/dfiles/code/METplus/MET/docker_data/ghostscript-fonts-std-8.11.tar.gz

#
# Install the required packages.
#
RUN apt-get update -y
RUN apt-get install -y libpng-dev zlib1g-dev
RUN apt-get install -y tcsh ksh
RUN apt-get install -y flex bison
RUN apt-get install -y libgslcblas0 libgsl23 grads libgrib2c-dev
RUN apt-get install -y gv ncview
RUN apt-get install -y python3-pip
RUN pip3 install --upgrade pip
RUN python3 -m pip install numpy xarray netCDF4

#
# Set the working directory.
#
WORKDIR /met

#
# Setup the environment for interactive bash/csh container shells.
#
RUN echo export MET_BASE=/usr/local/share/met >> /etc/bashrc \
&& echo setenv MET_BASE /usr/local/share/met >> /etc/csh.cshrc \
&& echo export MET_FONT_DIR=/usr/local/share/met/fonts >> /etc/bashrc \
&& echo setenv MET_FONT_DIR /usr/local/share/met/fonts >> /etc/csh.cshrc \
&& echo export RSCRIPTS_BASE=/usr/local/share/met/Rscripts >> /etc/bashrc \
&& echo setenv RSCRIPTS_BASE /usr/local/share/met/Rscripts >> /etc/csh.cshrc \
&& echo export LD_LIBRARY_PATH=/usr/local/lib >> /etc/bashrc \
&& echo setenv LD_LIBRARY_PATH /usr/local/lib >> /etc/csh.cshrc
ENV LD_LIBRARY_PATH /usr/local/lib
ENV MET_FONT_DIR /usr/local/share/met/fonts

#
# Download and install BUFRLIB.
#
RUN mkdir -p /met/logs \
&& mkdir -p /met/external_libs/BUFRLIB \
&& cd /met/external_libs/BUFRLIB \
&& echo "Downloading BUFRLIB from ${BUFRLIB_URL}" \
&& curl -SL ${BUFRLIB_URL} | tar xC /met/external_libs/BUFRLIB \
&& cat preproc.sh | sed 's/cpp /cpp -traditional-cpp /g' > preproc_patch.sh \
&& chmod +x preproc_patch.sh \
&& LOG_FILE=/met/logs/BUFRLIB_build.log \
&& echo "Compiling BUFRLIB and writing log file ${LOG_FILE}" \
&& ./preproc_patch.sh *.F > ${LOG_FILE} \
&& ${CC} -c -DUNDERSCORE *.c >> ${LOG_FILE} \
&& ${FC} -c -fno-second-underscore *.f >> ${LOG_FILE} \
&& ar crv libbufr.a *.o >> ${LOG_FILE} \
&& rm -f /usr/local/lib/libbufr.a \
&& cp *.a /usr/local/lib \
&& cd /met/external_libs \
&& rm -rf BUFRLIB

#
# Download and install HDF5.
#

RUN mkdir -p /met/external_libs/hdf5 \
&& cd /met/external_libs/hdf5 \
&& echo "Downloading hdf5-1.8.18 from ${HDF5_URL}" \
&& wget ${HDF5_URL} \
&& tar -xzf hdf5-1.8.18.tar.gz \
&& cd hdf5-1.8.18 \
&& LOG_FILE=/met/logs/hdf5-1.8.18_configure.log \
&& echo "Configuring hdf5-1.8.18 and writing log file ${LOG_FILE}" \
&& ./configure --prefix=/usr/local CFLAGS=-fPIC CXXFLAGS=-fPIC FFLAGS=-fPIC > ${LOG_FILE} \
&& LOG_FILE=/met/logs/hdf5-1.8.18_make_install.log \
&& echo "Compiling hdf5-1.8.18 and writing log file ${LOG_FILE}" \
&& make install > ${LOG_FILE} \
&& cd /met/external_libs \
&& rm -rf hdf5

#
# Download and install NetCDF4 (C and C++).
#

RUN mkdir -p /met/external_libs/netcdf \
&& cd /met/external_libs/netcdf \
&& echo "Downloading netcdf-c-4.4.1.1 from ${NETCDF4C_URL}" \
&& wget ${NETCDF4C_URL} \
&& unzip v4.4.1.1.zip \
&& cd netcdf-c-4.4.1.1 \
&& LOG_FILE=/met/logs/netcdf-c-4.4.1.1_configure.log \
&& echo "Configuring netcdf-c-4.4.1.1 and writing log file ${LOG_FILE}" \
&& ./configure --prefix=/usr/local LDFLAGS=-L/usr/local/lib:/usr/lib/x86_64-linux-gnu/ CPPFLAGS=-I/usr/local/include:/usr/include LIBS="${LIBS} -lhdf5_hl -lhdf5 -lz" > ${LOG_FILE} \
&& LOG_FILE=/met/logs/netcdf-c-4.4.1.1_make_install.log \
&& echo "Compiling netcdf-c-4.4.1.1 and writing log file ${LOG_FILE}" \
&& make install > ${LOG_FILE} \
&& echo "Downloading from ${NETCDF4CXX_URL}" \
&& cd /met/external_libs/netcdf \
&& wget ${NETCDF4CXX_URL} \
&& tar -xzf v4.3.0.tar.gz \
&& cd netcdf-cxx4-4.3.0 \
&& LOG_FILE=/met/logs/netcdf-cxx4-4.3.0_configure.log \
&& echo "Configuring netcdf-cxx4-4.3.0 and writing log file ${LOG_FILE}" \
&& ./configure --prefix=/usr/local > ${LOG_FILE} \
&& LOG_FILE=/met/logs/netcdf-cxx4-4.3.0_make_install.log \
&& echo "Compiling netcdf-cxx4-4.3.0 and writing log file ${LOG_FILE}" \
&& make install > ${LOG_FILE} \
&& cd /met/external_libs \
&& rm -rf netcdf

#
# Download and install HDF4 and HDFEOS.
#
RUN echo "Downloading HDF4.2r3 from ${HDF4_URL}" \
&& curl -SL ${HDF4_URL} | tar zxC /met/external_libs \
&& cd /met/external_libs/HDF4.2r3 \
&& LOG_FILE=/met/logs/HDF4.2r3_configure.log \
&& echo "Configuring HDF4.2r3 and writing log file ${LOG_FILE}" \
&& ./configure --prefix=/usr/local/hdf --disable-netcdf > ${LOG_FILE} \
&& cat mfhdf/hdiff/Makefile | sed 's/LIBS = -ljpeg -lz/LIBS = -ljpeg -lz -lm/g' > Makefile_NEW \
&& mv -f Makefile_NEW mfhdf/hdiff/Makefile \
&& LOG_FILE=/met/logs/HDF4.2r3_make_install.log \
&& echo "Compiling HDF4.2r3 and writing log file ${LOG_FILE}" \
&& make install > ${LOG_FILE} \
&& echo "Downloading hdfeos from ${HDFEOS_URL}" \
&& curl -SL ${HDFEOS_URL} | tar zxC /met/external_libs \
&& cd /met/external_libs/hdfeos \
&& LOG_FILE=/met/logs/hdfeos_configure.log \
&& echo "Configuring hdfeos and writing log file ${LOG_FILE}" \
&& ./configure --prefix=/usr/local/hdfeos --with-hdf4=/usr/local/hdf CC=/usr/local/hdf/bin/h4cc > ${LOG_FILE} \
&& LOG_FILE=/met/logs/hdfeos_make_install.log \
&& echo "Compiling hdfeos and writing log file ${LOG_FILE}" \
&& make install > ${LOG_FILE} \
&& mkdir /usr/local/hdfeos/include \
&& cp include/*.h /usr/local/hdfeos/include/. \
&& cd /met/external_libs \
&& rm -rf HDF4.2r3 hdfeos

RUN echo "Downloading GhostScript fonts from ${GSFONT_URL} into /usr/local/share/met" \
&& mkdir -p /usr/local/share/met \
&& curl -SL ${GSFONT_URL} | tar zxC /usr/local/share/met

#
# SOURCE_BRANCH is not defined when built via Docker Hub.
#
RUN if [ "x${SOURCE_BRANCH}" = "x" ]; then \
echo "ERROR: SOURCE_BRANCH undefined! Rebuild with \"--build-arg SOURCE_BRANCH={branch name}\""; \
exit 1; \
else \
echo "Build Argument SOURCE_BRANCH=${SOURCE_BRANCH}"; \
fi

ENV MET_GIT_NAME ${SOURCE_BRANCH}
ENV MET_REPO_DIR /met/MET-${MET_GIT_NAME}
ENV MET_GIT_URL https://github.com/dtcenter/MET
ENV MET_DEVELOPMENT true

#
# Set the working directory.
#
WORKDIR /met

#
# Download and install MET and GhostScript fonts.
# Delete the MET source code for tagged releases matching "v"*.
#
RUN echo "Checking out MET ${MET_GIT_NAME} from ${MET_GIT_URL}" \
&& git clone ${MET_GIT_URL} ${MET_REPO_DIR} \
&& cd ${MET_REPO_DIR} \
&& git checkout ${MET_GIT_NAME} \
&& internal/scripts/docker/build_met_docker.sh
Loading

0 comments on commit df73b85

Please sign in to comment.