-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Running AtChem2 in a docker container (#518)
* add container files * update to run with singularity * tidy Docker files and update README * change mechanism location to full path * user now provides folder containing mechanism at runtime, rather than this being hardcoded to `mcm` * Add copyright notices to new files * Add comments to scripts and update some directory names * Remove hardcoding of version in Dockerfile, it will now build from whichever branch it is run in. * update CI checkout v3 -> v4; remove testing on macos 11 * Make entrypoint path absolute for apptainer compatibility * Stop outputs nesting if model is rerun - now rerunning a model overwrites existing outputs as expected
- Loading branch information
1 parent
c4ed6af
commit 0943743
Showing
5 changed files
with
192 additions
and
5 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
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,30 @@ | ||
# ----------------------------------------------------------------------------- | ||
# | ||
# Copyright (c) 2009 - 2012 Chris Martin, Kasia Boronska, Jenny Young, | ||
# Peter Jimack, Mike Pilling | ||
# | ||
# Copyright (c) 2017 Sam Cox, Roberto Sommariva | ||
# | ||
# Copyright (c) 2024 Will Drysdale, Beth Nelson | ||
# | ||
# This file is part of the AtChem2 software package. | ||
# | ||
# This file is covered by the MIT license which can be found in the file | ||
# LICENSE.md at the top level of the AtChem2 distribution. | ||
# | ||
# ----------------------------------------------------------------------------- | ||
|
||
# get base image | ||
FROM rockylinux:8.9 | ||
|
||
# copy the repo into the container | ||
COPY . /atchem/ | ||
|
||
# run install script | ||
RUN /atchem/docker/install.sh | ||
|
||
# add lable for github container registry | ||
LABEL org.opencontainers.image.source=https://github.com/wacl-york/AtChem2 | ||
|
||
# set entrypoint as the script that runs on `docker run` | ||
ENTRYPOINT [ "/atchem/docker/entrypoint.sh" ] |
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,56 @@ | ||
#!/usr/bin/bash | ||
# ----------------------------------------------------------------------------- | ||
# | ||
# Copyright (c) 2009 - 2012 Chris Martin, Kasia Boronska, Jenny Young, | ||
# Peter Jimack, Mike Pilling | ||
# | ||
# Copyright (c) 2017 Sam Cox, Roberto Sommariva | ||
# | ||
# Copyright (c) 2024 Will Drysdale, Beth Nelson | ||
# | ||
# This file is part of the AtChem2 software package. | ||
# | ||
# This file is covered by the MIT license which can be found in the file | ||
# LICENSE.md at the top level of the AtChem2 distribution. | ||
# | ||
# ----------------------------------------------------------------------------- | ||
|
||
# ----------------------------------------------------------------------------- | ||
# This script is run everytime the container is run. | ||
# | ||
# First it copies the /atchem/ directory that is created during the build to | ||
# the home directory of the user running the container. This is for | ||
# compatibility with singularity, where the user running the container is not | ||
# root, and therefore cannot modify the model files in place. | ||
# | ||
# Next it moves the user configuration from /data_transfer/ and copies it into | ||
# the ~/atchem/ directory. This /data_transfer/ directory is created when the | ||
# the user mounts a volume when running the container (e.g `docker run -v...`) | ||
# | ||
# We then move to the ~/atchem directory and build the model using the mechanism | ||
# specified by the user as a runtime argument to `docker run`. | ||
# | ||
# Then the model is run by executing the newly built atchem2 file. | ||
# | ||
# On completion the atchem model output directory is copied to the data_transfer | ||
# directory and as such onto the host filesystem | ||
# ----------------------------------------------------------------------------- | ||
|
||
# make a copy to home to allow for compatibility with singularity | ||
\command cp -rf /atchem/ ~/ | ||
|
||
# Transfer in user config | ||
\command cp -rf /data_transfer/* ~/atchem/ | ||
|
||
# move into atchem dir | ||
cd ~/atchem/ | ||
|
||
# build model using user specified mechanism | ||
./build/build_atchem2.sh $1 | ||
echo $1 | ||
|
||
# run model | ||
./atchem2 | ||
|
||
# copy outputs to data_transfer / host filesystem | ||
\command cp -rf ~/atchem/model/output /data_transfer/model/ |
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,55 @@ | ||
#!/bin/bash | ||
# ----------------------------------------------------------------------------- | ||
# | ||
# Copyright (c) 2009 - 2012 Chris Martin, Kasia Boronska, Jenny Young, | ||
# Peter Jimack, Mike Pilling | ||
# | ||
# Copyright (c) 2017 Sam Cox, Roberto Sommariva | ||
# | ||
# Copyright (c) 2024 Will Drysdale, Beth Nelson | ||
# | ||
# This file is part of the AtChem2 software package. | ||
# | ||
# This file is covered by the MIT license which can be found in the file | ||
# LICENSE.md at the top level of the AtChem2 distribution. | ||
# | ||
# ----------------------------------------------------------------------------- | ||
|
||
# ----------------------------------------------------------------------------- | ||
# This is the install script that is run when the container is built. It | ||
# installs the necessary dependacies for installing AtChem2 (gcc-gfortran, | ||
# wget, cmake and python3.11). | ||
# | ||
# It then runs the install scripts provided with the model (install_cvode.sh | ||
# and install_openlibm.sh) to install additional dependancies required to build | ||
# the model. | ||
# | ||
# Next it produces the Makefile from the skeleton, and amends the dependancy | ||
# paths. | ||
# | ||
# Finally it does some housekeeping, updating the build_atchem2.sh to be able | ||
# to find the python installation, and makes the docker entrypoint script | ||
# executable. | ||
# ----------------------------------------------------------------------------- | ||
|
||
# Install dependancies from package repository | ||
dnf install -y which gcc-gfortran wget cmake python3.11 | ||
|
||
# make directories | ||
mkdir /atchem-lib | ||
# mkdir /atchem | ||
|
||
# move to /atchem so the dependacy installation scripts work correctly. | ||
cd atchem | ||
|
||
# Install dependancies to /atchem-lib | ||
./tools/install/install_cvode.sh /atchem-lib/ | ||
./tools/install/install_openlibm.sh /atchem-lib/ | ||
|
||
# Change atchem dependancy paths and create Makefile from skeleton | ||
sed 's,cvode/lib,/atchem-lib/cvode/lib,g' tools/install/Makefile.skel > ./Makefile | ||
sed -i 's,openlibm-0.8.1,/atchem-lib/openlibm-0.8.1,g' ./Makefile | ||
|
||
# Fix python command to match installed version | ||
sed -i "s/python/python3/g" ./build/build_atchem2.sh | ||
chmod +x docker/entrypoint.sh |