Skip to content

Commit

Permalink
from o=moho
Browse files Browse the repository at this point in the history
  • Loading branch information
meihuisu committed Jan 19, 2025
1 parent 0c7ff37 commit e8cb5c9
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 34 deletions.
59 changes: 29 additions & 30 deletions ucvm_v22_7_quakeworx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,32 @@ RUN ln -s /usr/bin/python3 /usr/bin/python
# To support the python2 plotting library, we will install Anaconda with a python2
# virtual environment in this image
WORKDIR /home/$APP_UNAME/app
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O anaconda.sh && \
mkdir /home/$APP_UNAME/.conda && \
/bin/bash anaconda.sh -b -p /usr/local/opt/conda && \
rm -f anaconda.sh && \
echo "Running $(conda --version)" && \
/usr/local/opt/conda/bin/conda update conda && \
/usr/local/opt/conda/bin/conda init bash

#RUN wget --quiet https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh -O anaconda.sh && \
#RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O anaconda.sh && \
# mkdir /home/$APP_UNAME/.conda && \
# /bin/bash anaconda.sh -b -p /usr/local/opt/conda && \
# rm anaconda.sh && \
# ln -s /usr/local/opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
# find /usr/local/opt/conda/ -follow -type f -name '*.a' -delete && \
# find /usr/local/opt/conda/ -follow -type f -name '*.js.map' -delete && \
# /usr/local/opt/conda/bin/conda clean -afy && \
# rm -f anaconda.sh && \
# echo "Running $(conda --version)" && \
# /usr/local/opt/conda/bin/conda init bash

RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O anaconda.sh && \
/bin/bash anaconda.sh -b -p /usr/local/opt/conda && \
rm anaconda.sh && \
ln -s /usr/local/opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
find /usr/local/opt/conda/ -follow -type f -name '*.a' -delete && \
find /usr/local/opt/conda/ -follow -type f -name '*.js.map' -delete && \
/usr/local/opt/conda/bin/conda clean -afy && \
/usr/local/opt/conda/bin/conda init bash

RUN echo "source /usr/local/opt/conda/etc/profile.d/conda.sh" >> /home/$APP_UNAME/.bashrc && \
bash /home/$APP_UNAME/.bashrc && \
/usr/local/opt/conda/bin/conda install -y pip bzip2

#RUN /usr/local/opt/conda/bin/conda create -n Python2 -y python=2.7.15 scipy numpy matplotlib basemap basemap-data-hires
RUN /usr/local/opt/conda/bin/conda create -n plotPython -y numpy matplotlib basemap basemap-data-hires

RUN /usr/local/opt/conda/bin/conda create -n plotPython -y pip scipy numpy matplotlib basemap basemap-data-hires
RUN /usr/local/opt/conda/bin/conda install -y jupyterlab


#### building user app part

# Retrieve and build UCVM
WORKDIR /home/$APP_UNAME/app
RUN git clone https://github.com/sceccode/ucvm.git src
Expand All @@ -100,11 +97,18 @@ RUN ./ucvm_setup.py -a -d -p /home/$APP_UNAME/app/ucvm >& ./ucvm_setup_install.l
WORKDIR /home/$APP_UNAME/app
RUN rm -rf src

# Install plotting libraries
WORKDIR /home/$APP_UNAME/app/ucvm
ENV PATH="/usr/local/opt/conda/bin:${PATH}"
ARG PATH="/usr/local/opt/conda/bin:${PATH}"
ENV PYTHONPATH="/home/ucvmuser/.local/lib/python3.12/site-packages/pycvm:${PYTHONPATH}"
ARG PYTHONPATH="/home/ucvmuser/.local/lib/python3.12/site-packages/pycvm:${PYTHONPATH}"

# Install plotting libraries as root
WORKDIR /home/$APP_UNAME/app
RUN git clone https://github.com/SCECcode/ucvm_plotting.git
WORKDIR /home/$APP_UNAME/app/ucvm/ucvm_plotting
##RUN ./unpack-dist
WORKDIR /home/$APP_UNAME/app/ucvm_plotting
RUN ./unpack-dist
## not able to unpack into system spot and so ended up at
## /home/ucvmuser/.local/lib/python3.12/site-packages/pycvm/

# Add metadata to dockerfile using labels
LABEL org.label-schema.build-date=$BDATE
Expand All @@ -119,15 +123,11 @@ RUN echo "source /home/$APP_UNAME/app/ucvm/conf/ucvm_env.sh" >> /home/$APP_UNAME
echo "conda activate plotPython" >> /home/$APP_UNAME/.bashrc

# Added steps to manage home directory permissions
RUN mkdir -p $HOME/.local \
&& chown -R $APP_UID:$APP_GID $HOME \
&& chmod -R 755 $HOME
RUN chown -R $APP_UID:$APP_GID $HOME && \
chmod -R 755 $HOME

USER $APP_UNAME

ENV PATH="/usr/local/opt/conda/bin:${PATH}"
ARG PATH="/usr/local/opt/conda/bin:${PATH}"

WORKDIR /home/$APP_UNAME

# Expose the port JupyterLab will run on
Expand All @@ -137,8 +137,7 @@ EXPOSE 8888
#VOLUME /home/$APP_UNAME/app/target

SHELL ["/bin/bash", "--login", "-c"]

#ENTRYPOINT ["/bin/bash"]
CMD ["/bin/bash" ]
# Define the command to run JupyterLab
ENTRYPOINT ["/usr/local/opt/conda/bin/jupyter", "lab", "--ip=0.0.0.0", "--no-browser", "--allow-root"]
#ENTRYPOINT ["/usr/local/opt/conda/bin/jupyter", "lab", "--ip=0.0.0.0", "--no-browser", "--allow-root"]

8 changes: 5 additions & 3 deletions ucvm_v22_7_quakeworx/build_one_quakeworx.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@
month=dt.month
day=dt.day
mdate="%02d%02d"%(month,day)
tuser="ucvmuser"

models = ["cvmh"]

for m in models:
print ("building model: " + m)
cmd = "docker build --no-cache=false -f Dockerfile . -t ucvm_227_%s_quakeworx:%s " \
"--build-arg APP_UNAME=ucvmuser --build-arg APP_GRPNAME=ucvmuser " \
"--build-arg APP_UID=1000 --build-arg APP_GID=1000 --build-arg MODELID=%s --build-arg BDATE=%s"%(m,mdate,m,mdate)
cmd = "docker build --no-cache -f Dockerfile . -t ucvm_227_%s_quakeworx:%s " \
"--build-arg APP_UNAME=%s --build-arg APP_GRPNAME=%s " \
"--build-arg APP_UID=1000 --build-arg APP_GID=1000 --build-arg MODELID=%s --build-arg BDATE=%s" \
%(m,mdate,tuser,tuser,m,mdate)
os.system(cmd)

cmd = "docker tag ucvm_227_%s_quakeworx:%s sceccode/ucvm_227_%s_quakeworx:%s"%(m,mdate,m,mdate)
Expand Down
2 changes: 1 addition & 1 deletion ucvm_v22_7_quakeworx/r
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#docker pull sceccode/ucvm_227_cvmh_quakeworx:latest
#docker rm $(docker ps -a | grep Exit | cut -d ' ' -f 1)

docker run -p 8888:8888 --rm -it --mount type=bind,source="$(pwd)"/target,destination=/app/target sceccode/ucvm_227_cvmh_quakeworx:0117
docker run -p 8888:8888 --rm -it --mount type=bind,source="$(pwd)"/target,destination=/home/ucvmuser/app/target sceccode/ucvm_227_cvmh_quakeworx:0119
#sceccode/ucvm_227_cvmh_quakeworx:latest

#docker run -p 8888:8888 --rm -it --mount type=bind,source="$(pwd)"/target,destination=/home/ucvmuser/target sceccode/ucvm_227_cvmh:0710
Expand Down

0 comments on commit e8cb5c9

Please sign in to comment.