diff --git a/vim/Dockerfile.base b/vim/Dockerfile.base new file mode 100644 index 0000000..9a2bebc --- /dev/null +++ b/vim/Dockerfile.base @@ -0,0 +1,96 @@ +FROM docker.io/alpine:latest AS base + +RUN apk --no-cache add bash curl git + +ENV UID=1000 +ENV GID=1000 + +RUN addgroup --gid "1000" "vim" \ + && adduser \ + --disabled-password \ + --gecos "" \ + --home "/home/vim-user" \ + --ingroup "vim" \ + --uid "1000" \ + vim + +ENTRYPOINT ["/bin/bash"] + +# vim base +FROM base AS vim + +RUN apk --no-cache add vim --repository=https://dl-cdn.alpinelinux.org/alpine/edge/main + +USER vim + +# neovim base +FROM base AS neovim + +RUN apk --no-cache add neovim --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community \ + && ln -s /usr/bin/nvim /usr/local/bin/vim + +USER vim + +# pathogen-vim +FROM vim AS pathogen-vim + +RUN mkdir -p ~/.vim/autoload ~/.vim/bundle \ + && curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim + +COPY vimrc/pathogen.vimrc /home/vim/.vimrc + +# pathogen-neovim +FROM neovim AS pathogen-neovim + +RUN mkdir -p ~/.vim/autoload ~/.vim/bundle \ + && curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim + +COPY vimrc/pathogen.vimrc /home/vim/.vimrc + +# vim-plug stuff +FROM base AS vim-plug-builder + +RUN curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + +# vim-plug-vim +FROM vim AS vim-plug-vim + +COPY --from=vim-plug-builder /home/vim/.vim/autoload /home/vim/.vim/autoload + +# vim-plug-neovim +FROM neovim AS vim-plug-neovim + +COPY --from=vim-plug-builder /home/vim/.vim/autoload /home/vim/.vim/autoload + +# vundle stuff +FROM base AS vundle-builder + +RUN git clone https://github.com/VundleVim/Vundle.vim.git /home/vim/.vim/bundle/Vundle.vim + +# vundle-vim +FROM vim AS vundle-vim + +COPY --from=vundle-builder /home/vim/.vim/bundle /home/vim/.vim/bundle +COPY vimrc/vundle.vimrc /home/vim/.vimrc + +# vundle-neovim +FROM neovim AS vundle-neovim + +COPY --from=vundle-builder /home/vim/.vim/bundle /home/vim/.vim/bundle +COPY vimrc/vundle.vimrc /home/vim/.vimrc + +# vundle-vim test +FROM vundle-vim AS vundle-vim-test +COPY tests/vundle/vundle.vimrc /home/vim/.vimrc +COPY tests/test.sh /test.sh +COPY tests/commands.vim /commands.vim + +RUN chmod +x /test.sh && test.sh + +# vundle-vim test +FROM vundle-neovim AS vundle-neovim-test +COPY tests/vundle/vundle.vimrc /home/vim/.vimrc +COPY tests/test.sh /test.sh +COPY tests/commands.vim /commands.vim + +RUN chmod +x /test.sh && test.sh diff --git a/vim/Dockerfile.pathogen b/vim/Dockerfile.pathogen new file mode 100644 index 0000000..5259d29 --- /dev/null +++ b/vim/Dockerfile.pathogen @@ -0,0 +1,33 @@ +# pathogen-vim +FROM vim AS pathogen-vim + +RUN mkdir -p ~/.vim/autoload ~/.vim/bundle \ + && curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim + +COPY vimrc/pathogen.vimrc /home/vim/.vimrc + +# pathogen-neovim +FROM neovim AS pathogen-neovim + +RUN mkdir -p ~/.vim/autoload ~/.vim/bundle \ + && curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim + +COPY vimrc/pathogen.vimrc /home/vim/.vimrc + +# pathogen-vim test +FROM pathogen-vim AS vim-test +COPY tests/test.sh /test.sh +COPY tests/commands.vim /commands.vim + +COPY tests/pathogen/install.sh /install.sh +RUN bash /install.sh \ + && bash test.sh + +# pathogen-vim test +FROM pathogen-neovim AS neovim-test +COPY tests/test.sh /test.sh +COPY tests/commands.vim /commands.vim + +COPY tests/pathogen/install.sh /install.sh +RUN bash /install.sh \ + && bash test.sh diff --git a/vim/Dockerfile.vim-plug b/vim/Dockerfile.vim-plug new file mode 100644 index 0000000..dbc94a6 --- /dev/null +++ b/vim/Dockerfile.vim-plug @@ -0,0 +1,25 @@ +# vim-plug-vim +FROM vim AS vim-plug-vim + +RUN curl -fLo /home/vim-user/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + +# vim-plug-neovim +FROM neovim AS vim-plug-neovim + +RUN sh -c 'curl -fLo /home/vim-user/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' + +# vim-plug-vim test +FROM vim-plug-vim AS vim-test +COPY tests/vim-plug/vimrc /home/vim-user/.vimrc +COPY tests/test.sh /test.sh +COPY tests/commands.vim /commands.vim + +RUN bash test.sh + +# vim-plug-vim test +FROM vim-plug-neovim AS neovim-test +COPY tests/vim-plug/vimrc /home/vim-user/.vimrc +COPY tests/test.sh /test.sh +COPY tests/commands.vim /commands.vim + +RUN bash test.sh diff --git a/vim/Dockerfile.vundle b/vim/Dockerfile.vundle new file mode 100644 index 0000000..7060a79 --- /dev/null +++ b/vim/Dockerfile.vundle @@ -0,0 +1,31 @@ +FROM base AS vundle-builder + +RUN git clone https://github.com/VundleVim/Vundle.vim.git /home/vim/.vim/bundle/Vundle.vim + +# vundle-vim +FROM vim AS vundle-vim + +COPY --from=vundle-builder /home/vim/.vim/bundle /home/vim/.vim/bundle +COPY vimrc/vundle.vimrc /home/vim/.vimrc + +# vundle-neovim +FROM neovim AS vundle-neovim + +COPY --from=vundle-builder /home/vim/.vim/bundle /home/vim/.vim/bundle +COPY vimrc/vundle.vimrc /home/vim/.vimrc + +# vundle-vim test +FROM vundle-vim AS vim-test +COPY tests/vundle/vimrc /home/vim/.vimrc +COPY tests/test.sh /test.sh +COPY tests/commands.vim /commands.vim + +RUN bash test.sh + +# vundle-vim test +FROM vundle-neovim AS neovim-test +COPY tests/vundle/vimrc /home/vim/.vimrc +COPY tests/test.sh /test.sh +COPY tests/commands.vim /commands.vim + +RUN bash test.sh diff --git a/vim/README.md b/vim/README.md new file mode 100644 index 0000000..14e2a9e --- /dev/null +++ b/vim/README.md @@ -0,0 +1 @@ +This is a set of images with Vim or NeoVim and various Vim plugin managers installed. diff --git a/vim/build.sh b/vim/build.sh new file mode 100755 index 0000000..ac0f736 --- /dev/null +++ b/vim/build.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +docker build -t base -f Dockerfile.base --target=base . +docker build -t vim -f Dockerfile.base --target=vim . +docker build -t neovim -f Dockerfile.base --target=neovim . + +plugin_managers=("pathogen" "vim-plug" "vundle") + +set -ex +for manager in "${plugin_managers[@]}"; do + docker build -t "docker.io/heywoodlh/vim:${manager}-vim" -f "Dockerfile.${manager}" --target="${manager}-vim" . + docker build -t "docker.io/heywoodlh/vim:${manager}-vim-test" -f "Dockerfile.${manager}" --target="vim-test" . + docker build -t "docker.io/heywoodlh/vim:${manager}-neovim" -f "Dockerfile.${manager}" --target="${manager}-neovim" . + docker build -t "docker.io/heywoodlh/vim:${manager}-neovim-test" -f "Dockerfile.${manager}" --target="neovim-test" . +done diff --git a/vim/tests/commands.vim b/vim/tests/commands.vim new file mode 100644 index 0000000..d99643b --- /dev/null +++ b/vim/tests/commands.vim @@ -0,0 +1,2 @@ +:call writefile(["testline"], "/tmp/test.txt", "a") +:q! diff --git a/vim/tests/pathogen/install.sh b/vim/tests/pathogen/install.sh new file mode 100755 index 0000000..cd37425 --- /dev/null +++ b/vim/tests/pathogen/install.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +git clone https://github.com/tpope/vim-sensible.git /home/vim-user/.vim/bundle/vim-sensible +git clone https://github.com/github/copilot.vim /home/vim-user/.vim/bundle/copilot.vim diff --git a/vim/tests/test.sh b/vim/tests/test.sh new file mode 100755 index 0000000..eb5495a --- /dev/null +++ b/vim/tests/test.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -ex +vim -n -c "set nomore" -S "/commands.vim" "filespec" +grep testline /tmp/test.txt diff --git a/vim/tests/vim-plug/vimrc b/vim/tests/vim-plug/vimrc new file mode 100644 index 0000000..4b47fba --- /dev/null +++ b/vim/tests/vim-plug/vimrc @@ -0,0 +1,4 @@ +call plug#begin() +Plug 'github/copilot.vim' +Plug 'tpope/vim-fugitive' +call plug#end() diff --git a/vim/tests/vundle/vimrc b/vim/tests/vundle/vimrc new file mode 100644 index 0000000..723a5fa --- /dev/null +++ b/vim/tests/vundle/vimrc @@ -0,0 +1,18 @@ +set nocompatible " be iMproved, required +filetype off " required + +" set the runtime path to include Vundle and initialize +set rtp+=~/.vim/bundle/Vundle.vim +call vundle#begin() +" alternatively, pass a path where Vundle should install plugins +"call vundle#begin('~/some/path/here') + +" let Vundle manage Vundle, required +Plugin 'VundleVim/Vundle.vim' + +Plugin 'tpope/vim-fugitive' +Plugin 'github/copilot.vim' + +" All of your Plugins must be added before the following line +call vundle#end() " required +filetype plugin indent on " required diff --git a/vim/vimrc/pathogen.vimrc b/vim/vimrc/pathogen.vimrc new file mode 100644 index 0000000..b29d781 --- /dev/null +++ b/vim/vimrc/pathogen.vimrc @@ -0,0 +1,3 @@ +execute pathogen#infect() +syntax on +filetype plugin indent on diff --git a/vim/vimrc/vundle.vimrc b/vim/vimrc/vundle.vimrc new file mode 100644 index 0000000..a46aa27 --- /dev/null +++ b/vim/vimrc/vundle.vimrc @@ -0,0 +1,15 @@ +set nocompatible " be iMproved, required +filetype off " required + +" set the runtime path to include Vundle and initialize +set rtp+=~/.vim/bundle/Vundle.vim +call vundle#begin() +" alternatively, pass a path where Vundle should install plugins +"call vundle#begin('~/some/path/here') + +" let Vundle manage Vundle, required +Plugin 'VundleVim/Vundle.vim' + +" All of your Plugins must be added before the following line +call vundle#end() " required +filetype plugin indent on " required