Skip to content

Commit

Permalink
Add install script and update builds (#7)
Browse files Browse the repository at this point in the history
* Add an install script that detects OS (alpine and ubuntu only for now)

* Add a full and minimal version for each base image build

* Fix for runtime error in fzf-lua

* Add bash lsp to ensure installed
  • Loading branch information
mau-mauricelim authored Aug 15, 2024
1 parent fce062b commit 4e76c3e
Show file tree
Hide file tree
Showing 11 changed files with 268 additions and 245 deletions.
4 changes: 4 additions & 0 deletions .commonrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$XDG_CONFIG_HOME/local/share"
export XDG_CACHE_HOME="$XDG_CONFIG_HOME/cache"
export XDG_STATE_HOME="$HOME/.local/state"
# BUG: fix for https://github.com/ibhagwan/fzf-lua/issues/1243
export XDG_RUNTIME_DIR="$XDG_CONFIG_HOME/local/runtime-dir"
[ -d "$XDG_RUNTIME_DIR" ] || mkdir -p "$XDG_RUNTIME_DIR"
[ "$(stat -c "%a" "$XDG_RUNTIME_DIR")" = "700" ] || chmod 700 "$XDG_RUNTIME_DIR"

# Set system locale
export LANG=C.UTF-8
Expand Down
16 changes: 8 additions & 8 deletions .config/nvim/lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp-vsnip": { "branch": "main", "commit": "989a8a73c44e926199bfd05fa7a516d51f2d2752" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"conform.nvim": { "branch": "master", "commit": "2122fe2ff01e9a542fc358ee9398ce2cbddf345d" },
"conform.nvim": { "branch": "master", "commit": "667102f26106709cddd2dff1f699610df5b94d7f" },
"fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" },
"flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" },
"fzf-lua": { "branch": "main", "commit": "2c4f76ac810de3b1ef91f06371ebc3cff55b1b3c" },
"fzf-lua": { "branch": "main", "commit": "64a305a2490e48c44be9f5a489e01b995dd58c92" },
"gitsigns.nvim": { "branch": "main", "commit": "562dc47189ad3c8696dbf460d38603a74d544849" },
"harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" },
"incline.nvim": { "branch": "main", "commit": "16fc9c073e3ea4175b66ad94375df6d73fc114c0" },
"indent-blankline.nvim": { "branch": "master", "commit": "3fe94b8034dd5241cb882bb73847303b58857ecf" },
"indent-blankline.nvim": { "branch": "master", "commit": "dddb5d21811c319eb6e51a993d8fb44b193aae3f" },
"lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" },
"lazygit.nvim": { "branch": "main", "commit": "dc56df433bfbf107fee0139e187eb9750878fa84" },
"lazygit.nvim": { "branch": "main", "commit": "2432b447483f42ff2e18b2d392cb2bb27e495c08" },
"lualine.nvim": { "branch": "master", "commit": "544dd1583f9bb27b393f598475c89809c4d5e86b" },
"markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "62360f061d45177dda8afc1b0fd1327328540301" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"mini.nvim": { "branch": "main", "commit": "d8faae693d266ee4f3a2bf1fb7ca4bc81314c3e9" },
"mini.nvim": { "branch": "main", "commit": "608e15779f3d672d30c8ee01ad8ff9cac9f7d723" },
"neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" },
"noice.nvim": { "branch": "main", "commit": "d9328ef903168b6f52385a751eb384ae7e906c6f" },
"nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" },
"nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" },
"nvim-lspconfig": { "branch": "master", "commit": "652386deae739e38fa1bcf2f06e3e7de9b3436ba" },
"nvim-tree.lua": { "branch": "master", "commit": "f9ff00bc06d7cb70548a3847d7a2a05e928bc988" },
"nvim-treesitter": { "branch": "master", "commit": "3e0feeb062b29bb7d6d6df1e32ba28111c2bb734" },
"nvim-lspconfig": { "branch": "master", "commit": "ff97d376b1d22b2eaf9274605531babf0cd0cf21" },
"nvim-tree.lua": { "branch": "master", "commit": "ad0b95dee55955817af635fa121f6e2486b10583" },
"nvim-treesitter": { "branch": "master", "commit": "8a966f32c973511f9697264b3533e9846d29fd09" },
"nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" },
"oil.nvim": { "branch": "master", "commit": "fcca212c2e966fc3dec1d4baf888e670631d25d1" },
"onedark.nvim": { "branch": "master", "commit": "fae34f7c635797f4bf62fb00e7d0516efa8abe37" },
Expand Down
5 changes: 5 additions & 0 deletions .config/nvim/lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ return { -- LSP Configuration & Plugins
-- for you, so that they are available from within Neovim.
local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, {
-- you can turn off/on auto_update per tool
{ 'bash-language-server', auto_update = true },
'shfmt',
'shellcheck',
'lua-language-server',
'stylua', -- Used to format lua code
})
require('mason-tool-installer').setup({ ensure_installed = ensure_installed })
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/wsl-distro-custom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
BASE_IMAGE: [ ubuntu, alpine ]
BASE_IMAGE: [ alpine, ubuntu ]
INSTALL_TYPE: [ mini, full ]
runs-on: ubuntu-latest
env:
IMAGE_NAME: ${{ matrix.BASE_IMAGE }}-custom
IMAGE_NAME: ${{ matrix.BASE_IMAGE }}.${{ matrix.INSTALL_TYPE }}-custom
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -36,6 +37,8 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
file: Dockerfile.${{ matrix.BASE_IMAGE }}
build-args: |
INSTALL_TYPE=${{ matrix.INSTALL_TYPE }}
- name: Upload docker image to registry
run: docker image push ${{ env.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest
- name: Export docker container to a tar.gz file using gzip
Expand All @@ -50,4 +53,4 @@ jobs:
name: wsl-${{ env.IMAGE_NAME }}
path: |
/tmp/${{ env.IMAGE_NAME }}.tar.gz
/tmp/install.cmd
/tmp/install.cmd
4 changes: 3 additions & 1 deletion .profile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
# This file is not read by bash(1), if $HOME/.bash_profile or $HOME/.bash_login exists.

# If running bash, include .bashrc if it exists
[ -n "$BASH_VERSION" ] && [ -f "$HOME/.bashrc" ] && source "$HOME/.bashrc"
[ -n "$BASH_VERSION" ] && [ -f "$HOME/.bashrc" ] && source "$HOME/.bashrc"
export NVM_DIR="$HOME/.config/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
1 change: 1 addition & 0 deletions .stow-local-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ src
tests
bin
^/Dockerfile.*
install.sh
.*.md
119 changes: 6 additions & 113 deletions Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -9,65 +9,10 @@ ARG USERNAME=maurice
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ARG HOME=/home/$USERNAME
ARG INSTALL_TYPE=mini

# Alpine uses MUSL binaries
# Install required packages
RUN apk -q --no-progress --no-cache add \
# coreutils is for dircolors, procps is for vim-tmux-navigator
# build-base installs a C compiler for nvim-treesitter
sudo zsh coreutils tar bzip2 rlwrap curl git vim stow openssh tmux procps build-base xclip \
# Busybox binaries (default) doesn't support all features. E.g. `grep -P`
grep \
# util-linux-misc is for script
neovim bash util-linux-misc nodejs npm \
# Entry in man
mandoc man-pages less \
# Install the documentation companion package
docs && \
# Manual install of man pages for release binaries
mkdir -p /usr/local/share/man/man1 && \
# Install MUSL ripgrep from source
RIPGREP_VERSION=$(curl -sL "https://api.github.com/repos/BurntSushi/ripgrep/releases/latest" | grep tag_name | cut -d '"' -f4) && \
curl -sL https://github.com/BurntSushi/ripgrep/releases/download/${RIPGREP_VERSION}/ripgrep-${RIPGREP_VERSION}-x86_64-unknown-linux-musl.tar.gz \
| tar xz ripgrep-${RIPGREP_VERSION}-x86_64-unknown-linux-musl/rg ripgrep-${RIPGREP_VERSION}-x86_64-unknown-linux-musl/doc/rg.1 --strip-components=1 && \
install rg /usr/local/bin && mv doc/rg.1 /usr/local/share/man/man1 && rm -r rg doc && \
# Install MUSL fd from source
FD_VERSION=$(curl -sL "https://api.github.com/repos/sharkdp/fd/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') && \
curl -sL https://github.com/sharkdp/fd/releases/download/v${FD_VERSION}/fd-v${FD_VERSION}-x86_64-unknown-linux-musl.tar.gz \
| tar xz fd-v${FD_VERSION}-x86_64-unknown-linux-musl/fd fd-v${FD_VERSION}-x86_64-unknown-linux-musl/fd.1 --strip-components=1 && \
install fd /usr/local/bin && mv fd.1 /usr/local/share/man/man1 && rm fd && \
# Install MUSL bat from source
BAT_VERSION=$(curl -sL "https://api.github.com/repos/sharkdp/bat/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') && \
curl -sL https://github.com/sharkdp/bat/releases/download/v${BAT_VERSION}/bat-v${BAT_VERSION}-x86_64-unknown-linux-musl.tar.gz \
| tar xz bat-v${BAT_VERSION}-x86_64-unknown-linux-musl/bat bat-v${BAT_VERSION}-x86_64-unknown-linux-musl/bat.1 --strip-components=1 && \
install bat /usr/local/bin && mv bat.1 /usr/local/share/man/man1 && rm bat && \
# Install MUSL eza from source
EZA_VERSION=$(curl -sL "https://api.github.com/repos/eza-community/eza/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') && \
curl -sL https://github.com/eza-community/eza/releases/latest/download/eza_x86_64-unknown-linux-musl.tar.gz | tar xz && \
curl -sL https://github.com/eza-community/eza/releases/latest/download/man-${EZA_VERSION}.tar.gz | tar xz ./target/man-${EZA_VERSION}/eza.1 --strip-components=3 && \
install eza /usr/local/bin && mv eza.1 /usr/local/share/man/man1 && rm eza && \
# Install MUSL delta from source
DELTA_VERSION=$(curl -sL "https://api.github.com/repos/dandavison/delta/releases/latest" | grep tag_name | cut -d '"' -f4) && \
curl -sL https://github.com/dandavison/delta/releases/latest/download/delta-${DELTA_VERSION}-x86_64-unknown-linux-musl.tar.gz \
| tar xz delta-${DELTA_VERSION}-x86_64-unknown-linux-musl/delta --strip-components=1 && \
install delta /usr/local/bin && rm delta && \
# Install MUSL yazi from source
YAZI_VERSION=$(curl -sL "https://api.github.com/repos/sxyazi/yazi/releases/latest" | grep tag_name | cut -d '"' -f4) && \
curl -sLo yazi.zip https://github.com/sxyazi/yazi/releases/download/${YAZI_VERSION}/yazi-x86_64-unknown-linux-musl.zip && \
unzip -qj yazi.zip yazi-x86_64-unknown-linux-musl/yazi && \
install yazi /usr/local/bin && rm yazi yazi.zip && \
# Install LINUX lazygit from source
LAZYGIT_VERSION=$(curl -sL "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') && \
curl -sL https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz \
| tar xz lazygit && \
install lazygit /usr/local/bin && rm lazygit && \
# Install LINUX jq
JQ_VERSION=$(curl -sL "https://api.github.com/repos/jqlang/jq/releases/latest" | grep tag_name | cut -d '"' -f4) && \
curl -sLo jq https://github.com/jqlang/jq/releases/latest/download/jq-linux-amd64 && \
curl -sL https://github.com/jqlang/jq/releases/latest/download/${JQ_VERSION}.tar.gz | tar xz ${JQ_VERSION}/jq.1 --strip-components=1 && \
install jq /usr/local/bin && mv jq.1 /usr/local/share/man/man1 && rm jq && \
# Install zoxide
curl -sLS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash -s -- --bin-dir /usr/local/bin --man-dir /usr/local/share/man && \
RUN apk -q --no-progress --no-cache add sudo bash && \
# Create user
addgroup --gid $USER_GID $USERNAME && \
# Set Zsh as the default shell
Expand All @@ -83,64 +28,12 @@ RUN apk -q --no-progress --no-cache add \
# Set default user
USER $USERNAME
WORKDIR $HOME
# Setup dotfiles
COPY --chown=$USERNAME:$USERNAME install.sh $HOME/install.sh
COPY --chown=$USERNAME:$USERNAME tests /tmp/tests

SHELL ["/bin/bash", "-c"]

# Bootstrap
RUN \
# Create the top level directories before stowing so that stow does not symlink from the top level
mkdir -p $HOME/.config/{nvim,tmux,yazi,zsh} $HOME/.vim && \
# Stow the dotfiles
git clone -q --depth=1 https://github.com/mau-mauricelim/dotfiles.git $HOME/dotfiles && \
cd $HOME/dotfiles && git remote set-url origin [email protected]:mau-mauricelim/dotfiles.git && \
stow . && git restore . && cd $HOME && \
# Install local binaries
sudo install $HOME/dotfiles/bin/* /usr/local/bin && \
# Create a symlink for zshenv to HOME
ln -s $HOME/.config/zsh/.zshenv $HOME/.zshenv && \
# Source the latest zshenv
source $HOME/.zshenv && \
# Create ZDOTDIR and XDG_DATA_HOME directories
mkdir -p $ZDOTDIR $XDG_DATA_HOME/{nvim,vim}/{undo,swap,backup} && \
# Zsh Theme - Powerlevel10k (Requires manual font installation)
git clone -q --depth=1 https://github.com/romkatv/powerlevel10k.git $ZDOTDIR/powerlevel10k && \
# Zsh Auto Suggestions
git clone -q --depth=1 https://github.com/zsh-users/zsh-autosuggestions $ZDOTDIR/zsh-autosuggestions && \
# Zsh Syntax Highlighting
git clone -q --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git $ZDOTDIR/zsh-syntax-highlighting && \
# fzf
git clone -q --depth 1 https://github.com/junegunn/fzf.git $ZDOTDIR/fzf && \
$ZDOTDIR/fzf/install --xdg --no-update-rc --completion --key-bindings >/dev/null 2>&1 && \
# Vim syntax and indent
mkdir -p $HOME/.vim/{indent,syntax} && \
git clone -q --depth=1 https://github.com/katusk/vim-qkdb-syntax.git $HOME/.vim/vim-qkdb-syntax && \
ln -s $HOME/.vim/vim-qkdb-syntax/indent/{k,q}.vim $HOME/.vim/indent && \
ln -s $HOME/.vim/vim-qkdb-syntax/syntax/k.vim $HOME/.vim/syntax && \
git clone -q --depth=1 https://github.com/jshinonome/vim-q-syntax.git $HOME/.vim/vim-q-syntax && \
ln -s $HOME/.vim/vim-q-syntax/syntax/q.vim $HOME/.vim/syntax && \
# Symlink Vim syntax and indent files to Neovim
ln -s $HOME/.vim/indent $XDG_CONFIG_HOME/nvim && \
ln -s $HOME/.vim/syntax $XDG_CONFIG_HOME/nvim && \
# bash and zsh key bindings for Git objects, powered by fzf.
curl -sLo $XDG_CONFIG_HOME/fzf/fzf-git.sh https://raw.githubusercontent.com/junegunn/fzf-git.sh/main/fzf-git.sh && \
# TPM installation
# git clone -q --depth=1 https://github.com/tmux-plugins/tpm $XDG_CONFIG_HOME/tmux/plugins/tpm && $XDG_CONFIG_HOME/tmux/plugins/tpm/bin/install_plugins && \
# Install q language server for neovim
sudo npm --global i @jo.shinonome/qls && \
# Install yazi themes
git clone -q --depth=1 https://github.com/yazi-rs/flavors.git flavors && \
mkdir -p $XDG_CONFIG_HOME/yazi/flavors && \
mv flavors/*.yazi $XDG_CONFIG_HOME/yazi/flavors && rm -rf flavors && \
# Run Lazy install, clean and update non-interactively from command line
# nvim --headless '+Lazy! sync' +qa && \
RUN bash install.sh $INSTALL_TYPE && rm install.sh && \
# Run tests
source $HOME/.bashrc && \
echo -e "\n#########\n# TESTS #\n#########\n" && \
echo -e "\n#########\n# TESTS #\n#########\n" && \
for test in /tmp/tests/*.sh; do bash "$test"; done && \
rm -rf /tmp/tests && \
# Start zsh and exit (It'll allow powerlevel10k to do everything it needs to do on first run.)
echo exit | script -qec zsh /dev/null >/dev/null && \
# Clean up
sudo apk del util-linux-misc
rm -rf /tmp/tests
Loading

0 comments on commit 4e76c3e

Please sign in to comment.