Skip to content

Instantly share code, notes, and snippets.

@gbraccialli
Created October 28, 2020 13:02
Show Gist options
  • Save gbraccialli/abc29c41e04526397d14f9dad06f4757 to your computer and use it in GitHub Desktop.
Save gbraccialli/abc29c41e04526397d14f9dad06f4757 to your computer and use it in GitHub Desktop.
cd /tmp
mkdir /app
rm -f /tmp/Anaconda3-2019.10-Linux-x86_64.sh
wget https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh
chmod 744 ./Anaconda3-2019.10-Linux-x86_64.sh
/tmp/Anaconda3-2019.10-Linux-x86_64.sh -b -p /app/anaconda3/
rm -f /tmp/Anaconda3-2019.10-Linux-x86_64.sh
/app/anaconda3/bin/conda install -y -c conda-forge jupyterhub
/app/anaconda3/bin/pip install jupyter-server-proxy
/app/anaconda3/bin/pip install ipykernel
/app/anaconda3/bin/jupyter serverextension enable --sys-prefix jupyter_server_proxy
/app/anaconda3/bin/conda init
/app/anaconda3/bin/conda create -y -n xxx python=3.6
sh -c 'source /app/anaconda3/bin/activate xxx;pip install ipykernel;python -m ipykernel install --name xxx --display-name "xxx"'
aws configure set s3.signature_version s3v4
aws s3 cp s3://xxx/requirements.txt /tmp/requirements.txt
sh -c 'source /app/anaconda3/bin/activate xxx;pip install -r /tmp/requirements.txt'
chmod 777 -R /app/anaconda3
#userdel -r jupyter
#rm -rf /home/jupyter
adduser jupyter
su - jupyter -c 'mkdir /home/jupyter/notebooks'
su - jupyter -c 'mkdir /home/jupyter/.jupyter'
su - jupyter -c 'cat << EOF > /home/jupyter/.jupyter/jupyter_notebook_config.json
{
"NotebookApp": {
"password": "XXXXXXX-ENCRYPTED-PASSWORD"
}
}
EOF'
#must have aws credentials configured for your user to configure them for jupyter user
su - jupyter -c 'mkdir /home/jupyter/.aws'
cp ~/.aws/credentials /home/jupyter/.aws/credentials
chown jupyter /home/jupyter/.aws/credentials
su - jupyter -c '/app/anaconda3/bin/conda init'
su - jupyter -c 'cat > /home/jupyter/start_jupyter.sh <<EOF
cd /home/jupyter/notebooks
nohup jupyter notebook --port 8000 --ip 0.0.0.0 --no-browser > /tmp/jupyter.log 2>&1 &
jupyter notebook list
EOF'
chmod 744 /home/jupyter/start_jupyter.sh
su - jupyter -c '/home/jupyter/start_jupyter.sh'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment