Creating a Neovim Container Image for Airgap Environment

Zhimin Wen
4 min readMay 23, 2023
Image by Rudy and Peter Skitterians from Pixabay

I deal with disconnected environment constantly. I need to have my toolbox prepared before going to these environment. Container image become my 1st choice as it ideally wraps the tools without the need of intrusively installing any dependencies.

Let’s check out a neovim and golang environment I built as a container image.

The Base Dockerfile

FROM docker.io/golang

WORKDIR /workspace
RUN git clone https://github.com/magefile/mage && \
cd mage && \
go run bootstrap.go && \
cd .. && rm -rf mage && \
curl -LO https://github.com/neovim/neovim/releases/download/stable/nvim-linux64.tar.gz && \
tar -xzf nvim-linux64.tar.gz && \
rm -rf nvim-linux64.tar.gz && \
mv nvim-linux64 / && \
ln -fs /nvim-linux64/bin/nvim /usr/local/bin/nvim && \
mkdir -p /root/.config/nvim && \
apt update && apt install -y unzip nodejs npm ripgrep && \
git clone https://github.com/NvChad/NvChad ~/.config/nvim

Start with the golang image, add the magefile tool. Then install the neovim as the editor.

Instead customize the neovim configuration from scratch, lets use the NvChad, “Blazing fast Neovim framework providing solid defaults and a beautiful UI, enhancing your neovim experience”. The installation is very straighforward by cloning its github repo.

Let’s build our base working image.

podman build -t go-ide:v0.98 .

NvChad/Neovim Custom Config

NvChad provides a well structured configuration for neovim. Let’s start with the example repo, https://github.com/NvChad/example_config, as our base custom configuration.

git clone https://github.com/NvChad/example_config myCustom
  1. Custom Snippets

NvChad uses LuaSnip. To add my own custom snippets that I used in VSCode, first update myCustom/init.lua to define the VSCode snippets location.

vim.g.vscode_snippets_path = vim.fn.stdpath "config" .. "/lua/custom/snippets"

The path will be expand as ~/.config/nvim/lua/custom/snippets Lets create myCustom/snippets directory. In this directory, copy the VSCode snippets for golang, save it as go.json…

--

--