Skip to content

Commit 792e666

Browse files
committed
Docker setup for SMCE use
1 parent 3174868 commit 792e666

2 files changed

Lines changed: 72 additions & 0 deletions

File tree

Docker/smce/Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Dockerfile to build SMCE OSS environment for running ECCO tutorials.
2+
FROM public.ecr.aws/smce/smce-images:smce-oss-earth-r-julia-48aae375
3+
4+
ENV NB_USER=jovyan
5+
ENV HOME=/home/${NB_USER}
6+
7+
# USER ${NB_USER}
8+
WORKDIR ${HOME}
9+
10+
11+
# retrieve ECCO Python tutorials
12+
RUN git clone https://github.com/ECCO-GROUP/ECCO-v4-Python-Tutorial.git
13+
14+
# install any additional Python packages needed
15+
RUN mamba install -y -n notebook matplotlib ecco_v4_py
16+
17+
# install packages needed to run Julia notebooks
18+
RUN julia -e 'import Pkg; Pkg.add("Pluto"); using Pluto'
19+
RUN julia -e 'import Pkg; Pkg.add("OceanStateEstimation")'
20+
21+
# create symlink from home directory to jupyter_lab_start_docker.sh
22+
RUN ln -s ${HOME}/ECCO-v4-Python-Tutorial/Docker/smce/jupyter_lab_start_smce.sh \
23+
${HOME}/jupyter_lab_start_smce.sh
24+
25+
EXPOSE 8888
26+
27+
# start jupyter lab inside the container
28+
ENTRYPOINT ["./jupyter_lab_start_smce.sh"]
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
3+
# Shell script to start a Jupyter lab session
4+
# in a tmux window (so it persists even if ssh tunnel is disconnected)
5+
6+
red_start='\033[0;31m'
7+
blue_start='\033[0;34m'
8+
nocolor_start='\033[0m'
9+
10+
11+
# Add Earthdata credentials to ~/.netrc if they are not already present
12+
sh ~/ECCO-v4-Python-Tutorial/Docker/earthdata_auth_docker.sh
13+
14+
echo "Starting Jupyter lab session!"
15+
echo ""
16+
17+
read -p 'Which container port do you want to use [default 8888]: ' user_port
18+
user_port=${user_port:-8888}
19+
echo "using port ${user_port}"
20+
echo ""
21+
22+
# Start configuration for Jupyter lab
23+
echo "Enter password to access Jupyter lab from browser,"
24+
echo "or leave blank to not require a password."
25+
26+
PW="$(python3 -c 'from jupyter_server.auth import passwd; import getpass; print(passwd(getpass.getpass(), algorithm="sha256"))')"
27+
28+
29+
# Start Jupyter lab
30+
source /srv/conda/bin/activate
31+
conda activate notebook
32+
jupyter lab --no-browser --autoreload --port=${user_port} --ip='0.0.0.0' --NotebookApp.token='' --NotebookApp.password=\"$PW\" --notebook-dir=\"./ECCO-v4-Python-Tutorial\"
33+
34+
# Print info about session
35+
echo -e "${red_start}Started Jupyter lab in Docker container"
36+
echo -e "${red_start}Access from your local machine in a browser window"
37+
echo -e "${red_start}by tunneling to host machine at the port"
38+
echo -e "${red_start}you are using to connect to the Docker container, e.g., "
39+
echo -e "${blue_start}ssh -i ~/.ssh/ec2_auth.pem -L 8888:localhost:8888 ec2-user@100.104.70.127"
40+
echo -e "${red_start}and opening the URL in your browser"
41+
echo -e "${blue_start}http://127.0.0.1:8888/ ${red_start}or ${blue_start}http://localhost:8888/"
42+
echo -e "${red_start}If you are already running Jupyter on your local machine"
43+
echo -e "${red_start}on port 8888, you need to use a different local port, e.g.,"
44+
echo -e "${blue_start}ssh -i ~/.ssh/ec2_auth.pem -L 9889:localhost:8888 ec2-user@100.104.70.127${nocolor_start}"

0 commit comments

Comments
 (0)