This repository has been archived by the owner on Dec 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add spack config yaml and template to generate dockerfile
- Loading branch information
rem1776
committed
Jan 3, 2024
1 parent
2021773
commit 9db9ef3
Showing
4 changed files
with
191 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,35 +17,75 @@ | |
# License along with FRE-NCTools. If not, see | ||
# <http://www.gnu.org/licenses/>. | ||
#*********************************************************************** | ||
# Build stage with Spack pre-installed and ready to be used | ||
FROM spack/rockylinux9:latest as builder | ||
|
||
|
||
# What we want to install and how we want to install it | ||
# is specified in a manifest file (spack.yaml) | ||
RUN mkdir /opt/spack-environment \ | ||
&& (echo spack: \ | ||
&& echo ' specs:' \ | ||
&& echo ' - gcc' \ | ||
&& echo ' - mpich' \ | ||
&& echo ' - netcdf-c' \ | ||
&& echo ' - netcdf-fortran' \ | ||
&& echo ' - nccmp' \ | ||
&& echo ' concretizer:' \ | ||
&& echo ' unify: true' \ | ||
&& echo ' packages:' \ | ||
&& echo ' all:' \ | ||
&& echo ' compiler: [gcc]' \ | ||
&& echo ' config:' \ | ||
&& echo ' template_dirs:' \ | ||
&& echo ' - /home/rem/fre-nctools-container/template' \ | ||
&& echo ' # container specific options' \ | ||
&& echo ' install_tree: /opt/software' \ | ||
&& echo ' view: /opt/views/view') > /opt/spack-environment/spack.yaml | ||
|
||
# Install the software, remove unnecessary deps | ||
RUN cd /opt/spack-environment && spack env activate . && spack install --fail-fast && spack gc -y | ||
|
||
# Modifications to the environment that are necessary to run | ||
RUN cd /opt/spack-environment && \ | ||
spack env activate --sh -d . > activate.sh | ||
|
||
|
||
|
||
# Bare OS image to run the installed executables | ||
FROM docker.io/rockylinux:9 | ||
|
||
COPY --from=builder /opt/spack-environment /opt/spack-environment | ||
COPY --from=builder /opt/software /opt/software | ||
|
||
# paths.view is a symlink, so copy the parent to avoid dereferencing and duplicating it | ||
COPY --from=builder /opt/views /opt/views | ||
|
||
RUN { \ | ||
echo '#!/bin/sh' \ | ||
&& echo '.' /opt/spack-environment/activate.sh \ | ||
&& echo 'exec "$@"'; \ | ||
} > /entrypoint.sh \ | ||
&& chmod a+x /entrypoint.sh \ | ||
&& ln -s /opt/views/view /opt/view | ||
|
||
|
||
RUN dnf update -y && dnf install -y epel-release && dnf update -y \ | ||
&& dnf install -y autoconf libtool make bats git libgomp python3 python3-numpy python3-pip python3-pytest \ | ||
&& rm -rf /var/cache/dnf && dnf clean all | ||
|
||
# Install any needed pip packages | ||
RUN pip install git+https://github.com/adcroft/numpypi.git && \ | ||
pip install netCDF4 virtualenv | ||
# Set compilers for mpich wrappers | ||
ENV MPICH_FC=gfortran | ||
ENV MPICH_CC=gcc | ||
LABEL "maintainer"="Seth Underwood <[email protected]>" | ||
LABEL "copyright"="2021, 2022, 2023 GFDL" | ||
LABEL "license"="LGPL v3+" | ||
LABEL "gov.noaa.gfdl.version"="5.0.0" | ||
LABEL "vendor"="Geophysical Fluid Dynamics Laboratory" | ||
LABEL "gov.noaa.gfdl.release-date"="2024-01-07" | ||
ENTRYPOINT [ "/entrypoint.sh" ] | ||
CMD [ "/bin/bash" ] | ||
|
||
FROM ubuntu:focal | ||
LABEL maintainer="Seth Underwood <[email protected]>" | ||
LABEL copyright="2021, 2022 GFDL" | ||
LABEL license="LGPL v3+" | ||
LABEL gov.noaa.gfdl.version="3.0.0" | ||
LABEL vendor="Geophysical Fluid Dynamics Laboratory" | ||
LABEL gov.noaa.gfdl.release-date="2022-02-20" | ||
|
||
## install fre-nctools dependencies | ||
RUN apt-get update \ | ||
&& apt-get -y install software-properties-common \ | ||
&& add-apt-repository ppa:underwoo/nccmp --update \ | ||
&& apt-get install -y \ | ||
autoconf \ | ||
bats \ | ||
gfortran \ | ||
git \ | ||
libnetcdf-dev \ | ||
libnetcdff-dev \ | ||
make \ | ||
nccmp \ | ||
netcdf-bin \ | ||
python \ | ||
python3-netcdf4 \ | ||
python3-numpy \ | ||
python3-pip \ | ||
python3-pytest \ | ||
python3-venv \ | ||
mpich \ | ||
libmpich-dev \ | ||
&& pip install git+https://github.com/adcroft/numpypi.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#*********************************************************************** | ||
# GNU Lesser General Public License | ||
# | ||
# This file is part of the GFDL FRE NetCDF tools package (FRE-NCTools). | ||
# | ||
# FRE-NCTools is free software: you can redistribute it and/or modify it under | ||
# the terms of the GNU Lesser General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or (at | ||
# your option) any later version. | ||
# | ||
# FRE-NCTools is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
# for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with FRE-NCTools. If not, see | ||
# <http://www.gnu.org/licenses/>. | ||
#*********************************************************************** | ||
# Ryan Mulhall 2023 | ||
# spack environment config to generate a dockerfile for the fre-nctools ci image. | ||
# After any updates to generate a new dockerfile you must fill in the template_dirs below with your current | ||
# directory and run the following: | ||
# | ||
# <clone spack and source spack/share/spack/setup-env.sh) | ||
# spack env create fnct-container-env spack.yaml | ||
# spack env activate fnct-container-env | ||
# spack containerize > Dockerfile | ||
# | ||
# For versions, spack packages will use the default (usually the newest but depends on whats compatible) | ||
# Images should be tagged with gcc version used | ||
spack: | ||
specs: | ||
- gcc | ||
- mpich | ||
- netcdf-c | ||
- netcdf-fortran | ||
- nccmp | ||
concretizer: | ||
unify: true | ||
packages: | ||
all: | ||
compiler: [ gcc ] | ||
config: | ||
template_dirs: | ||
- /home/rem/fre-nctools-container/template | ||
# container specific options | ||
container: | ||
format: docker | ||
template: Dockerfile.template | ||
images: | ||
os: "rockylinux:9" | ||
spack: develop | ||
# labels for final image | ||
labels: | ||
maintainer: "Seth Underwood <[email protected]>" | ||
copyright: "2021, 2022, 2023 GFDL" | ||
license: "LGPL v3+" | ||
gov.noaa.gfdl.version: "5.0.0" | ||
vendor: "Geophysical Fluid Dynamics Laboratory" | ||
gov.noaa.gfdl.release-date: "2024-01-10" | ||
# TODO should strip binaries for size if possible | ||
# currently causes linker issues with libgcc when true | ||
strip: false | ||
# Additional packages that are needed at (ci) runtime | ||
# this is anything that doesn't need to be built from source | ||
# pip installs would be added in the template instead | ||
os_packages: | ||
final: | ||
- autoconf | ||
- libtool | ||
- make | ||
- bats | ||
- git | ||
- libgomp | ||
- python3 | ||
- python3-numpy | ||
- python3-pip | ||
- python3-pytest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#*********************************************************************** | ||
# GNU Lesser General Public License | ||
# | ||
# This file is part of the GFDL FRE NetCDF tools package (FRE-NCTools). | ||
# | ||
# FRE-NCTools is free software: you can redistribute it and/or modify it under | ||
# the terms of the GNU Lesser General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or (at | ||
# your option) any later version. | ||
# | ||
# FRE-NCTools is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
# for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with FRE-NCTools. If not, see | ||
# <http://www.gnu.org/licenses/>. | ||
#*********************************************************************** | ||
{% extends "container/Dockerfile" %} | ||
{% block build_stage %} | ||
{{ super() }} | ||
{% endblock %} | ||
{% block final_stage %} | ||
{{ super() }} | ||
# Install any needed pip packages | ||
RUN pip install git+https://github.com/adcroft/numpypi.git && \ | ||
pip install netCDF4 virtualenv | ||
# Set compilers for mpich wrappers | ||
ENV MPICH_FC=gfortran | ||
ENV MPICH_CC=gcc | ||
{% endblock %} |