Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docker container, add Docker auto-build and test, update documentation for building with spack-stack #466

Merged
merged 34 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6e2c33a
Add a macos clang module file
mkavulich Apr 3, 2024
1f6014a
Starting documentation updates for build/run
mkavulich Apr 5, 2024
8d90db0
Update dockerfile for latest main branch
mkavulich Apr 25, 2024
e0e18f7
Update Dockerfile python setup; now runs test case successfully. Upda…
mkavulich Apr 29, 2024
d1d16a7
Testing out docker autobuild CI
mkavulich Apr 30, 2024
b6a1c31
Don't run CI on all pushes
mkavulich Apr 30, 2024
5c9b124
Fixing docker context for CI
mkavulich Apr 30, 2024
6b12f31
Small users guide addition about Docker usage, try to fix docker CI h…
mkavulich Apr 30, 2024
cc88611
Testing docker CI
mkavulich Apr 30, 2024
edf6b18
Testing push of the test tag to dockerhub
mkavulich Apr 30, 2024
f12b0b8
Testing pull of docker CI test tag
mkavulich Apr 30, 2024
048b018
Testing HOME permissions for docker CI
mkavulich Apr 30, 2024
d563524
Adding write permissions to $HOME for docker CI
mkavulich Apr 30, 2024
9c8556f
Adding read+write permissions to $HOME recursively wqfor docker CI
mkavulich Apr 30, 2024
2d0182e
Put output in a subdirectory of $HOME to avoid permissions issues for…
mkavulich Apr 30, 2024
a0c0c9f
chmod wasn't working as expected
mkavulich Apr 30, 2024
4f5d74d
chmod STILL wasn't working as expected
mkavulich Apr 30, 2024
a9bda64
I will never ever trust myself with a chmod command again
mkavulich Apr 30, 2024
4087a9f
It works! Now to try running all test cases
mkavulich Apr 30, 2024
19350a5
Now to run it all together...
mkavulich Apr 30, 2024
e1ce0cc
Consolidate dockerfile RUN commands to shrink container size
mkavulich Apr 30, 2024
78ad73c
More updates to Quick Start chapter:
mkavulich May 1, 2024
1ff40ce
Split out the CI test that pushes new container to Dockerhub, only ru…
mkavulich May 1, 2024
3d2ce1b
Add Linux GNU modulefile, remove compiler version from macos_clang mo…
mkavulich May 1, 2024
a93a5a5
More quick-start updates
mkavulich May 1, 2024
18fb473
Minor users guide updates
mkavulich May 1, 2024
daf8563
Consolidate some repeated directory setup commands in Dockerfile
mkavulich May 1, 2024
755e0c5
More Quick Start updates
mkavulich May 1, 2024
6cb6db8
Fix format error, convert some important notes to warnings
mkavulich May 1, 2024
1d2f9e7
Fix incorrect Dockerhub org name
mkavulich May 1, 2024
074fbd8
Apparently GitHub secrets are not passed when PRs come in from forks.…
mkavulich May 1, 2024
2257062
Fix dockerfile
mkavulich May 1, 2024
0283c18
Updates from Dustin's comments
mkavulich May 15, 2024
10c8f05
Run build and push docker test on ubuntu-22.04 per concerns about "la…
mkavulich May 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/build_and_push_docker_latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: build_test_and_push_docker

on:
push:
branches:
# Only build containers when pushing to main
- "main"

env:
LATEST_TAG: dtcenter/ccpp-scm:latest

jobs:
docker:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push latest tag
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ env.LATEST_TAG }}
2 changes: 1 addition & 1 deletion .github/workflows/ci_build_scm_ubuntu_22.04_nvidia.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI test to build the CCPP-SCM on ubuntu v22.04

on: [push,pull_request,workflow_dispatch]
on: [pull_request,workflow_dispatch]

jobs:

Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/ci_test_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: build_test_and_push_docker

on: [pull_request,workflow_dispatch]

env:
TEST_TAG: dtcenter/ccpp-scm:test

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and export test tag
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
load: true
tags: ${{ env.TEST_TAG }}
- name: Test
run: |
mkdir $HOME/output
chmod a+rw $HOME/output
docker run --rm -v $HOME/output:/home ${{ env.TEST_TAG }} ./run_scm.py -f ../../test/rt_test_cases.py --runtime_mult 0.1 -d
127 changes: 81 additions & 46 deletions docker/Dockerfile
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we name this file Dockerfile_GNU or Dockerfile_GNUv12? Just in case we get an Intel one soon.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point; do you think there is a possibility that Intel might be doable? Last time I worked with Docker (a few years ago) Intel was very difficult to get working in containers.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JCSDA uses Intel in Docker all the time. The only issue is that you can't distribute the containers to the public.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, okay that's good to know. If we do implement containers for testing we'll need a place to push them other than Dockerhub anyway, so it sounds like this may work.

Original file line number Diff line number Diff line change
@@ -1,55 +1,81 @@
FROM dtcenter/common-community-container:gnu9
FROM debian:12
MAINTAINER Michael Kavulich <[email protected]>

MAINTAINER Michelle Harrold <[email protected]> or Grant Firl <[email protected]> or Michael Kavulich <[email protected]>
# Set up base OS environment

#
# Dockerfile for building CCPP SCM container
#
RUN apt-get -y update

# Note: The common community container image contains the following packages, which are used to build the SCM:
# gfortran, gcc, cmake, netCDF, HDF5, ZLIB, SZIP, Python, and libxml2
# To access the common community container repository: https://github.com/NCAR/Common-Community-Container
# Get "essential" tools and libraries
RUN apt-get -y install build-essential \
&& apt-get -y install cmake curl git file gfortran-12 ksh m4 python3 tcsh time wget vim \
&& apt-get -y install libnetcdf-pnetcdf-19 libnetcdff7 libnetcdf-dev libnetcdff-dev libxml2 \
&& apt-get -y install python3-pip python3.11-venv

# Obtain CCPP SCM source code
RUN cd /comsoftware \
&& git clone --recursive -b release/public-v6 https://github.com/NCAR/ccpp-scm

# Obtain static data that was previously stored in repository
RUN cd /comsoftware/ccpp-scm/ \
&& . contrib/get_all_static_data.sh

# Obtain the pre-computed look-up tables for running with Thompson microphysics
RUN cd /comsoftware/ccpp-scm/ \
&& . contrib/get_thompson_tables.sh

# Run the machine setup script to set environment variables
ENV CC=/opt/rh/devtoolset-9/root/usr/bin/gcc
ENV CXX=/opt/rh/devtoolset-9/root/usr/bin/g++
ENV F77=/opt/rh/devtoolset-9/root/usr/bin/gfortran
ENV F90=/opt/rh/devtoolset-9/root/usr/bin/gfortran
ENV FC=/opt/rh/devtoolset-9/root/usr/bin/gfortran

ENV NETCDF=/comsoftware/libs/netcdf

RUN cd /comsoftware/ccpp-scm/contrib \
&& wget https://raw.githubusercontent.com/NCAR/ccpp-scm/3f501aa8af0fb00ff124d8301c932292d1d0abf3/contrib/build_nceplibs.sh \
&& chmod +x build_nceplibs.sh \
&& cd .. \
&& ./contrib/build_nceplibs.sh $PWD/nceplibs

ENV bacio_ROOT /comsoftware/ccpp-scm/nceplibs
ENV sp_ROOT /comsoftware/ccpp-scm/nceplibs
ENV w3nco_ROOT /comsoftware/ccpp-scm/nceplibs

# Create your own link from python -> python3
# This works without setting the system PATH env var
# since /usr/local/bin is before /usr/bin in the search path.
USER root
RUN ln -s /usr/bin/python3 /usr/local/bin/python
MAINTAINER Grant Firl <[email protected]> or Michael Kavulich <[email protected]>

#Compiler environment variables
ENV CC /usr/bin/gcc
ENV FC /usr/bin/gfortran
ENV CXX /usr/bin/g++
ENV F77 /usr/bin/gfortran
ENV F90 /usr/bin/gfortran

# Other necessary environment variables
ENV LD_LIBRARY_PATH /usr/lib/

# Set up unpriviledged user account, set up user home space and make sure user has permissions on all stuff in /comsoftware
RUN groupadd comusers -g 9999 \
&& useradd -u 9999 -g comusers -M -s /bin/bash -c "Unpriviledged user account" -d /home comuser \
&& mkdir /comsoftware \
&& chown -R comuser:comusers /home \
&& chmod 6755 /home \
&& chown -R comuser:comusers /comsoftware \
&& chmod -R 6755 /comsoftware

# Link version-specific aliases (python3 will be created later with virtual environment)
RUN ln -s ~comuser/.venv/bin/python3 /usr/local/bin/python
RUN ln -s /usr/bin/gfortran-12 /usr/bin/gfortran

# all root steps completed above, now continue below as regular userID comuser
USER comuser
WORKDIR /home

# Build NCEP libraries we need for SCM

ENV NCEPLIBS_DIR /comsoftware/nceplibs

# Invoke cmake on the source code to build
RUN cd /comsoftware/ccpp-scm/scm \
RUN mkdir -p $NCEPLIBS_DIR/src && cd $NCEPLIBS_DIR/src \
&& git clone -b v2.4.1 --recursive https://github.com/NOAA-EMC/NCEPLIBS-bacio \
grantfirl marked this conversation as resolved.
Show resolved Hide resolved
&& mkdir NCEPLIBS-bacio/build && cd NCEPLIBS-bacio/build \
&& cmake -DCMAKE_INSTALL_PREFIX=$NCEPLIBS_DIR .. \
&& make VERBOSE=1 \
&& make install

RUN cd $NCEPLIBS_DIR/src \
&& git clone -b v2.3.3 --recursive https://github.com/NOAA-EMC/NCEPLIBS-sp \
&& mkdir NCEPLIBS-sp/build && cd NCEPLIBS-sp/build \
&& cmake -DCMAKE_INSTALL_PREFIX=$NCEPLIBS_DIR .. \
&& make VERBOSE=1 \
&& make install

RUN cd $NCEPLIBS_DIR/src \
&& git clone -b v2.11.0 --recursive https://github.com/NOAA-EMC/NCEPLIBS-w3emc \
&& mkdir NCEPLIBS-w3emc/build && cd NCEPLIBS-w3emc/build \
&& cmake -DCMAKE_INSTALL_PREFIX=$NCEPLIBS_DIR .. \
&& make VERBOSE=1 \
&& make install

ENV bacio_ROOT /comsoftware/nceplibs
ENV sp_ROOT /comsoftware/nceplibs
ENV w3emc_ROOT /comsoftware/nceplibs

# Obtain CCPP SCM source code and static data, build code
RUN cd /comsoftware \
&& git clone --recursive -b main https://github.com/NCAR/ccpp-scm \
&& cd /comsoftware/ccpp-scm/ \
&& ./contrib/get_all_static_data.sh \
&& ./contrib/get_thompson_tables.sh \
&& cd /comsoftware/ccpp-scm/scm \
grantfirl marked this conversation as resolved.
Show resolved Hide resolved
&& mkdir bin \
&& cd bin \
&& cmake ../src \
Expand All @@ -67,3 +93,12 @@ RUN cd /comsoftware/ccpp-scm/scm \
WORKDIR /comsoftware/ccpp-scm/scm/bin
ENV SCM_WORK=/comsoftware
ENV SCM_ROOT=/comsoftware/ccpp-scm/

# For interactive use, vim mouse settings are infuriating
RUN echo "set mouse=" > ~/.vimrc

# Set up python virtual environment and install needed packages
ENV VIRTUAL_ENV=~/.venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN pip3 install f90nml==1.4.4 netcdf4==1.6.5
2 changes: 1 addition & 1 deletion scm/doc/TechGuide/chap_intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ This release bundle has some known limitations:

- As of this release, using the SCM over a land point with an LSM is
possible through the use of UFS initial conditions (see
:numref:`Section %s <UFS ICs>`). However, advective forcing terms
:numref:`Section %s <UFSreplay>`). However, advective forcing terms
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW. We are going to need to change all instances of "replay" in the documentation to "case generation".
There will be a subsequent PR with those code changes, so no need to address this at the moment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link is currently broken (not caught in the last PR) so this just updates the link to point to the correct place.

are unavailable as of this release, so only short integrations using
this configuration should be employed. Using dynamical tendencies
(advective forcing terms) from the UFS will be part of a future
Expand Down
Loading
Loading