Skip to content

Commit

Permalink
add dockerfile, model_info.json to template (fixes #2567)
Browse files Browse the repository at this point in the history
  • Loading branch information
robkooper committed Apr 30, 2020
1 parent 482e514 commit 447e245
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ For more information about this file see also [Keep a Changelog](http://keepacha
- PEcAn.JULES: Removed dependency on `ncdf4.helpers` package, which has been removed from CRAN (#2511).

### Added
- model_info.json and Dockerfile to template (#2567)
- Dockerize BASGRA_N model.
- Basic coupling for models BASGRA_N and STICS.
- PEcAn.priors now exports functions `priorfig` and `plot_densities` (#2439).
Expand Down
69 changes: 69 additions & 0 deletions models/template/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
########################################################################
# First we build the actual model, this has everything that is needed
# for the model to compile. Next we create the final image that has the
# PEcAn code as well as only the model binary.
########################################################################

# this needs to be at the top, what version are we building
ARG IMAGE_VERSION="latest"

# ----------------------------------------------------------------------
# BUILD MODEL BINARY
# ----------------------------------------------------------------------
FROM debian:stretch as model-binary

# Some variables that can be used to set control the docker build
ARG MODEL_VERSION=git

# install dependencies
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
curl \
gfortran \
git \
libhdf5-dev \
libopenmpi-dev \
&& rm -rf /var/lib/apt/lists/*

# download, unzip and build ed2
WORKDIR /src
RUN git clone https://github.com/model/repo.git \
&& cd repo \
&& if [ "${MODEL_VERSION}" != "git" ]; then git checkout "v.${MODEL_VERSION}"; fi \
&& ./configure \
&& make

########################################################################

# ----------------------------------------------------------------------
# BUILD PECAN FOR MODEL
# ----------------------------------------------------------------------
FROM pecan/models:${IMAGE_VERSION}

# ----------------------------------------------------------------------
# INSTALL MODEL SPECIFIC PIECES
# ----------------------------------------------------------------------

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libgfortran3 \
libopenmpi2 \
&& rm -rf /var/lib/apt/lists/*

# ----------------------------------------------------------------------
# SETUP FOR SPECIFIC MODEL
# ----------------------------------------------------------------------

# Some variables that can be used to set control the docker build
ARG MODEL_VERSION=git

# Setup model_info file
# @VERSION@ is replaced with model version in the model_info.json file
# @BINARY@ is replaced with model binary in the model_info.json file
COPY model_info.json /work/model.json
RUN sed -i -e "s/@VERSION@/${MODEL_VERSION}/g" \
-e "s#@BINARY@#/usr/local/bin/model#g" /work/model.json

# COPY model binary
COPY --from=model-binary /src/repo/src/model /usr/local/bin/model
36 changes: 36 additions & 0 deletions models/template/model_info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "Name of model, displayed in UI",
"type": "Type of model",
"version": "@VERSION@",
"binary": "@BINARY@",
"description": "Longer description of the model, right now only displayed in the monitor",
"creator": "Main creator of model",
"contributors": ["List of contributors", "Both for model", "And PEcAn code for model"],
"links": [
{
"type": "git",
"description": "Link to source code, if not exist, just remove",
"url": "https://github.com/...."
},
{
"type": "issues",
"description": "Link to issues, if not exist, just remove",
"url": "https://github.com/..../issues"
},
{
"type": "documentation",
"description": "Link to documentation, if not exist, just remove",
"url": "https://github.com/..../wiki"
},
{
"type": "docker",
"description": "Link to docker image, if not exist, just remove",
"url": "organization/image"
}
],
"inputs": {},
"bibtex": [
"How to cite the model, paper 1",
"How to cite the model, paper 2"
]
}

0 comments on commit 447e245

Please sign in to comment.