From 4ee29dfb80a294f147a572fb303e3b3e611c9e8f Mon Sep 17 00:00:00 2001 From: Andy Galkin Date: Mon, 25 Nov 2024 16:59:01 -0800 Subject: [PATCH] Migrate to single setup file, inspired by tailscale setup script --- .github/README.md | 17 +++++++---------- .zshrc | 2 +- setup/1-base.sh | 8 -------- setup/2-minimal-config.sh | 19 ------------------- setup/3-dev.sh | 11 ----------- setup/4-gui-fonts.sh | 30 ------------------------------ setup/4-gui.sh | 12 ------------ setup/5-personal.sh | 10 ---------- setup/6-personal-gui.sh | 21 --------------------- setup/Dockerfile | 15 +++------------ 10 files changed, 11 insertions(+), 134 deletions(-) delete mode 100755 setup/1-base.sh delete mode 100755 setup/2-minimal-config.sh delete mode 100755 setup/3-dev.sh delete mode 100755 setup/4-gui-fonts.sh delete mode 100755 setup/4-gui.sh delete mode 100755 setup/5-personal.sh delete mode 100755 setup/6-personal-gui.sh diff --git a/.github/README.md b/.github/README.md index e499883..12b9b7a 100644 --- a/.github/README.md +++ b/.github/README.md @@ -23,13 +23,10 @@ Configuration: - [Dockerfile](setup/Dockerfile) - [Docker compose](setup/docker-compose.yml) -| Action | Minimal | -| ----------------------------------- | --------------------------------------------------------------------------------------------------------------- | -| Run from repository, docker | `docker run --rm -it galkkk/dotfiles:minimal` | -| Run from repository, docker compose | `docker compose run --rm dotfiles:minimal` | -| Build | `sudo docker buildx build --build-context setupscripts=setup --target minimal --tag dotfiles:minimal setup` | -| Run locally | `docker run -it docker.io/library/dotfiles:minimal` | -| Push to repository | docker tag dotfiles:minimal galkkk/dotfiles:minimal
docker image push galkkk/dotfiles:minimal
| - -TODO: Figure out if it is possible to move setup files to subdirectory and real dotfiles *into* parent directory. - That will require figuring out build context and may be not possible in general case. Unless I will figure out sub repositories or docker contexts, then it will work. \ No newline at end of file +| Action | Minimal | +| ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | +| Run from repository, docker | `docker run --rm -it galkkk/dotfiles:minimal` | +| Run from repository, docker compose | `docker compose run --rm dotfiles:minimal` | +| Build | `docker buildx build --build-context setupscripts=setup --target minimal --tag dotfiles:minimal --file setup/Dockerfile --progress=plain --no-cache .` | +| Run locally | `docker run -it docker.io/library/dotfiles:minimal` | +| Push to repository | docker tag dotfiles:minimal galkkk/dotfiles:minimal
docker image push galkkk/dotfiles:minimal
| \ No newline at end of file diff --git a/.zshrc b/.zshrc index 601746e..044de9f 100644 --- a/.zshrc +++ b/.zshrc @@ -82,7 +82,7 @@ zstyle ':autocomplete:*' widget-style menu-select zstyle ':autocomplete:*' list-lines 16 zstyle ':autocomplete:*' fzf-completion yes -zstyle ':completion:*:*' matcher-list 'm:{[:lower:]-}={[:upper:]_}' '+r:|[.]=**' +zstyle ':completion:*:*' matcher-list 'm:{[:lower:]-}={[:upper:]_}' '+r:|[.]=**' bindkey '^I' menu-complete bindkey "$terminfo[kcbt]" reverse-menu-complete diff --git a/setup/1-base.sh b/setup/1-base.sh deleted file mode 100755 index 26c0ef6..0000000 --- a/setup/1-base.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -# Do not skip fzf key bindings -echo "path-include=/usr/share/doc/fzf/examples/*" | tee -a /etc/dpkg/dpkg.cfg.d/excludes - -apt-get -qq update -apt-get -qq install --no-install-recommends ca-certificates zsh git vim fzf curl bat \ - unzip htop mc mosh tmux neovim ripgrep wget openssh-server jq pipx diff --git a/setup/2-minimal-config.sh b/setup/2-minimal-config.sh deleted file mode 100755 index 4b95a1a..0000000 --- a/setup/2-minimal-config.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -[ -f ~/.work.zshrc ] || touch ~/.work.zshrc -[ -d ~/.config ] || mkdir -p ~/.config -[ -d ~/.local/bin ] || mkdir -p ~/.local/bin - -# make top level symlinks to all files in dotfiles from home directory -# only if ~/project/dotfiles exists (not the case for docker container). -# all existing files are going to be backed up. -if [ -d ~/projects/dotfiles ]; then - ln -sfb $(find ~/projects/dotfiles/ -maxdepth 1 -mindepth 1 -type f -not -name '.dockerignore') ~ - ln -sfb $(find ~/projects/dotfiles/.config -maxdepth 1 -mindepth 1) ~/.config/ -fi - -# This runs all installation steps, needed for zsh and plugins -echo exit | script -qec "$(which zsh)" /dev/null - -# change shell to zsh using usermod -[ -z "$USER" ] || usermod -s "$(which zsh)" "$USER" diff --git a/setup/3-dev.sh b/setup/3-dev.sh deleted file mode 100755 index 0ea1495..0000000 --- a/setup/3-dev.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -apt-get -qq install --no-install-recommends \ - build-essential cmake python3-dev golang \ - strace podman podman-toolbox \ - openjdk-21-jdk clang lldb gcc g++ gdb rr - -# Let podman to get images from docker hub. -echo " -[registries.search] -registries = ['docker.io']" | tee -a /etc/containers/registries.conf diff --git a/setup/4-gui-fonts.sh b/setup/4-gui-fonts.sh deleted file mode 100755 index c730936..0000000 --- a/setup/4-gui-fonts.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash - -fnt update - -# Change to `fnt install` after https://github.com/alexmyczko/fnt/issues/30 is fixed -fonts=( anonymouspro \ - cousine \ - firacode \ - ibmplexmono \ - jetbrains-mono \ - barlowcondensed \ - sairaextracondensed \ - sofiasansextracondensed \ - stintultracondensed \ - azeretmono \ - victormono \ - robotomono \ - ) - -for font in "${fonts[@]}"; do - fnt install "$font" -done - -cd "$(mktemp -d)" || exit -wget https://github.com/ryanoasis/nerd-fonts/releases/latest/download/NerdFontsSymbolsOnly.zip -curl -s 'https://api.github.com/repos/be5invis/Iosevka/releases/latest' | jq -r ".assets[] | .browser_download_url" | grep SuperTTC-Iosevka | grep -v SS | xargs -n 1 curl -L -O --fail --show-error -unzip -j '*.zip' -mv ./*.ttf ./*.ttc ~/.fonts - -fc-cache -f -v diff --git a/setup/4-gui.sh b/setup/4-gui.sh deleted file mode 100755 index c5faba9..0000000 --- a/setup/4-gui.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -DEBIAN_FRONTEND=noninteractive apt-get -qq --no-install-recommends install \ - i3 rofi flameshot remmina xinit brightnessctl peek \ - copyq sway wdisplays krita kazam nemo ffmpegthumbnailer \ - ffmpegthumbnailer ffmpeg imagemagick xclip fnt - -# Install latest kitty -mkdir -p ~/.local/bin -curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin -ln -sf ~/.local/kitty.app/bin/kitty ~/.local/kitty.app/bin/kitten ~/.local/bin/ -update-alternatives --install /usr/bin/x-terminal-emulator x-terminal-emulator ~/.local/bin/kitty 50 diff --git a/setup/5-personal.sh b/setup/5-personal.sh deleted file mode 100755 index 7db91fa..0000000 --- a/setup/5-personal.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash - -# Things that shouldn't be installed at work, because they require custom binary downloads, custom repositories etc - -# Tailscale -curl -fsSL https://tailscale.com/install.sh | sh - -# Docker. -# Must be last as they have weird thing and require 20s sleep for non-interactive scripts -curl -fsSL https://get.docker.com | sh diff --git a/setup/6-personal-gui.sh b/setup/6-personal-gui.sh deleted file mode 100755 index 96808fa..0000000 --- a/setup/6-personal-gui.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env bash - -wget -O vscode.deb 'https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-x64' -apt-get -qq --no-install-recommends install ./vscode.deb -rm vscode.deb - -# easy way out for remote access, no need to do xrdp/vnc all the stuff. -# TODO(galk): consider doing some "proper" xrdp configuration later -wget https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb -apt-get -qq --no-install-recommends install ./chrome-remote-desktop_current_amd64.deb -rm chrome-remote-desktop_current_amd64.deb - -apt-get -qq --no-install-recommends install flatpak - -flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo -flatpak install -y flathub md.obsidian.Obsidian -flatpak install -y flathub com.jetbrains.IntelliJ-IDEA-Community -flatpak install -y flathub com.github.tchx84.Flatseal - -# to run brightnessctl without sudo -# usermod -aG video $USER diff --git a/setup/Dockerfile b/setup/Dockerfile index 011981e..c66471d 100644 --- a/setup/Dockerfile +++ b/setup/Dockerfile @@ -5,7 +5,7 @@ FROM ubuntu:rolling AS minimal COPY . /root/ # Using bind mount to not copy installation scripts to the container -RUN --mount=from=setupscripts,dst=/setupscripts/ /setupscripts/1-base.sh && /setupscripts/2-minimal-config.sh +RUN --mount=from=setupscripts,dst=/setupscripts/ /setupscripts/setup.sh WORKDIR /root/ CMD ["/bin/zsh"] @@ -13,15 +13,6 @@ CMD ["/bin/zsh"] # Stage 2 - full image FROM minimal as full -RUN --mount=from=setupscripts,dst=/setupscripts/ /setupscripts/3-dev.sh && /setupscripts/5-personal.sh +RUN --mount=from=setupscripts,dst=/setupscripts/ /setupscripts/setup.sh dev -CMD ["/bin/zsh"] - -# Stage 3 - gui image -FROM full as gui - -ENV DEBIAN_FRONTEND=noninteractive - -RUN --mount=from=setupscripts,dst=/setupscripts/ /setupscripts/4-gui.sh && /setupscripts/4-gui-fonts.sh && /setupscripts/6-personal-gui.sh - -CMD ["/bin/zsh"] +CMD ["/bin/zsh"] \ No newline at end of file