1
- FROM dtcenter/common-community-container:gnu9
1
+ FROM debian:12
2
+ MAINTAINER Michael Kavulich <kavulich@ucar.edu>
2
3
3
- MAINTAINER Michelle Harrold <harrold@ucar.edu> or Grant Firl <grantf@ucar.edu> or Michael Kavulich <kavulich@ucar.edu>
4
+ # Set up base OS environment
4
5
5
- #
6
- # Dockerfile for building CCPP SCM container
7
- #
6
+ RUN apt-get -y update
8
7
9
- # Note: The common community container image contains the following packages, which are used to build the SCM:
10
- # gfortran, gcc, cmake, netCDF, HDF5, ZLIB, SZIP, Python, and libxml2
11
- # To access the common community container repository: https://github.com/NCAR/Common-Community-Container
8
+ # Get "essential" tools and libraries
9
+ RUN apt-get -y install build-essential \
10
+ && apt-get -y install cmake curl git file gfortran-12 ksh m4 python3 tcsh time wget vim \
11
+ && apt-get -y install libnetcdf-pnetcdf-19 libnetcdff7 libnetcdf-dev libnetcdff-dev libxml2 \
12
+ && apt-get -y install python3-pip python3.11-venv
12
13
13
- # Obtain CCPP SCM source code
14
- RUN cd /comsoftware \
15
- && git clone --recursive -b release/public-v6 https://github.com/NCAR/ccpp-scm
16
-
17
- # Obtain static data that was previously stored in repository
18
- RUN cd /comsoftware/ccpp-scm/ \
19
- && . contrib/get_all_static_data.sh
20
-
21
- # Obtain the pre-computed look-up tables for running with Thompson microphysics
22
- RUN cd /comsoftware/ccpp-scm/ \
23
- && . contrib/get_thompson_tables.sh
24
-
25
- # Run the machine setup script to set environment variables
26
- ENV CC=/opt/rh/devtoolset-9/root/usr/bin/gcc
27
- ENV CXX=/opt/rh/devtoolset-9/root/usr/bin/g++
28
- ENV F77=/opt/rh/devtoolset-9/root/usr/bin/gfortran
29
- ENV F90=/opt/rh/devtoolset-9/root/usr/bin/gfortran
30
- ENV FC=/opt/rh/devtoolset-9/root/usr/bin/gfortran
31
-
32
- ENV NETCDF=/comsoftware/libs/netcdf
33
-
34
- RUN cd /comsoftware/ccpp-scm/contrib \
35
- && wget https://raw.githubusercontent.com/NCAR/ccpp-scm/3f501aa8af0fb00ff124d8301c932292d1d0abf3/contrib/build_nceplibs.sh \
36
- && chmod +x build_nceplibs.sh \
37
- && cd .. \
38
- && ./contrib/build_nceplibs.sh $PWD/nceplibs
39
-
40
- ENV bacio_ROOT /comsoftware/ccpp-scm/nceplibs
41
- ENV sp_ROOT /comsoftware/ccpp-scm/nceplibs
42
- ENV w3nco_ROOT /comsoftware/ccpp-scm/nceplibs
43
-
44
- # Create your own link from python -> python3
45
- # This works without setting the system PATH env var
46
- # since /usr/local/bin is before /usr/bin in the search path.
47
- USER root
48
- RUN ln -s /usr/bin/python3 /usr/local/bin/python
14
+ MAINTAINER Grant Firl <grantf@ucar.edu> or Michael Kavulich <kavulich@ucar.edu>
15
+
16
+ # Compiler environment variables
17
+ ENV CC /usr/bin/gcc
18
+ ENV FC /usr/bin/gfortran
19
+ ENV CXX /usr/bin/g++
20
+ ENV F77 /usr/bin/gfortran
21
+ ENV F90 /usr/bin/gfortran
22
+
23
+ # Other necessary environment variables
24
+ ENV LD_LIBRARY_PATH /usr/lib/
25
+
26
+ # Set up unpriviledged user account, set up user home space and make sure user has permissions on all stuff in /comsoftware
27
+ RUN groupadd comusers -g 9999 \
28
+ && useradd -u 9999 -g comusers -M -s /bin/bash -c "Unpriviledged user account" -d /home comuser \
29
+ && mkdir /comsoftware \
30
+ && chown -R comuser:comusers /home \
31
+ && chmod 6755 /home \
32
+ && chown -R comuser:comusers /comsoftware \
33
+ && chmod -R 6755 /comsoftware
34
+
35
+ # Link version-specific aliases (python3 will be created later with virtual environment)
36
+ RUN ln -s ~comuser/.venv/bin/python3 /usr/local/bin/python
37
+ RUN ln -s /usr/bin/gfortran-12 /usr/bin/gfortran
38
+
39
+ # all root steps completed above, now continue below as regular userID comuser
49
40
USER comuser
41
+ WORKDIR /home
42
+
43
+ # Build NCEP libraries we need for SCM
44
+
45
+ ENV NCEPLIBS_DIR /comsoftware/nceplibs
50
46
51
- # Invoke cmake on the source code to build
52
- RUN cd /comsoftware/ccpp-scm/scm \
47
+ RUN mkdir -p $NCEPLIBS_DIR/src && cd $NCEPLIBS_DIR/src \
48
+ && git clone -b v2.4.1 --recursive https://github.com/NOAA-EMC/NCEPLIBS-bacio \
49
+ && mkdir NCEPLIBS-bacio/build && cd NCEPLIBS-bacio/build \
50
+ && cmake -DCMAKE_INSTALL_PREFIX=$NCEPLIBS_DIR .. \
51
+ && make VERBOSE=1 \
52
+ && make install
53
+
54
+ RUN cd $NCEPLIBS_DIR/src \
55
+ && git clone -b v2.3.3 --recursive https://github.com/NOAA-EMC/NCEPLIBS-sp \
56
+ && mkdir NCEPLIBS-sp/build && cd NCEPLIBS-sp/build \
57
+ && cmake -DCMAKE_INSTALL_PREFIX=$NCEPLIBS_DIR .. \
58
+ && make VERBOSE=1 \
59
+ && make install
60
+
61
+ RUN cd $NCEPLIBS_DIR/src \
62
+ && git clone -b v2.11.0 --recursive https://github.com/NOAA-EMC/NCEPLIBS-w3emc \
63
+ && mkdir NCEPLIBS-w3emc/build && cd NCEPLIBS-w3emc/build \
64
+ && cmake -DCMAKE_INSTALL_PREFIX=$NCEPLIBS_DIR .. \
65
+ && make VERBOSE=1 \
66
+ && make install
67
+
68
+ ENV bacio_ROOT /comsoftware/nceplibs
69
+ ENV sp_ROOT /comsoftware/nceplibs
70
+ ENV w3emc_ROOT /comsoftware/nceplibs
71
+
72
+ # Obtain CCPP SCM source code and static data, build code
73
+ RUN cd /comsoftware \
74
+ && git clone --recursive -b main https://github.com/NCAR/ccpp-scm \
75
+ && cd /comsoftware/ccpp-scm/ \
76
+ && ./contrib/get_all_static_data.sh \
77
+ && ./contrib/get_thompson_tables.sh \
78
+ && cd /comsoftware/ccpp-scm/scm \
53
79
&& mkdir bin \
54
80
&& cd bin \
55
81
&& cmake ../src \
@@ -67,3 +93,12 @@ RUN cd /comsoftware/ccpp-scm/scm \
67
93
WORKDIR /comsoftware/ccpp-scm/scm/bin
68
94
ENV SCM_WORK=/comsoftware
69
95
ENV SCM_ROOT=/comsoftware/ccpp-scm/
96
+
97
+ # For interactive use, vim mouse settings are infuriating
98
+ RUN echo "set mouse=" > ~/.vimrc
99
+
100
+ # Set up python virtual environment and install needed packages
101
+ ENV VIRTUAL_ENV=~/.venv
102
+ RUN python3 -m venv $VIRTUAL_ENV
103
+ ENV PATH="$VIRTUAL_ENV/bin:$PATH"
104
+ RUN pip3 install f90nml==1.4.4 netcdf4==1.6.5
0 commit comments