From 8dbafa6971a44695c12d2196063acd267e748df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Thu, 9 Apr 2015 01:30:27 +0200 Subject: [PATCH] Zsh+Docker --- DevDockerfile => Docker/Dockerfile | 14 ++++++++++---- make.sh | 20 ++++++++------------ zshrc | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+), 16 deletions(-) rename DevDockerfile => Docker/Dockerfile (82%) diff --git a/DevDockerfile b/Docker/Dockerfile similarity index 82% rename from DevDockerfile rename to Docker/Dockerfile index a88e7ad..3eb867f 100644 --- a/DevDockerfile +++ b/Docker/Dockerfile @@ -30,19 +30,25 @@ ENV PATH /home/dev/bin:$PATH RUN mkdir /var/shared/ RUN touch /var/shared/placeholder RUN chown -R dev:dev /var/shared -VOLUME /var/shared +RUN mkdir -p /usr/src/app/ +RUN touch /usr/src/app/nocode +RUN chown -R dev:dev /usr/src/app + +VOLUME /usr/src/app WORKDIR /home/dev ENV HOME /home/dev -ADD . /home/dev/dotfiles +RUN git clone https://github.com/balkian/dotfiles /home/dev/dotfiles RUN sh /home/dev/dotfiles/make.sh # Link in shared parts of the home directory RUN ln -s /var/shared/.ssh -RUN ln -s /var/shared/src +RUN ln -s /usr/src/app RUN chsh dev -s /usr/bin/zsh RUN chown -R dev: /home/dev RUN chown -R dev: /usr/local/ -ENTRYPOINT ["/usr/bin/zsh", "-i"] + +WORKDIR /home/dev/app +ENTRYPOINT ["zsh"] USER dev diff --git a/make.sh b/make.sh index 6389edc..e3e3e9d 100644 --- a/make.sh +++ b/make.sh @@ -6,32 +6,28 @@ ########## Variables -# dotfiles directory -dir=`dirname $0` - # change to the dotfiles directory -echo "Changing to the $dir directory" -cd $dir -echo "...done" +cd `dirname $0` ########## Don't forget the submodules git submodule init git submodule update --recursive olddir=~/dotfiles$(date +%Y-%m-%d_%H:%M:%S) # old dotfiles backup directory -files=$(ls --ignore="not_dots" --ignore="README.md" --ignore="make.sh" --ignore="DevDockerfile" $dir) # list of files/folders to symlink in homedir +files=$(ls --ignore="not_dots" --ignore="README.md" --ignore="make.sh" --ignore="Docker" $PWD) # list of files/folders to symlink in homedir ########## # create dotfiles_old in homedir -echo "Creating $olddir for backup: of any existing dotfiles in ~" +echo "** Creating $olddir for backup: of any existing dotfiles in ~" mkdir -p $olddir echo "...done" # move any existing dotfiles in homedir to dotfiles_old directory, then create symlinks +echo "** Creating symlinks. Any existing dotfiles will be moved to: $olddir" for file in $files; do - echo "Moving any existing dotfiles from ~ to $olddir" - mv ~/.$file $olddir - echo "Creating symlink to $file in home directory." - ln -s $dir/$file ~/.$file + mv ~/.$file $olddir && echo "Backed up: ~/.$file" + ln -s $PWD/$file ~/.$file done + +rmdir $olddir 2>/dev/null && echo "Backup dir empty. Removed" diff --git a/zshrc b/zshrc index ada2f2f..a0fd81e 100644 --- a/zshrc +++ b/zshrc @@ -50,6 +50,24 @@ alias e='myemacs -nw' alias ew='myemacs -n' export ALTERNATE_EDITOR=/usr/bin/vim EDITOR="vim" VISUAL="vim" +# Docker goodies +alias drm="docker rm" +alias drmi="docker rmi" +alias dps="docker ps" +alias dpi="docker images" +function da () { + docker start $1 && docker attach $1 +} +function drmia () { + docker rmi $(docker images | grep "^" | awk '{print $3}') +} +function drma () { + docker rm $(docker ps -q $*) +} +function newdev () { + docker run -v $PWD:/usr/src/app -t -i --name $1 -h $1 balkian/devmachine +} + PYTHONSTARTUP=~/.pythonrc.py export PYTHONSTARTUP ssh-add -l >/dev/null || alias ssh='ssh-add -l >/dev/null || ssh-add && unalias ssh; ssh'; alias mosh='ssh-add -l >/dev/null || ssh-add && unalias mosh; mosh'