Last active
August 29, 2015 14:20
-
-
Save krasnobaev/d413691caefe295f8eba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NAME iPython @ python2 | |
FROM ubuntu:15.04 | |
MAINTAINER Aleksey Krasnobaev <https://github.com/krasnobaev> | |
RUN apt-get update; \ | |
DEBIAN_FRONTEND=noninteractive apt-get install -y ipython-notebook pwgen; | |
#mailutils | |
RUN useradd --create-home --shell /bin/bash ipythoner | |
USER ipythoner | |
WORKDIR /home/ipythoner | |
# run public ipython | |
RUN openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem -subj "/C=NL/ST=Z/L=R/O=SN/OU=IT/CN=local.org" | |
RUN ipython profile create nbserver;\ | |
PASSWORD=`pwgen -B -s 24 1`;\ | |
echo $PASSWORD;\ | |
# echo $PASSWORD | mail -sipythonpassword [email protected];\ | |
SHA1PASS=`python -c "from IPython.lib import passwd; print(passwd('$PASSWORD'))"`;\ | |
CONFIG='/home/ipythoner/.ipython/profile_nbserver/ipython_notebook_config.py';\ | |
sed -i "s/# c.NotebookApp.certfile = u''/c.NotebookApp.certfile = u'\/root\/mycert.pem'/g" $CONFIG;\ | |
sed -i "s/# c.NotebookApp.ip = '127.0.0.1'/c.NotebookApp.ip = '*'/g" $CONFIG;\ | |
sed -i "s/# c.NotebookApp.ip = 'localhost'/c.NotebookApp.ip = '*'/g" $CONFIG;\ | |
sed -i 's/# c.NotebookApp.open_browser = True/c.NotebookApp.open_browser = False/g' $CONFIG;\ | |
sed -i "s/# c.NotebookApp.password = u''/c.NotebookApp.password = u'$SHA1PASS'/g" $CONFIG; | |
ENTRYPOINT ipython notebook --profile=nbserver --certfile=mycert.pem | |
EXPOSE 8888 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NAME iPython @ python3.2 | |
FROM ubuntu:15.04 | |
MAINTAINER Aleksey Krasnobaev <https://github.com/krasnobaev> | |
RUN apt-get update; \ | |
DEBIAN_FRONTEND=noninteractive apt-get install -y git python3 python3-pip pwgen; \ | |
#mailutils | |
# pyenv build requirements https://github.com/yyuu/pyenv/wiki/Common-build-problems | |
DEBIAN_FRONTEND=noninteractive apt-get install -y make build-essential libssl-dev \ | |
zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm; | |
# create user | |
RUN useradd --create-home --shell /bin/bash ipythoner | |
USER ipythoner | |
WORKDIR /home/ipythoner | |
# setup pyenv | |
# https://github.com/yyuu/pyenv | |
RUN git clone https://github.com/yyuu/pyenv.git ~/.pyenv;\ | |
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc;\ | |
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc;\ | |
echo 'eval "$(pyenv init -)"' >> ~/.bashrc;\ | |
exec /bin/bash -l; | |
ENV PYENV_ROOT /home/ipythoner/.pyenv | |
ENV PATH $PYENV_ROOT/bin:$PATH | |
# setup python 3.2 | |
RUN pyenv install 3.2; | |
RUN pyenv global 3.2; | |
RUN pyenv rehash; | |
RUN pip3 install ipython<2; | |
# run public ipython server | |
# http://ipython.org/ipython-doc/1/interactive/public_server.html | |
RUN openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem -subj "/C=NL/ST=Z/L=R/O=SN/OU=IT/CN=local.org" | |
RUN ipython3 profile create nbserver;\ | |
PASSWORD=`pwgen -B -s 24 1`;\ | |
echo $PASSWORD;\ | |
# echo $PASSWORD | mail -sipythonpassword [email protected];\ | |
SHA1PASS=`python3 -c "from IPython.lib import passwd; print(passwd('$PASSWORD'))"`;\ | |
CONFIG='/home/ipythoner/.ipython/profile_nbserver/ipython_notebook_config.py';\ | |
sed -i "s/# c.NotebookApp.certfile = u''/c.NotebookApp.certfile = u'\/root\/mycert.pem'/g" $CONFIG;\ | |
sed -i "s/# c.NotebookApp.certfile = ''/c.NotebookApp.certfile = '\/root\/mycert.pem'/g" $CONFIG;\ | |
sed -i "s/# c.NotebookApp.ip = '127.0.0.1'/c.NotebookApp.ip = '*'/g" $CONFIG;\ | |
sed -i "s/# c.NotebookApp.ip = 'localhost'/c.NotebookApp.ip = '*'/g" $CONFIG;\ | |
sed -i 's/# c.NotebookApp.open_browser = True/c.NotebookApp.open_browser = False/g' $CONFIG;\ | |
sed -i "s/# c.NotebookApp.password = u''/c.NotebookApp.password = u'$SHA1PASS'/g" $CONFIG; | |
sed -i "s/# c.NotebookApp.password = ''/c.NotebookApp.password = '$SHA1PASS'/g" $CONFIG; | |
ENTRYPOINT ipython3 notebook --profile=nbserver --certfile=mycert.pem | |
EXPOSE 8888 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USERNAME=stub | |
apt-get -y update | |
apt-get -y upgrade | |
apt-get -y dist-upgrade | |
DEBIAN_FRONTEND=noninteractive apt-get -y install git docker.io mailutils pwgen | |
apt-get -y autoremove | |
apt-get -y autoclean | |
useradd --shell /bin/bash --user-group --create-home $USERNAME | |
mkdir -p /home/stub/.ssh | |
ssh-import-id -o /home/$USERNAME/.ssh/authorized_keys gh:krasnobaev | |
chown -R $USERNAME:$USERNAME /home/$USERNAME/.ssh | |
adduser $USERNAME sudo | |
gpasswd -a $USERNAME docker | |
PASSWORD=`pwgen -B -s 24 1` | |
echo $PASSWORD | mail -spassword [email protected] | |
echo $USERNAME:$PASSWORD | /usr/sbin/chpasswd | |
chage -d 0 $USERNAME | |
echo 'PermitRootLogin no' >> /etc/ssh/sshd_config | |
echo 'PasswordAuthentication no' >> /etc/ssh/sshd_config | |
echo "AllowUsers $USERNAME" >> /etc/ssh/sshd_config | |
service ssh reload |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run this on your host | |
startDroplet: | |
TOKEN= | |
curl | |
tuneDroplet: | |
URL=https://gist.githubusercontent.com/krasnobaev/d413691caefe295f8eba/raw/e45db37889cf35baef094f4378024dc523744926/DODockerDeploy | |
IP=127.0.0.1 | |
USERNAME=stub | |
# ssh root@$IP wget $URL | |
# ssh root@$IP source DODockerDeploy | |
# OR | |
# ssh root@$IP wget -O - $URL | bash | |
buildIPyOnPy2: | |
docker build -t ipyonpy2 . | |
docker run -it -p 8888:8888 ipyonpy2 | |
# docker exec -it 3835b7f7defa /bin/bash | |
buildIPyOnPy32: | |
docker build -t ipyonpy32 . | |
docker run -it -p 8888:8888 ipyonpy32 | |
# docker exec -it 3835b7f7defa /bin/bash | |
exposeRunningContainer: | |
docker ps | |
CONTAINER='99eedac6e51e' | |
CONTAINERIP=`docker inspect $CONTAINER | grep IPAddress | tr '" ' '\n' | grep -o '[0-9.]*'` | |
sudo iptables -t nat -A DOCKER -p tcp --dport 8888 -j DNAT --to-destination $CONTAINERIP:8888 | |
#sudo iptables --flush |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment