From df318488c9bad0fae2e38c8fd57afaade295f135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Mon, 10 Jul 2017 18:39:55 -0400 Subject: [PATCH 1/2] test-in-docker: quickly test frameworks in docker This adds `./test-in-docker` for quickly playing with various frameworks. All the containers are based off Ubuntu 14.04 which has ZSH 5.0.2. Thanks to @dritter for figuring out all the framework installation methods. --- TESTS.md | 19 ++++++-- docker/antibody/Dockerfile | 7 +++ docker/antibody/install.zsh | 1 + docker/antibody/zshrc | 2 + docker/antigen/Dockerfile | 7 +++ docker/antigen/install.zsh | 12 +++++ docker/antigen/zshrc | 4 ++ docker/base/Dockerfile | 33 ++++++++++++++ docker/dotfile/Dockerfile | 4 ++ docker/dotfile/zshrc | 1 + docker/fred-sudoers | 2 + docker/omz/Dockerfile | 7 +++ docker/omz/install.zsh | 4 ++ docker/omz/zshrc | 5 +++ docker/prezto/Dockerfile | 6 +++ docker/prezto/install.zsh | 18 ++++++++ docker/zgen/Dockerfile | 7 +++ docker/zgen/install.zsh | 5 +++ docker/zgen/zshrc | 10 +++++ docker/zim/Dockerfile | 6 +++ docker/zim/install.zsh | 21 +++++++++ docker/zplug/Dockerfile | 7 +++ docker/zplug/install.zsh | 5 +++ docker/zplug/zshrc | 5 +++ docker/zplugin/Dockerfile | 7 +++ docker/zplugin/install.zsh | 12 +++++ docker/zplugin/zshrc.plugins | 5 +++ docker/zpm/Dockerfile | 7 +++ docker/zpm/install.zsh | 6 +++ docker/zpm/zshrc | 3 ++ docker/zulu/Dockerfile | 6 +++ docker/zulu/install.zsh | 10 +++++ test-in-docker | 85 ++++++++++++++++++++++++++++++++++++ 33 files changed, 336 insertions(+), 3 deletions(-) create mode 100644 docker/antibody/Dockerfile create mode 100644 docker/antibody/install.zsh create mode 100644 docker/antibody/zshrc create mode 100644 docker/antigen/Dockerfile create mode 100644 docker/antigen/install.zsh create mode 100644 docker/antigen/zshrc create mode 100644 docker/base/Dockerfile create mode 100644 docker/dotfile/Dockerfile create mode 100644 docker/dotfile/zshrc create mode 100644 docker/fred-sudoers create mode 100644 docker/omz/Dockerfile create mode 100644 docker/omz/install.zsh create mode 100644 docker/omz/zshrc create mode 100644 docker/prezto/Dockerfile create mode 100644 docker/prezto/install.zsh create mode 100644 docker/zgen/Dockerfile create mode 100644 docker/zgen/install.zsh create mode 100644 docker/zgen/zshrc create mode 100644 docker/zim/Dockerfile create mode 100644 docker/zim/install.zsh create mode 100644 docker/zplug/Dockerfile create mode 100644 docker/zplug/install.zsh create mode 100644 docker/zplug/zshrc create mode 100644 docker/zplugin/Dockerfile create mode 100644 docker/zplugin/install.zsh create mode 100644 docker/zplugin/zshrc.plugins create mode 100644 docker/zpm/Dockerfile create mode 100644 docker/zpm/install.zsh create mode 100644 docker/zpm/zshrc create mode 100644 docker/zulu/Dockerfile create mode 100644 docker/zulu/install.zsh create mode 100755 test-in-docker diff --git a/TESTS.md b/TESTS.md index d51051c5..64c4db48 100644 --- a/TESTS.md +++ b/TESTS.md @@ -13,10 +13,23 @@ Tests in separate files under `test/functions`. These Tests tend to be more complex in setup than the basic tests. To avoid ending up in a huge single file, there is one file per segment in `test/segments`. -# Test-VMs +# Manual Testing If unit tests are not sufficient (e.g. you have an issue with your prompt that -occurs only in a specific ZSH framework), then you could use our Test-VMs! +occurs only in a specific ZSH framework) then you can use either Docker or +or our Vagrant. + +## Docker + +This is the easiest to use _if_ you have Docker already installed and running. + +The command `./test-in-docker` should make it fairly easy to get into a running +container with the framework of your choice. + +You can get Docker at . + +## Vagrant + Currently there are two test VMs. `test-vm` is an Ubuntu machine with several pre-installed ZSH frameworks. And there is `test-bsd-vm` which is a FreeBSD! -For how to run the machines see [here](test-vm/README.md). \ No newline at end of file +For how to run the machines see [here](test-vm/README.md). diff --git a/docker/antibody/Dockerfile b/docker/antibody/Dockerfile new file mode 100644 index 00000000..9ee2e8be --- /dev/null +++ b/docker/antibody/Dockerfile @@ -0,0 +1,7 @@ +FROM p9k:base + +COPY docker/antibody/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/antibody/zshrc .zshrc diff --git a/docker/antibody/install.zsh b/docker/antibody/install.zsh new file mode 100644 index 00000000..4c54fa68 --- /dev/null +++ b/docker/antibody/install.zsh @@ -0,0 +1 @@ +curl -sL https://git.io/antibody | bash -s diff --git a/docker/antibody/zshrc b/docker/antibody/zshrc new file mode 100644 index 00000000..d516b679 --- /dev/null +++ b/docker/antibody/zshrc @@ -0,0 +1,2 @@ +source <(antibody init) +antibody bundle ~/p9k/ diff --git a/docker/antigen/Dockerfile b/docker/antigen/Dockerfile new file mode 100644 index 00000000..76487678 --- /dev/null +++ b/docker/antigen/Dockerfile @@ -0,0 +1,7 @@ +FROM p9k:base + +COPY docker/antigen/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/antigen/zshrc .zshrc diff --git a/docker/antigen/install.zsh b/docker/antigen/install.zsh new file mode 100644 index 00000000..6bab8ab3 --- /dev/null +++ b/docker/antigen/install.zsh @@ -0,0 +1,12 @@ +#!/bin/zsh + +mkdir ~/antigen + +curl \ + -qLsSf \ + -o ~/antigen/antigen.zsh \ + https://git.io/antigen + +source ~/antigen/antigen.zsh + +# EOF diff --git a/docker/antigen/zshrc b/docker/antigen/zshrc new file mode 100644 index 00000000..0f8d4da4 --- /dev/null +++ b/docker/antigen/zshrc @@ -0,0 +1,4 @@ +source ~/antigen/antigen.zsh + +antigen theme "${HOME}/p9k" powerlevel9k --no-local-clone +antigen apply diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile new file mode 100644 index 00000000..08d06254 --- /dev/null +++ b/docker/base/Dockerfile @@ -0,0 +1,33 @@ +FROM ubuntu:trusty + +RUN \ + apt-get update && \ + echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + curl \ + git \ + zsh \ + mercurial \ + subversion \ + golang \ + jq \ + node \ + ruby \ + python \ + python-virtualenv + +RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred +RUN locale-gen "en_US.UTF-8" + +COPY docker/fred-sudoers /etc/sudoers.d/fred + +USER fred +WORKDIR /home/fred +ENV LANG=en_US.UTF-8 +ENV TERM=xterm-256color +ENV DEFAULT_USER=fred +ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true + +RUN touch .zshrc + +CMD ["/bin/zsh", "-l"] diff --git a/docker/dotfile/Dockerfile b/docker/dotfile/Dockerfile new file mode 100644 index 00000000..166e348c --- /dev/null +++ b/docker/dotfile/Dockerfile @@ -0,0 +1,4 @@ +FROM p9k:base + +COPY ./ p9k/ +COPY docker/dotfile/zshrc .zshrc diff --git a/docker/dotfile/zshrc b/docker/dotfile/zshrc new file mode 100644 index 00000000..382b84a8 --- /dev/null +++ b/docker/dotfile/zshrc @@ -0,0 +1 @@ +source "${HOME}/p9k/prompt_powerlevel9k_setup" diff --git a/docker/fred-sudoers b/docker/fred-sudoers new file mode 100644 index 00000000..5fcd646f --- /dev/null +++ b/docker/fred-sudoers @@ -0,0 +1,2 @@ +Defaults:fred !requiretty +fred ALL=(ALL) NOPASSWD: ALL diff --git a/docker/omz/Dockerfile b/docker/omz/Dockerfile new file mode 100644 index 00000000..f839fba8 --- /dev/null +++ b/docker/omz/Dockerfile @@ -0,0 +1,7 @@ +FROM p9k:base + +COPY docker/omz/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY docker/omz/zshrc .zshrc +COPY ./ p9k/ diff --git a/docker/omz/install.zsh b/docker/omz/install.zsh new file mode 100644 index 00000000..e2cdfa96 --- /dev/null +++ b/docker/omz/install.zsh @@ -0,0 +1,4 @@ +sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" + +mkdir -p ~/.oh-my-zsh/custom/themes +ln -nsf ~/p9k/ ~/.oh-my-zsh/custom/themes/powerlevel9k diff --git a/docker/omz/zshrc b/docker/omz/zshrc new file mode 100644 index 00000000..9e798e2d --- /dev/null +++ b/docker/omz/zshrc @@ -0,0 +1,5 @@ +export ZSH=$HOME/.oh-my-zsh +ZSH_THEME="powerlevel9k/powerlevel9k" +plugins=(git rake ruby) + +source $ZSH/oh-my-zsh.sh diff --git a/docker/prezto/Dockerfile b/docker/prezto/Dockerfile new file mode 100644 index 00000000..389dbd0a --- /dev/null +++ b/docker/prezto/Dockerfile @@ -0,0 +1,6 @@ +FROM p9k:base + +COPY docker/prezto/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ diff --git a/docker/prezto/install.zsh b/docker/prezto/install.zsh new file mode 100644 index 00000000..9cca57ed --- /dev/null +++ b/docker/prezto/install.zsh @@ -0,0 +1,18 @@ +#!/bin/zsh + +set -eu + +git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto" + +setopt EXTENDED_GLOB +for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do + ln -nsf "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}" +done + +ln -s "${HOME}/p9k/powerlevel9k.zsh-theme" \ + "${HOME}/.zprezto/modules/prompt/functions/prompt_powerlevel9k_setup" + +echo "zstyle ':prezto:module:prompt' theme 'powerlevel9k'" \ + >> "${HOME}/.zpreztorc" + +# EOF diff --git a/docker/zgen/Dockerfile b/docker/zgen/Dockerfile new file mode 100644 index 00000000..9a0c13c7 --- /dev/null +++ b/docker/zgen/Dockerfile @@ -0,0 +1,7 @@ +FROM p9k:base + +COPY docker/zgen/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/zgen/zshrc .zshrc diff --git a/docker/zgen/install.zsh b/docker/zgen/install.zsh new file mode 100644 index 00000000..5cdc6181 --- /dev/null +++ b/docker/zgen/install.zsh @@ -0,0 +1,5 @@ +#!/bin/zsh + +git clone https://github.com/tarjoilija/zgen.git "${HOME}/.zgen" + +# EOF diff --git a/docker/zgen/zshrc b/docker/zgen/zshrc new file mode 100644 index 00000000..1fcb75b9 --- /dev/null +++ b/docker/zgen/zshrc @@ -0,0 +1,10 @@ +# load zgen +source ~/.zgen/zgen.zsh + +# if the init scipt doesn't exist +if ! zgen saved; then + zgen load ~/p9k/powerlevel9k.zsh-theme + + # generate the init script from plugins above + zgen save +fi diff --git a/docker/zim/Dockerfile b/docker/zim/Dockerfile new file mode 100644 index 00000000..dd10d102 --- /dev/null +++ b/docker/zim/Dockerfile @@ -0,0 +1,6 @@ +FROM p9k:base + +COPY docker/zim/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ diff --git a/docker/zim/install.zsh b/docker/zim/install.zsh new file mode 100644 index 00000000..d6c6006a --- /dev/null +++ b/docker/zim/install.zsh @@ -0,0 +1,21 @@ +#!zsh + +git clone --recursive https://github.com/Eriner/zim.git "${ZDOTDIR:-${HOME}}/.zim" + +setopt EXTENDED_GLOB +for template_file ( ${ZDOTDIR:-${HOME}}/.zim/templates/* ); do + user_file="${ZDOTDIR:-${HOME}}/.${template_file:t}" + touch ${user_file} + ( print -rn "$(<${template_file})$(<${user_file})" >! ${user_file} ) 2>/dev/null +done + +source "${ZDOTDIR:-${HOME}}/.zlogin" + +ln -nsf \ + ~/p9k/ \ + ~/.zim/modules/prompt/external-themes/powerlevel9k +ln -nsf \ + ~/.zim/modules/prompt/external-themes/powerlevel9k/powerlevel9k.zsh-theme \ + ~/.zim/modules/prompt/functions/prompt_powerlevel9k_setup + +sed -i "s/zprompt_theme='steeef'/zprompt_theme='powerlevel9k'/g" ~/.zimrc diff --git a/docker/zplug/Dockerfile b/docker/zplug/Dockerfile new file mode 100644 index 00000000..a87480be --- /dev/null +++ b/docker/zplug/Dockerfile @@ -0,0 +1,7 @@ +FROM p9k:base + +COPY docker/zplug/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/zplug/zshrc .zshrc diff --git a/docker/zplug/install.zsh b/docker/zplug/install.zsh new file mode 100644 index 00000000..b01ff6ee --- /dev/null +++ b/docker/zplug/install.zsh @@ -0,0 +1,5 @@ +#!zsh + +curl -sL --proto-redir -all,https https://raw.githubusercontent.com/zplug/installer/master/installer.zsh| zsh + +# git clone https://github.com/zplug/zplug "${HOME}/.zplug" diff --git a/docker/zplug/zshrc b/docker/zplug/zshrc new file mode 100644 index 00000000..0a4ceb83 --- /dev/null +++ b/docker/zplug/zshrc @@ -0,0 +1,5 @@ +#!zsh + +source ~/.zplug/init.zsh +zplug "${HOME}/p9k", use:"powerlevel9k.zsh-theme", from:local, as:theme +zplug load --verbose diff --git a/docker/zplugin/Dockerfile b/docker/zplugin/Dockerfile new file mode 100644 index 00000000..dc723606 --- /dev/null +++ b/docker/zplugin/Dockerfile @@ -0,0 +1,7 @@ +FROM p9k:base + +COPY docker/zplugin/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/zplugin/zshrc.plugins .zshrc.plugins diff --git a/docker/zplugin/install.zsh b/docker/zplugin/install.zsh new file mode 100644 index 00000000..fec4249d --- /dev/null +++ b/docker/zplugin/install.zsh @@ -0,0 +1,12 @@ +sh -c "$(curl -fsSL https://raw.githubusercontent.com/psprint/zplugin/master/doc/install.sh)" + +# The 'zplugin snippet' only copies the .zsh-theme file, not everything else. +mkdir -p ~/.zplugin/snippets +ln -nsf \ + ~/p9k/ \ +~/.zplugin/snippets/--SLASH--home--SLASH--fred--SLASH--p9k--SLASH--powerlevel9k--DOT--zsh-theme + +{ + echo + echo "source ~/.zshrc.plugins" +} >> ~/.zshrc diff --git a/docker/zplugin/zshrc.plugins b/docker/zplugin/zshrc.plugins new file mode 100644 index 00000000..2e9ba7a3 --- /dev/null +++ b/docker/zplugin/zshrc.plugins @@ -0,0 +1,5 @@ +#!zsh + +zplugin load psprint zsh-navigation-tools +zplugin load psprint---zprompts +zplugin snippet ~/p9k/powerlevel9k.zsh-theme diff --git a/docker/zpm/Dockerfile b/docker/zpm/Dockerfile new file mode 100644 index 00000000..d99edb37 --- /dev/null +++ b/docker/zpm/Dockerfile @@ -0,0 +1,7 @@ +FROM p9k:base + +COPY docker/zpm/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ +COPY docker/zpm/zshrc .zshrc diff --git a/docker/zpm/install.zsh b/docker/zpm/install.zsh new file mode 100644 index 00000000..6f74e8e0 --- /dev/null +++ b/docker/zpm/install.zsh @@ -0,0 +1,6 @@ +# install zpm +git clone --recursive https://github.com/zpm-zsh/zpm.git ~/.zpm + +# Install powerlevel9k +mkdir ~/.zpm/plugins/powerlevel9k +ln -s ~/p9k/powerlevel9k.zsh-theme ~/.zpm/plugins/powerlevel9k/powerlevel9k.plugin.zsh diff --git a/docker/zpm/zshrc b/docker/zpm/zshrc new file mode 100644 index 00000000..b107976e --- /dev/null +++ b/docker/zpm/zshrc @@ -0,0 +1,3 @@ +source ~/.zpm/zpm.zsh + +zpm load powerlevel9k diff --git a/docker/zulu/Dockerfile b/docker/zulu/Dockerfile new file mode 100644 index 00000000..dcb332ab --- /dev/null +++ b/docker/zulu/Dockerfile @@ -0,0 +1,6 @@ +FROM p9k:base + +COPY docker/zulu/install.zsh /tmp/ +RUN zsh /tmp/install.zsh + +COPY ./ p9k/ diff --git a/docker/zulu/install.zsh b/docker/zulu/install.zsh new file mode 100644 index 00000000..0ad6aae3 --- /dev/null +++ b/docker/zulu/install.zsh @@ -0,0 +1,10 @@ +#!zsh + +# install zulu https://github.com/zulu-zsh/zulu +curl -L https://git.io/zulu-install | zsh && zsh + +{ +echo 'zulu fpath add ~/p9k' +echo 'zulu fpath add ~/p9k/functions' +echo 'zulu theme powerlevel9k' +} >> ~/.zshrc diff --git a/test-in-docker b/test-in-docker new file mode 100755 index 00000000..ff3bb86b --- /dev/null +++ b/test-in-docker @@ -0,0 +1,85 @@ +#!/usr/bin/env zsh + +set -eu + +setopt extendedglob +cd "${${(%):-%x}:A:h}" + +# TODO: Crazy Logic to munge TERM to something supported in Ubuntu 14.04 +term=screen-256color + +frameworks() +{ + for path in docker/*/Dockerfile(N.); do + framework=${path:h:t} + if [[ "$framework" == base ]]; then continue; fi + echo "$framework" + done +} + +show-help() +{ + echo "Usage: ${(%):-%x} |--list" + echo + echo "Loads up a docker image with powershell9k configured in " + echo + echo " --list Lists all available framework containers." + echo + echo "Framework containers:" + for f in $(frameworks); do + echo " - $f" + done +} + +build-and-run() +{ + local framework="$1" ; shift + + print -P "%F{green}Preparing ${framework} container...%f" + + if [[ "$framework" != "base" ]]; then + echo -n "p9k:base: " + docker build \ + --quiet \ + --tag p9k:base \ + --file docker/base/Dockerfile \ + . + fi + echo -n "p9k:${framework}: " + docker build \ + --quiet \ + --tag "p9k:${framework}" \ + --file "docker/${framework}/Dockerfile" \ + . + + + print -P "%F{green}Starting ${framework} container...%f" + exec docker run \ + --rm \ + --interactive \ + --tty \ + --hostname="${framework}" \ + --env="TERM=${term}" \ + "$@" \ + "p9k:${framework}" +} + +arg1="${1:-}"; if (( $# > 0 )); then shift; fi + +if [[ -z "$arg1" ]] || [[ "$arg1" == "help" ]]; then + show-help + exit 0 +elif [[ "$arg1" == '--list' ]]; then + frameworks + exit 0 +elif [[ -d "docker/${arg1}" ]]; then + build-and-run "$arg1" +elif [[ -n "docker/${arg1}"*/Dockerfile(#qN) ]]; then + # Allow globbing + build-and-run "docker/${arg1}"*(Y1:t) +else + show-help + exit 1 +fi + +# EOF From 2f808f8a4e6224478e1c9efb85c1a4b3f24df087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20H=C3=B6ltje?= Date: Wed, 12 Jul 2017 02:46:32 -0400 Subject: [PATCH 2/2] test-in-docker: Support for multiple ZSH versions -z --zsh can specify one of the versions of ZSH we can get from centos and ubuntu --- TESTS.md | 14 ++ docker/antibody/Dockerfile | 3 +- docker/antigen/Dockerfile | 3 +- docker/base-4.3.11/Dockerfile | 31 +++++ docker/{base => base-5.0.3}/Dockerfile | 2 +- docker/base-5.1.1/Dockerfile | 35 +++++ docker/base-5.2/Dockerfile | 35 +++++ docker/dotfile/Dockerfile | 3 +- docker/omz/Dockerfile | 3 +- docker/prezto/Dockerfile | 3 +- docker/zgen/Dockerfile | 3 +- docker/zim/Dockerfile | 3 +- docker/zplug/Dockerfile | 3 +- docker/zplugin/Dockerfile | 3 +- docker/zpm/Dockerfile | 3 +- docker/zulu/Dockerfile | 3 +- test-in-docker | 180 +++++++++++++++++-------- 17 files changed, 264 insertions(+), 66 deletions(-) create mode 100644 docker/base-4.3.11/Dockerfile rename docker/{base => base-5.0.3}/Dockerfile (96%) create mode 100644 docker/base-5.1.1/Dockerfile create mode 100644 docker/base-5.2/Dockerfile diff --git a/TESTS.md b/TESTS.md index 64c4db48..eb5db704 100644 --- a/TESTS.md +++ b/TESTS.md @@ -26,8 +26,22 @@ This is the easiest to use _if_ you have Docker already installed and running. The command `./test-in-docker` should make it fairly easy to get into a running container with the framework of your choice. +Examples: + +``` zsh +# Test Antigen with the oldest version of ZSH +$ ./test-in-docker antigen +``` + +``` zsh +# Test Prezto with ZSH version 5.2 +$ ./test-in-docker --zsh 5.2 prezto +``` + You can get Docker at . +**Note:** Not all frameworks work with all versions of ZSH (or the underlying OS). + ## Vagrant Currently there are two test VMs. `test-vm` is an Ubuntu machine with several diff --git a/docker/antibody/Dockerfile b/docker/antibody/Dockerfile index 9ee2e8be..84a60a89 100644 --- a/docker/antibody/Dockerfile +++ b/docker/antibody/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/antibody/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/antigen/Dockerfile b/docker/antigen/Dockerfile index 76487678..d8d0a4bc 100644 --- a/docker/antigen/Dockerfile +++ b/docker/antigen/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/antigen/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/base-4.3.11/Dockerfile b/docker/base-4.3.11/Dockerfile new file mode 100644 index 00000000..805a7ae1 --- /dev/null +++ b/docker/base-4.3.11/Dockerfile @@ -0,0 +1,31 @@ +FROM centos:6 + +RUN \ + yum install -y \ + curl \ + git \ + zsh \ + mercurial \ + subversion \ + golang \ + jq \ + node \ + ruby \ + python \ + python-virtualenv \ + sudo + +RUN adduser --shell /bin/zsh --comment 'fred' --user-group fred + +COPY docker/fred-sudoers /etc/sudoers.d/fred + +USER fred +WORKDIR /home/fred +ENV LANG=en_US.UTF-8 +ENV TERM=xterm-256color +ENV DEFAULT_USER=fred +ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true + +RUN touch .zshrc + +CMD ["/bin/zsh", "-l"] diff --git a/docker/base/Dockerfile b/docker/base-5.0.3/Dockerfile similarity index 96% rename from docker/base/Dockerfile rename to docker/base-5.0.3/Dockerfile index 08d06254..e0b6c6c3 100644 --- a/docker/base/Dockerfile +++ b/docker/base-5.0.3/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:trusty +FROM ubuntu:14.04 RUN \ apt-get update && \ diff --git a/docker/base-5.1.1/Dockerfile b/docker/base-5.1.1/Dockerfile new file mode 100644 index 00000000..a7f644bf --- /dev/null +++ b/docker/base-5.1.1/Dockerfile @@ -0,0 +1,35 @@ +FROM ubuntu:16.04 + +RUN \ + apt-get update && \ + echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + curl \ + git \ + zsh \ + mercurial \ + subversion \ + golang \ + jq \ + nodejs \ + ruby \ + python \ + python-virtualenv \ + sudo \ + locales + +RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred +RUN locale-gen "en_US.UTF-8" + +COPY docker/fred-sudoers /etc/sudoers.d/fred + +USER fred +WORKDIR /home/fred +ENV LANG=en_US.UTF-8 +ENV TERM=xterm-256color +ENV DEFAULT_USER=fred +ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true + +RUN touch .zshrc + +CMD ["/bin/zsh", "-l"] diff --git a/docker/base-5.2/Dockerfile b/docker/base-5.2/Dockerfile new file mode 100644 index 00000000..62a10074 --- /dev/null +++ b/docker/base-5.2/Dockerfile @@ -0,0 +1,35 @@ +FROM ubuntu:17.04 + +RUN \ + apt-get update && \ + echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y \ + curl \ + git \ + zsh \ + mercurial \ + subversion \ + golang \ + jq \ + nodejs \ + ruby \ + python \ + python-virtualenv \ + sudo \ + locales + +RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred +RUN locale-gen "en_US.UTF-8" + +COPY docker/fred-sudoers /etc/sudoers.d/fred + +USER fred +WORKDIR /home/fred +ENV LANG=en_US.UTF-8 +ENV TERM=xterm-256color +ENV DEFAULT_USER=fred +ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true + +RUN touch .zshrc + +CMD ["/bin/zsh", "-l"] diff --git a/docker/dotfile/Dockerfile b/docker/dotfile/Dockerfile index 166e348c..f29c4d56 100644 --- a/docker/dotfile/Dockerfile +++ b/docker/dotfile/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY ./ p9k/ COPY docker/dotfile/zshrc .zshrc diff --git a/docker/omz/Dockerfile b/docker/omz/Dockerfile index f839fba8..1a417b9f 100644 --- a/docker/omz/Dockerfile +++ b/docker/omz/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/omz/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/prezto/Dockerfile b/docker/prezto/Dockerfile index 389dbd0a..70f3b65d 100644 --- a/docker/prezto/Dockerfile +++ b/docker/prezto/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/prezto/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/zgen/Dockerfile b/docker/zgen/Dockerfile index 9a0c13c7..48e44c77 100644 --- a/docker/zgen/Dockerfile +++ b/docker/zgen/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/zgen/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/zim/Dockerfile b/docker/zim/Dockerfile index dd10d102..cfe0fc93 100644 --- a/docker/zim/Dockerfile +++ b/docker/zim/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/zim/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/zplug/Dockerfile b/docker/zplug/Dockerfile index a87480be..89c23d54 100644 --- a/docker/zplug/Dockerfile +++ b/docker/zplug/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/zplug/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/zplugin/Dockerfile b/docker/zplugin/Dockerfile index dc723606..90c35c0e 100644 --- a/docker/zplugin/Dockerfile +++ b/docker/zplugin/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/zplugin/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/zpm/Dockerfile b/docker/zpm/Dockerfile index d99edb37..c1c44e38 100644 --- a/docker/zpm/Dockerfile +++ b/docker/zpm/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/zpm/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/docker/zulu/Dockerfile b/docker/zulu/Dockerfile index dcb332ab..880a07d0 100644 --- a/docker/zulu/Dockerfile +++ b/docker/zulu/Dockerfile @@ -1,4 +1,5 @@ -FROM p9k:base +ARG base +FROM p9k:${base} COPY docker/zulu/install.zsh /tmp/ RUN zsh /tmp/install.zsh diff --git a/test-in-docker b/test-in-docker index ff3bb86b..c1aafcd9 100755 --- a/test-in-docker +++ b/test-in-docker @@ -2,84 +2,156 @@ set -eu -setopt extendedglob +# The default ZSH to use. +default_version='4.3.11' + +setopt extended_glob glob_subst numeric_glob_sort cd "${${(%):-%x}:A:h}" # TODO: Crazy Logic to munge TERM to something supported in Ubuntu 14.04 term=screen-256color -frameworks() +# Note: If versions and frameworks looks complicated, it isn't that bad... +# ...see Modifiers in zshexpn(1) for details. + +# List of ZSH versions +typeset -a versions +versions=( docker/base-*/Dockerfile(N.on:h:t:s/base-//) ) + +# List of frameworks +typeset -a frameworks +frameworks=( docker/*/Dockerfile(N.on:h:t) ) +frameworks=${(@)frameworks:#base-*} + +err() { - for path in docker/*/Dockerfile(N.); do - framework=${path:h:t} - if [[ "$framework" == base ]]; then continue; fi - echo "$framework" - done + print -P "%F{red}Error:%f $*" + exit 2 } -show-help() -{ - echo "Usage: ${(%):-%x} |--list" - echo - echo "Loads up a docker image with powershell9k configured in " - echo - echo " --list Lists all available framework containers." - echo - echo "Framework containers:" - for f in $(frameworks); do - echo " - $f" - done +resolve_framework() { + local f=$1 found + found=${frameworks[(In:-1:)$f*]} + if (( found <= $#frameworks )); then + echo "${frameworks[$found]}" + fi } -build-and-run() -{ - local framework="$1" ; shift +resolve_version() { + local v=$1 found + found=${versions[(In:-1:)$v*]} + if (( found <= $#versions )); then + echo "${versions[$found]}" + fi +} - print -P "%F{green}Preparing ${framework} container...%f" +build_and_run() { + local version="$1" + local framework="$2" + local name="${version}-${framework}" - if [[ "$framework" != "base" ]]; then - echo -n "p9k:base: " - docker build \ - --quiet \ - --tag p9k:base \ - --file docker/base/Dockerfile \ - . - fi - echo -n "p9k:${framework}: " + print -P "%F{green}Preparing containers...%f" + + echo -n "p9k:base-${version}: " docker build \ --quiet \ - --tag "p9k:${framework}" \ - --file "docker/${framework}/Dockerfile" \ + --tag "p9k:base-${version}" \ + --file "docker/base-${version}/Dockerfile" \ . + echo -n "p9k:${version}-${framework}: " + docker build \ + --quiet \ + --build-arg="base=base-${version}" \ + --tag "p9k:${version}-${framework}" \ + --file "docker/${framework}/Dockerfile" \ + . - print -P "%F{green}Starting ${framework} container...%f" + print -P "%F{green}Starting ${name} container...%f" exec docker run \ --rm \ --interactive \ --tty \ - --hostname="${framework}" \ + --hostname="${name//./_}" \ --env="TERM=${term}" \ - "$@" \ - "p9k:${framework}" + "p9k:${version}-${framework}" +} + +show_help() { + local f v + echo "Usage: ${(%):-%x} |--list" + echo + echo "Loads up a docker image with powershell9k configured in " + echo + echo " --frameworks Lists all available frameworks, newline separated." + echo " --versions Lists all available ZSH versions, newline separated." + echo " --zsh VER Uses ZSH with version VER." + echo " --help You're soaking in it." + echo + echo "ZSH versions:" + for v in "${(@)versions}"; do + echo " $v" + done + echo + echo "Framework containers:" + for f in "${(@)frameworks}"; do + echo " $f" + done } -arg1="${1:-}"; if (( $# > 0 )); then shift; fi - -if [[ -z "$arg1" ]] || [[ "$arg1" == "help" ]]; then - show-help - exit 0 -elif [[ "$arg1" == '--list' ]]; then - frameworks - exit 0 -elif [[ -d "docker/${arg1}" ]]; then - build-and-run "$arg1" -elif [[ -n "docker/${arg1}"*/Dockerfile(#qN) ]]; then - # Allow globbing - build-and-run "docker/${arg1}"*(Y1:t) -else - show-help - exit 1 +# No arguments +if (( $# == 0 )); then + show_help + exit fi +# Parse flags and such. +use_version=$default_version +use_framework= +while (( $# > 0 )); do + case "$1" in + -f | --frameworks ) + print -l "${(@)frameworks}" + exit + ;; + -v | --versions ) + print -l "${(@)versions}" + exit + ;; + -z | --zsh ) + shift + local v="$(resolve_version "$1")" + if [[ -n "$v" ]]; then + use_version=$v + else + err "No such ZSH version '${1}'" + fi + ;; + -h | --help ) + show_help + exit + ;;; + -* ) + err "Unknown option ${1}" + show_help + exit 1 + ;; + * ) + if [[ -z "$use_framework" ]]; then + local f="$(resolve_framework "$1")" + if [[ -n "$f" ]]; then + use_framework=$f + else + err "No such framework '${1}'" + fi + else + err "You can only specify one framework at a time; you already specified '${use_framework}'" + fi + ;; + esac + shift +done + +build_and_run "$use_version" "$use_framework" + # EOF