Skip to content

Commit 046559b

Browse files
authored
Merge pull request #466 from mkavulich/feature/macos_and_docker_build
Update docker container, add Docker auto-build and test, update documentation for building with spack-stack
2 parents 148b068 + 10c8f05 commit 046559b

File tree

9 files changed

+458
-254
lines changed

9 files changed

+458
-254
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: build_test_and_push_docker
2+
3+
on:
4+
push:
5+
branches:
6+
# Only build containers when pushing to main
7+
- "main"
8+
9+
env:
10+
LATEST_TAG: dtcenter/ccpp-scm:latest
11+
12+
jobs:
13+
docker:
14+
runs-on: ubuntu-22.04
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
- name: Set up QEMU
19+
uses: docker/setup-qemu-action@v3
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
- name: Login to Docker Hub
23+
uses: docker/login-action@v3
24+
with:
25+
username: ${{ secrets.DOCKERHUB_USERNAME }}
26+
password: ${{ secrets.DOCKERHUB_TOKEN }}
27+
- name: Push latest tag
28+
uses: docker/build-push-action@v5
29+
with:
30+
context: .
31+
file: docker/Dockerfile
32+
platforms: linux/amd64,linux/arm64
33+
push: true
34+
tags: ${{ env.LATEST_TAG }}

.github/workflows/ci_build_scm_ubuntu_22.04_nvidia.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: CI test to build the CCPP-SCM on ubuntu v22.04
22

3-
on: [push,pull_request,workflow_dispatch]
3+
on: [pull_request,workflow_dispatch]
44

55
jobs:
66

.github/workflows/ci_test_docker.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: build_test_and_push_docker
2+
3+
on: [pull_request,workflow_dispatch]
4+
5+
env:
6+
TEST_TAG: dtcenter/ccpp-scm:test
7+
8+
jobs:
9+
docker:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
- name: Set up QEMU
15+
uses: docker/setup-qemu-action@v3
16+
- name: Set up Docker Buildx
17+
uses: docker/setup-buildx-action@v3
18+
- name: Build and export test tag
19+
uses: docker/build-push-action@v5
20+
with:
21+
context: .
22+
file: docker/Dockerfile
23+
load: true
24+
tags: ${{ env.TEST_TAG }}
25+
- name: Test
26+
run: |
27+
mkdir $HOME/output
28+
chmod a+rw $HOME/output
29+
docker run --rm -v $HOME/output:/home ${{ env.TEST_TAG }} ./run_scm.py -f ../../test/rt_test_cases.py --runtime_mult 0.1 -d

docker/Dockerfile

Lines changed: 81 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,81 @@
1-
FROM dtcenter/common-community-container:gnu9
1+
FROM debian:12
2+
MAINTAINER Michael Kavulich <kavulich@ucar.edu>
23

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
45

5-
#
6-
# Dockerfile for building CCPP SCM container
7-
#
6+
RUN apt-get -y update
87

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
1213

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
4940
USER comuser
41+
WORKDIR /home
42+
43+
# Build NCEP libraries we need for SCM
44+
45+
ENV NCEPLIBS_DIR /comsoftware/nceplibs
5046

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 \
5379
&& mkdir bin \
5480
&& cd bin \
5581
&& cmake ../src \
@@ -67,3 +93,12 @@ RUN cd /comsoftware/ccpp-scm/scm \
6793
WORKDIR /comsoftware/ccpp-scm/scm/bin
6894
ENV SCM_WORK=/comsoftware
6995
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

scm/doc/TechGuide/chap_intro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ This release bundle has some known limitations:
103103

104104
- As of this release, using the SCM over a land point with an LSM is
105105
possible through the use of UFS initial conditions (see
106-
:numref:`Section %s <UFS ICs>`). However, advective forcing terms
106+
:numref:`Section %s <UFSreplay>`). However, advective forcing terms
107107
are unavailable as of this release, so only short integrations using
108108
this configuration should be employed. Using dynamical tendencies
109109
(advective forcing terms) from the UFS will be part of a future

0 commit comments

Comments
 (0)