-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathDockerfile
More file actions
62 lines (55 loc) · 3.74 KB
/
Copy pathDockerfile
File metadata and controls
62 lines (55 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# Galacticus Docker image
# Uses Docker multi-stage build to build Galacticus.
ARG TAG=latest
FROM ghcr.io/galacticusorg/buildenv:${TAG} AS build
ARG REPO=galacticusorg/galacticus
ARG BRANCH=master
## COMMIT pins the build to an exact commit. CI sets this so that the image is built from the same
## commit as every other job in the run - without it we clone whatever the tip of ${BRANCH} happens
## to be at build time, which can differ from the commit the workflow was triggered on. Left empty
## for manual builds, which just take the tip of ${BRANCH}. Must be a full 40-character SHA - the
## server will not resolve an abbreviated one.
ARG COMMIT=
# Set build options.
## * The flags are also set in galacticus/buildenv:latest so we don't really need to reset them here.
## * We force use of the BFD linker here. The GCC in galacticus/buildenv:latest uses the gold linker by default. But, the gold
## linker seems to not correctly allow us to get values of some GSL constants (e.g. gsl_root_fsolver_brent) in Fortran.
ENV GALACTICUS_FCFLAGS="-fintrinsic-modules-path $INSTALL_PATH/finclude -fintrinsic-modules-path $INSTALL_PATH/include -fintrinsic-modules-path $INSTALL_PATH/include/gfortran -fintrinsic-modules-path $INSTALL_PATH/lib/gfortran/modules -L$INSTALL_PATH/lib -L$INSTALL_PATH/lib64 -fuse-ld=bfd"
ENV GALACTICUS_CFLAGS="-fuse-ld=bfd"
ENV GALACTICUS_CPPFLAGS="-fuse-ld=bfd"
ENV GALACTICUS_EXEC_PATH=/opt/galacticus
ENV GALACTICUS_DATA_PATH=/opt/datasets
RUN pwd && ls
# Clone datasets.
## REPO, BRANCH and COMMIT are passed through the environment rather than substituted directly into the `RUN` command below. On a
## pull request build the CI workflow sets them from the head repository name, branch name, and commit of the pull request, all of
## which are chosen by whoever opened it. A `RUN` instruction is executed by a shell, and Docker expands `${...}` into the command
## text before that shell parses it, so substituting them directly would let a branch name containing shell metacharacters run
## arbitrary commands during the image build. Expanding them from the environment instead passes their values through as data.
ENV CLONE_REPO=${REPO} \
CLONE_BRANCH=${BRANCH} \
CLONE_COMMIT=${COMMIT}
RUN cd /opt &&\
git clone --depth 1 -b "${CLONE_BRANCH}" "https://github.com/${CLONE_REPO}.git" galacticus &&\
if [ -n "${CLONE_COMMIT}" ]; then\
cd /opt/galacticus &&\
git fetch --depth 1 origin "${CLONE_COMMIT}" &&\
git checkout --detach FETCH_HEAD ;\
fi &&\
cd /opt &&\
git clone --depth 1 https://github.com/galacticusorg/datasets.git datasets
# Build Galacticus. Cap at -j2 to bound peak memory: at -j4 the concurrent -O3 compiles of the large
# generated `_class` units peak ~10 GB and OOM the ~16 GB runner (matches the -j2 backoff applied to the
# Linux executable jobs in .github/workflows/cicd.yml).
RUN cd /opt/galacticus &&\
make -j2 Galacticus.exe &&\
rm -rf work/build
# Build external tools.
RUN cd /opt/galacticus &&\
classVersion=`awk '{if ($1 == "class:") print $2}' ${GALACTICUS_EXEC_PATH}/aux/dependencies.yml` &&\
cambVersion=`awk '{if ($1 == "camb:") print $2}' ${GALACTICUS_EXEC_PATH}/aux/dependencies.yml` &&\
forutilsVersion=`awk '{if ($1 == "forutils:") print $2}' ${GALACTICUS_EXEC_PATH}/aux/dependencies.yml` &&\
fspsVersion=`awk '{if ($1 == "fsps:") print $2}' ${GALACTICUS_EXEC_PATH}/aux/dependencies.yml` &&\
cloudyVersion=`awk '{if ($1 == "cloudy:") print $2}' ${GALACTICUS_EXEC_PATH}/aux/dependencies.yml` &&\
./Galacticus.exe parameters/buildTools.xml &&\
rm /opt/datasets/dynamic/c${cloudyVersion}.tar.gz /opt/datasets/dynamic/CAMB_${cambVersion}.tar.gz /opt/datasets/dynamic/class_public-${classVersion}.tar.gz /opt/datasets/dynamic/FSPS_${fspsVersion}.tar.gz