-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
123 lines (102 loc) · 3.88 KB
/
Copy pathDockerfile
File metadata and controls
123 lines (102 loc) · 3.88 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
117
118
119
120
121
122
123
#
# Build an Ubuntu installation of gmsvtoolkit
#
FROM ubuntu:jammy
LABEL org.opencontainers.image.authors="fsilva@usc.edu"
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=America/Los_Angeles
RUN apt-get update && apt-get -y upgrade \
&& apt-get install -y --no-install-recommends \
git \
wget \
vim \
jupyter \
build-essential \
ca-certificates \
libfftw3-dev \
libfftw3-mpi-dev \
libopenmpi-dev \
gfortran \
&& rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/bin/python3 /usr/bin/python
# Define Build and runtime arguments
# These accept userid and groupid from the command line
#ARG APP_UNAME
#ARG APP_GRPNAME
#ARG APP_UID
#ARG APP_GID
#ARG BDATE
ENV APP_UNAME=scecuser \
APP_GRPNAME=scec \
APP_UID=1000 \
APP_GID=20 \
BDATE=20260714 \
CONDA_PLUGINS_AUTO_ACCEPT_TOS=true
# Added explicit HOME environment variable
ENV HOME=/home/${APP_UNAME}
ENV USER=${APP_UNAME}
ENV NB_UID=${APP_UID}
# Retrieve the userid and groupid from the args so
# Define these parameters to support building and deploying on EC2 so user is not root
# and for building the model and adding the correct date into the label
RUN echo $APP_UNAME $APP_GRPNAME $APP_UID $APP_GID $BDATE
# Setup Owners
# Group add duplicates "staff" so just continue if it doesn't work
RUN groupadd -f --non-unique --gid $APP_GID $APP_GRPNAME
RUN useradd -ms /bin/bash -g $APP_GRPNAME --uid $APP_UID $APP_UNAME
# Added steps to manage home directory permissions
RUN mkdir -p $HOME/.local \
&& chown -R $APP_UID:$APP_GID $HOME \
&& chmod -R 755 $HOME
# Define interactive user
USER ${APP_UNAME}
# Move to the user directory where the gmsvtoolkit is installed and built
ENV PATH="/home/${APP_UNAME}/miniconda3/bin:${PATH}"
ARG PATH="/home/${APP_UNAME}/miniconda3/bin:${PATH}"
WORKDIR /home/${APP_UNAME}
RUN ARCH=$(uname -m) \
&& if [ "$ARCH" = "x86_64" ]; then \
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh; \
elif [ "$ARCH" = "aarch64" ]; then \
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh -O /tmp/miniconda.sh; \
else \
echo "Unsupported architecture: $ARCH" && exit 1; \
fi \
&& mkdir -p /home/${APP_UNAME}/.conda \
&& bash /tmp/miniconda.sh -b \
&& rm -f /tmp/miniconda.sh \
&& echo "Running $(conda --version)" \
&& conda update conda \
&& conda create -n gmsvtoolkit_env \
&& conda init bash
RUN echo 'conda activate gmsvtoolkit_env' >> /home/${APP_UNAME}/.bashrc \
&& bash /home/${APP_UNAME}/.bashrc \
&& conda install python=3.10 pip numpy notebook jupyterlab numba matplotlib pyproj scipy
# Get a copy of the gmsvtoolkit_tutorials repo
WORKDIR /home/${APP_UNAME}
RUN git clone https://github.com/SCECcode/gmsvtoolkit_tutorials.git
# Move to the user directory where the gmsvtoolkit is installed and built
WORKDIR /home/${APP_UNAME}
RUN git clone https://github.com/SCECcode/gmsvtoolkit.git
WORKDIR /home/${APP_UNAME}/gmsvtoolkit/gmsvtoolkit/src
RUN make -f makefile
# Setup GMSVtoolkit path
ENV PYTHONPATH="$PYTHONPATH:/home/${APP_UNAME}/gmsvtoolkit/gmsvtoolkit"
ENV PATH="$PATH:/home/$APP_UNAME/gmsvtoolkit/gmsvtoolkit/src/gp/bin:/home/$APP_UNAME/gmsvtoolkit/gmsvtoolkit/src/ucb/bin:/home/${APP_UNAME}/gmsvtoolkit/gmsvtoolkit/src/usgs/bin"
ENV GMSVTOOLKIT_DIR="/home/${APP_UNAME}/gmsvtoolkit/gmsvtoolkit"
# Define file input/output mounted disk
#
VOLUME /home/${APP_UNAME}/target
WORKDIR /home/${APP_UNAME}/target
#
# The .bashrc and .bash_profile will Define ENV variables
#
#
# Add metadata to dockerfile using labels
LABEL "org.scec.project"="GMSVToolkit"
LABEL org.scec.responsible_person="Fabio Silva"
LABEL org.scec.primary_contact="fsilva@usc.edu"
LABEL version="${BDATE}"
# Create interactive entry point
ENTRYPOINT ["/usr/bin/jupyter","notebook","--ip=0.0.0.0","--notebook-dir=/home/scecuser/gmsvtoolkit_tutorials/notebooks","--allow-root","--no-browser"]
#CMD ["/bin/bash"]