-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.rte
More file actions
116 lines (91 loc) · 4.89 KB
/
Dockerfile.rte
File metadata and controls
116 lines (91 loc) · 4.89 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
ARG NGEN_BASE_IMAGE="ghcr.io/ngwpc/ngen:latest"
FROM $NGEN_BASE_IMAGE AS ngen_rte_base
# OCI Metadata Arguments
ARG TARGET_IMAGE_DESCRIPTION="Docker image for the National Water Model Runtime Environment (NWM RTE)."
ARG TARGET_IMAGE_SOURCE="unknown"
ARG TARGET_IMAGE_VENDOR="unknown"
ARG TARGET_IMAGE_VERSION="unknown"
ARG TARGET_IMAGE_REVISION="unknown"
ARG TARGET_IMAGE_CREATED="unknown"
# OCI Standard Labels
LABEL org.opencontainers.image.description=$TARGET_IMAGE_DESCRIPTION \
org.opencontainers.image.source=$TARGET_IMAGE_SOURCE \
org.opencontainers.image.vendor=$TARGET_IMAGE_VENDOR \
org.opencontainers.image.version=$TARGET_IMAGE_VERSION \
org.opencontainers.image.revision=$TARGET_IMAGE_REVISION \
org.opencontainers.image.created=$TARGET_IMAGE_CREATED
# ENV FORCING_LOGLEVEL=DEBUG
### Static args
ARG PYTHON_ENV="/ngen-app/ngen-python/bin"
ARG PYTHON_VERSION_STR="python3.11"
ENV PIP_NO_CACHE_DIR=1
ENV OMPI_ALLOW_RUN_AS_ROOT=1
ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
COPY nwm-rte/add_git_info.py .
### Create directory for git info JSON files
RUN mkdir -p /ngen-app/git-info
### Activate the venv
ENV PATH="${PYTHON_ENV}:${PATH}"
RUN python -m pip install --upgrade pip
### Install debuggers if specified
ARG INSTALL_DEBUGGERS
RUN --mount=type=bind,src=nwm-rte/install_debuggers.sh,dst=/src_ngwpc/nwm-rte/install_debuggers.sh \
"/src_ngwpc/nwm-rte/install_debuggers.sh" "${INSTALL_DEBUGGERS}"
### Install nwm packages
ARG REPO_TAG_FCST_MGR
RUN --mount=type=bind,src=nwm-rte/install_package.sh,dst=/src_ngwpc/nwm-rte/install_package.sh \
--mount=type=bind,src=nwm-fcst-mgr,dst=/src_ngwpc/nwm-fcst-mgr \
"/src_ngwpc/nwm-rte/install_package.sh" "python" "nwm-fcst-mgr" "${REPO_TAG_FCST_MGR}" ""
ARG REPO_TAG_MSW_MGR
RUN --mount=type=bind,src=nwm-rte/install_package.sh,dst=/src_ngwpc/nwm-rte/install_package.sh \
--mount=type=bind,src=nwm-msw-mgr,dst=/src_ngwpc/nwm-msw-mgr \
"/src_ngwpc/nwm-rte/install_package.sh" "python" "nwm-msw-mgr" "${REPO_TAG_MSW_MGR}" ""
ARG REPO_TAG_CAL_MGR
RUN --mount=type=bind,src=nwm-rte/install_package.sh,dst=/src_ngwpc/nwm-rte/install_package.sh \
--mount=type=bind,src=nwm-cal-mgr,dst=/src_ngwpc/nwm-cal-mgr \
"/src_ngwpc/nwm-rte/install_package.sh" "python" "nwm-cal-mgr" "${REPO_TAG_CAL_MGR}" ""
ARG REPO_TAG_REGION_MGR
RUN --mount=type=bind,src=nwm-rte/install_package.sh,dst=/src_ngwpc/nwm-rte/install_package.sh \
--mount=type=bind,src=nwm-region-mgr,dst=/src_ngwpc/nwm-region-mgr \
"/src_ngwpc/nwm-rte/install_package.sh" "python" "nwm-region-mgr" "${REPO_TAG_REGION_MGR}" "[parreg]"
ARG REPO_TAG_DATA_ASSIM_ENGINE
RUN --mount=type=bind,src=nwm-rte/install_package.sh,dst=/src_ngwpc/nwm-rte/install_package.sh \
--mount=type=bind,src=nwm-data-assimilation,dst=/src_ngwpc/nwm-data-assimilation \
"/src_ngwpc/nwm-rte/install_package.sh" "python" "nwm-data-assimilation" "${REPO_TAG_DATA_ASSIM_ENGINE}" ""
## ngen-forcing package is included with the starting base image,
## but it can be reinstalled from another branch or from local.
## See README.md for caveats.
ARG REPO_TAG_NGEN_FORCING
RUN --mount=type=bind,src=nwm-rte/install_package.sh,dst=/src_ngwpc/nwm-rte/install_package.sh \
--mount=type=bind,src=ngen-forcing,dst=/src_ngwpc/ngen-forcing \
"/src_ngwpc/nwm-rte/install_package.sh" "python" "ngen-forcing" "${REPO_TAG_NGEN_FORCING}" ""
##################################################
#### BEGIN SECOND STAGE: Adding a separate Python venv for nwm.eval and nwm.verf
FROM ngen_rte_base AS ngen_rte_eval_verf
# Call modules like `python_eval_verf -m nwm.verf`
ARG EVAL_VERF_PYTHON_ALIAS="python_eval_verf"
ARG EVAL_VERF_VENV="/ngen-app/venvs/eval_verf"
ARG EVAL_VERF_PYTHON_BIN_DIR="${EVAL_VERF_VENV}/bin"
ARG EVAL_VERF_PYTHON_BIN_FILE="${EVAL_VERF_PYTHON_BIN_DIR}/python"
# Make the venv
RUN python -m venv "${EVAL_VERF_VENV}"
# Add an alias for convenience
RUN echo "alias ${EVAL_VERF_PYTHON_ALIAS}=\"${EVAL_VERF_PYTHON_BIN_FILE}\"" >> ~/.bashrc
# Save the current PATH and PYTHONPATH
ENV PATH_SAVED=${PATH}
ENV PYTHONPATH_SAVED=${PYTHONPATH}
# Adjust PATH and PYTHONPATH to give this environment precedent
ENV PATH="${EVAL_VERF_PYTHON_BIN_DIR}:${PATH}"
ENV PYTHONPATH="${EVAL_VERF_PYTHON_BIN_DIR}/lib/python3.11/site-packages"
ARG REPO_TAG_VERF
RUN --mount=type=bind,src=nwm-rte/install_package.sh,dst=/src_ngwpc/nwm-rte/install_package.sh \
--mount=type=bind,src=nwm-verf,dst=/src_ngwpc/nwm-verf \
"/src_ngwpc/nwm-rte/install_package.sh" "/ngen-app/venvs/eval_verf/bin/python" "nwm-verf" "${REPO_TAG_VERF}" ""
ARG REPO_TAG_EVAL
RUN --mount=type=bind,src=nwm-rte/install_package.sh,dst=/src_ngwpc/nwm-rte/install_package.sh \
--mount=type=bind,src=nwm-eval-mgr,dst=/src_ngwpc/nwm-eval-mgr \
"/src_ngwpc/nwm-rte/install_package.sh" "/ngen-app/venvs/eval_verf/bin/python" "nwm-eval-mgr" "${REPO_TAG_EVAL}" ""
##############################
#### Clean up: reset PATH and PYTHONPATH
ENV PATH=${PATH_SAVED}
ENV PYTHONPATH=${PYTHONPATH_SAVED}