From d2bacf3f939f35f3220c5d92b8fb1be752be3270 Mon Sep 17 00:00:00 2001
From: "61825162+CaderIdris@users.noreply.github.com"
<61825162+CaderIdris@users.noreply.github.com>
Date: Wed, 22 Jan 2025 14:42:36 +0000
Subject: [PATCH] Added build script and yaml config
Problem:
- Lots of layers in image, making it quite large
Solution:
- Compress package install to a single step using a bash script
Added:
- packages.yml that replaces the txt files. States which packages to
install and groups them nicely, with optional documentation. Could
update README.md in future with this.
- uv package
Removed:
- Old txt files containing packages to install, now in yaml file
---
Dockerfile | 37 +-----
README.md | 132 ----------------------
files/tmp/packages.yml | 155 ++++++++++++++++++++++++++
files/tmp/packages/npm.pkg | 4 -
files/tmp/packages/pacman.pkg | 64 -----------
files/tmp/packages/pipx.pkg | 6 -
files/tmp/packages/yay.pkg | 7 --
files/tmp/scripts/install_packages.sh | 67 +++++++++++
8 files changed, 228 insertions(+), 244 deletions(-)
delete mode 100644 README.md
create mode 100644 files/tmp/packages.yml
delete mode 100644 files/tmp/packages/npm.pkg
delete mode 100644 files/tmp/packages/pacman.pkg
delete mode 100644 files/tmp/packages/pipx.pkg
delete mode 100644 files/tmp/packages/yay.pkg
create mode 100644 files/tmp/scripts/install_packages.sh
diff --git a/Dockerfile b/Dockerfile
index 994576c..2a6d371 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -12,36 +12,11 @@ COPY files/ /
# Upgrade packages
RUN \
- pacman -Syu --noconfirm
-RUN \
- while IFS= read -r pkg; do pacman -S --verbose --noconfirm $pkg; done < /tmp/packages/pacman.pkg
-
-# Create temp user for unpriveledged operations
-RUN \
- cp /etc/sudoers /etc/sudoers.bak && \
- useradd --no-create-home --shell=/bin/false build && \
- usermod -L build && \
- echo "build ALL = NOPASSWD: /usr/bin/pacman" >> /etc/sudoers
-
-# Install yay as temp user and install packages
-RUN mkdir -p /home/build/{.gnupg,.config/pacman} && chown -R build:users /home/build
-USER build
-RUN \
- bash /tmp/scripts/install_yay.sh
-RUN \
- while IFS= read -r pkg; do yay -S --noconfirm $pkg; done < /tmp/packages/yay.pkg
-
-USER root
-# Install pipx packages
-RUN \
- while IFS= read -r pkg; do PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install "$pkg"; done < /tmp/packages/pipx.pkg
-
-
-# Install npm packages
-RUN \
- while IFS= read -r pkg; do npm install -g $pkg; done < /tmp/packages/npm.pkg
+ pacman -Syu --verbose --noconfirm && pacman -S --verbose --noconfirm sudo base-devel yq git
+ # sudo is needed to run yay build and aur package installs as build user
+ # base-devel needed to build aur packages
+ # yq is installed to parse the packages.yml file
+ # git needed to install yay
-# Delete temp user
RUN \
- userdel build && \
- mv /etc/sudoers.bak /etc/sudoers
+ bash /tmp/scripts/install_packages.sh
diff --git a/README.md b/README.md
deleted file mode 100644
index e427955..0000000
--- a/README.md
+++ /dev/null
@@ -1,132 +0,0 @@
-
- datblygiad
-
-
-[![Publish image](https://github.com/CaderIdris/datblygiad/actions/workflows/build.yml/badge.svg)](https://github.com/CaderIdris/datblygiad/actions/workflows/build.yml)
-
----
-
-## Table of Contents
-
-1. [Summary](##summary)
-2. [Packages](##packages)
- 1. [Utility](###utility)
- 1. [Programming Languages](###programming-languages)
- 1. [Documents](###documents)
- 1. [Customisation](###customisation)
- 1. [Containers](###containers)
-
----
-
-## Summary
-
-Datblygiad (EN: development) is an Arch Linux based container designed to be used in a development environment.
-It installs multiple packages from the Arch repositories, PyPI (via pipx) and npm.
-It also uses packages from the AUR by using yay.
-It is intended to be used with distrobox but can be used as a docker or podman container as well.
-
----
-
-## Packages
-
-### Utility
-
-|Name|Repository|Use|
-|---|---|---|
-|neovim|pacman|Text editor|
-|zsh|pacman|Shell|
-|tmux|pacman|Add tabs to terminal|
-|curl|pacman|Download files using command line|
-|git|pacman|Version control|
-|bat|pacman|Display text files in terminal with formatting|
-|exa|pacman|Replacement for ls|
-|npm|pacman|Download packages from npm|
-|ripgrep|pacman|Replacement for grep|
-|lf|pacman|CLI file browser|
-|libnotify|pacman|Sends notifications to host|
-|python-pipx|pacman|Package manager for PyPI|
-|tldr|pacman|Short man pages|
-|ctags|pacman|Used to get tags from scripts|
-|unixodbc|pacman|ODBC drivers|
-|bottom|pacman|CLI process/system monitor with graphs|
-|zathura|pacman|PDF viewer|
-|zathura-pdf-poppler|pacman|PDF plugin for Zathura|
-|wezterm|pacman|Terminal|
-|sqlitebrowser|pacman|View sqlite files|
-|direnv|pacman|Automatically loads environmental variables from whitelisted .env files when switching directories in terminal|
-|just|pacman|Alternative to make|
-|ruff-lsp|pacman|LSP for python linting|
-|nushell|pacman|Alternative shell, great for reading data files|
-|zoxide|pacman|Terminal navigation|
-|jq|pacman|Parses json files|
-|yq|pacman|Parses yaml, toml and xml files|
-|qemu-full|pacman|VM backend|
-|samba|pacman|File sharing|
-|acpi|pacman|Used to monitor battery in tmux|
-|vifm|pacman|Terminal based file browser|
-|vscodium-bin|aur|Open version of VSCode|
-|azure-cli|aur|Interact with azure services from CLI|
-|azure-functions-core-tools-bin|aur|Build, test and publish azure functions from CLI|
-|msodbcsql17|aur|SQL Server driver|
-|ctpv-git|aur|Image previews for lf|
-|quickgui-bin|aur|VM manager|
-|asciinema|PyPI|Record terminal to file for playback|
-|cookiecutter|PyPI|Create directories with templates|
-|pipenv|PyPI|Python virtual environments with built-in dependency management|
-|jrnl|PyPI|Simple journal app for command line|
-|termtosvg|PyPI|Output terminal to svg file|
-|azurite|npm|Emulate azure storage|
-
-
-### Programming Languages
-
-|Name|Repository|Use|
-|---|---|---|
-|python|pacman|Python|
-|rustup|pacman|Rust|
-|lua|pacman|Lua|
-|processing|aur|Processing 4 + IDE|
-|python39|pacman|Python 3.9|
-|python310|pacman|Python 3.10|
-|python312|pacman|Python 3.12|
-
-## Documents
-|Name|Repository|Use|
-|---|---|---|
-|texlive-meta|pacman|LaTeX and multiple packages|
-|biber|pacman|LaTeX reference tool|
-|pandoc|pacman|Text file converter|
-|pandoc-crossref|pacman|Cross reference filter|
-|jabref-bin|aur|Bibliography manager|
-|ttf-twemoji|aur|Emoji font|
-|@marp-team/marp-cli|npm|Presentations from markdown files|
-|markdown-preview|npm|Show markdown file in browser|
-|browser-sync|npm|Host html file locally|
-
-### Customisation
-
-|Name|Repository|Use|
-|---|---|---|
-|starship|pacman|Shell prompt|
-|figlet|pacman|Text to ascii art|
-|chezmoi|pacman|Manage dotfiles|
-|neofetch|pacman|Display system info|
-|lolcat|pacman|Colour text in terminal|
-|cowsay|pacman|Style text in terminal|
-|ttf-linux-libertine|pacman|Libertine font for LaTeX|
-|otf-comicshanns-nerd|pacman|ComicShanns font for terminal|
-|ttf-jetbrains-mono-nerd|pacman|JetBrains Mono font for LaTeX/terminal|
-|toilet|aur|Text to coloured ascii art|
-
-
-### Containers
-
-|Name|Repository|Use|
-|---|---|---|
-|docker|pacman|Docker commands. Will not work in container, communicates with host|
-|docker-buildx|pacman|Docker-buildx commands. Will not work in container, communicates with host|
-|podman|pacman|Podman commands. Will not work in container, communicates with host|
-
-
-
-
diff --git a/files/tmp/packages.yml b/files/tmp/packages.yml
new file mode 100644
index 0000000..b8f3826
--- /dev/null
+++ b/files/tmp/packages.yml
@@ -0,0 +1,155 @@
+pacman: # Install packages from the official ArchLinux repositories
+ system:
+ # Anything that relates to the system.
+ # This includes libraries, essential tools and package managers.
+ curl:
+ __doc__: "Transfer data to and from remote server."
+ libnotify:
+ __doc__: "Sends desktop notifications to a notification daemon. Useful when using shell plugins that notify when commands complete."
+ tk:
+ __doc__: "Cross platform widget toolkit to build/use simple GUIs"
+ unixodbc:
+ __doc__: "Access data sources that use ODBC API"
+ python-pipx:
+ __doc__: "Package manager for installing python packages"
+ npm:
+ __doc__: "Package manager for installing node packages"
+
+ terminal_dev_tools:
+ # Anything useful for general development.
+ direnv:
+ __doc__: "Autoload .env files in root directory if explicitly whitelisted by user."
+ just:
+ __doc__: "Project/directory specific command runner"
+ ripgrep:
+ __doc__: "Faster grep"
+ tmux:
+ __doc__: "Terminal multiplexer, useful for multiple tabs/split terminal/keeping sessions persistent"
+ tig:
+ __doc__: "TUI for git"
+ nushell:
+ __doc__: "Non-POSIX shell focused on manipulating data"
+ zsh:
+ __doc__: "Easily customisable shell"
+ bottom:
+ __doc__: "System monitor TUI"
+ man-db:
+ __doc__: "Manual for commands"
+ tldr:
+ __doc__: "Simple man pages"
+ pass:
+ __doc__: "Encrypted local password manager for CLI applications"
+ zoxide:
+ __doc__: "cd replacement that can use shortened paths."
+
+ terminal_pretty:
+ # Anything that makes the terminal nicer.
+ figlet:
+ __doc__: "Fancy ascii text."
+ bat:
+ __doc__: "Fancy cat designed to output nice looking documents."
+ exa:
+ __doc__: "Fancy ls."
+ fastfetch:
+ __doc__: "Outputs system information into terminal"
+ libsixel:
+ __doc__: "Used to show images in terminal."
+ glow:
+ __doc__: "Render markdown documents in the terminal."
+ lolcat:
+ __doc__: "Colour text in terminal."
+ cowsay:
+ __doc__: "Make a cow say something."
+
+ text_editors:
+ # Text editors and related tools.
+ neovim:
+ __doc__: "Lua-configured text editor based on VIM."
+ tree-sitter-cli:
+ __doc__: "Parses text documents. Used by Neovim plugins for a range of purposes."
+ silicon:
+ __doc__: "Render code to fancy screenshots."
+ ctags:
+ __doc__: "Parse code for tags representing different objects (e.g. functions, classes, variables)"
+
+ latex:
+ # LaTeX and related tools.
+ texlive-meta:
+ __doc__: "Just about any LaTeX package you could ever need."
+ biber:
+ __doc__: "Bibliography manager for LaTeX."
+ zathura:
+ __doc__: "Show pdfs."
+ zathura-pdf-poppler:
+ __doc__: "Let Zathura actually show PDFs."
+ pandoc:
+ __doc__: "Convert documents from one format to another (e.g Tex to DOCx)."
+ pandoc-crossref:
+ __doc__: "Plugin to aid referencing when using pandoc."
+ inkscape:
+ __doc__: "Convert images to different formats."
+
+ python:
+ # Python and related tools.
+ python:
+ __doc__: "Python programming language."
+ pyenv:
+ __doc__: "Manage python versions."
+ ruff-lsp:
+ __doc__: "Language server for Python."
+ uv:
+ __doc__: "Fast virtual environment manager for Python."
+
+ rust:
+ # Rust and related tools.
+ rustup:
+ __doc__: "Manage rust installations."
+
+ lua:
+ # Lua and related tools.
+ lua:
+ __doc__: "Lua programming language."
+
+ customisation:
+ # Customisation of environment.
+ chezmoi:
+ __doc__: "Sync dotfiles with remote repository."
+
+ fonts:
+ # Just fonts 🤷
+ otf-comicshanns-nerd:
+ __doc__: "Comic Shanns font patched with NerdFont symbols."
+ ttf-jetbrains-mono-nerd:
+ __doc__: "Jetbrains Mono font patched with Nerdfont symbols."
+ ttf-linux-libertine:
+ __doc__: "Linux Libertine font."
+
+npm: # Install packages from npm
+
+ local_webserver:
+ # Webservers for local development
+ "@mryhryki/markdown-preview":
+ __doc__: "Preview markdown files in the browser with live updating."
+ browser-sync:
+ __doc__: "Preview webpages in the browser with live updating."
+
+pypi: # Install tools from PyPI. Currently installed using pipx.
+ terminal_tools:
+ # Tools used in the terminal
+ asciinema:
+ __doc__: "Record terminal."
+ termtosvg:
+ __doc__: "Convert terminal output to svg."
+ cookiecutter:
+ __doc__: "Customisable directory/project templating tool."
+
+ package_manager:
+ # Other package managers
+ pipenv:
+ __doc__: "Useful package manager for Python projects. Slowly migrating to uv though as it can be slow."
+
+aur: # Install from the AUR, currently using yay
+ fonts:
+ # Just fonts 🤷
+ ttf-twemoji:
+ __doc__: "Emoji. That's it."
diff --git a/files/tmp/packages/npm.pkg b/files/tmp/packages/npm.pkg
deleted file mode 100644
index 5fe3c3d..0000000
--- a/files/tmp/packages/npm.pkg
+++ /dev/null
@@ -1,4 +0,0 @@
-@marp-team/marp-cli
-@mryhryki/markdown-preview
-browser-sync
-azurite
diff --git a/files/tmp/packages/pacman.pkg b/files/tmp/packages/pacman.pkg
deleted file mode 100644
index 349b3ab..0000000
--- a/files/tmp/packages/pacman.pkg
+++ /dev/null
@@ -1,64 +0,0 @@
-sudo
-base-devel
-blas-openblas
-neovim
-zsh
-python
-pyenv
-rustup
-lua
-tmux
-figlet
-chezmoi
-curl
-git
-bat
-exa
-fastfetch
-npm
-ripgrep
-texlive-meta
-biber
-ttf-linux-libertine
-otf-comicshanns-nerd
-ttf-jetbrains-mono-nerd
-libnotify
-pandoc
-pandoc-crossref
-python-pipx
-tldr
-lolcat
-cowsay
-ctags
-podman
-docker
-docker-buildx
-unixodbc
-bottom
-zathura
-sqlitebrowser
-zathura-pdf-poppler
-direnv
-just
-ruff-lsp
-nushell
-yq
-jq
-zoxide
-samba
-acpi
-vifm
-gnupg
-pass
-libsixel
-silicon
-pscslite
-ccid
-opensc
-pcsc-tools
-inkscape
-glow
-tree-sitter-cli
-fzf
-tig
-tk
diff --git a/files/tmp/packages/pipx.pkg b/files/tmp/packages/pipx.pkg
deleted file mode 100644
index 5e459a5..0000000
--- a/files/tmp/packages/pipx.pkg
+++ /dev/null
@@ -1,6 +0,0 @@
-asciinema
-cookiecutter
-pipenv
-jrnl
-termtosvg
-huggingface_hub[cli]
diff --git a/files/tmp/packages/yay.pkg b/files/tmp/packages/yay.pkg
deleted file mode 100644
index b08259a..0000000
--- a/files/tmp/packages/yay.pkg
+++ /dev/null
@@ -1,7 +0,0 @@
-processing
-msodbcsql17
-jabref-bin
-ttf-twemoji
-pass-git-helper
-llama.cpp-vulkan
-slides
diff --git a/files/tmp/scripts/install_packages.sh b/files/tmp/scripts/install_packages.sh
new file mode 100644
index 0000000..6f9ce7c
--- /dev/null
+++ b/files/tmp/scripts/install_packages.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+PKGS_YML_PATH=/tmp/packages.yml
+
+# PACMAN
+echo "Installing packages from pacman"
+PACMAN_PKG_GROUPS=$(yq -r '.pacman | keys | @sh' $PKGS_YML_PATH | tr -d \')
+
+echo $PACMAN_PKG_GROUPS
+for grp in $PACMAN_PKG_GROUPS
+do
+ echo "Group: ${grp}"
+ packages=$(yq -r ".pacman.${grp} | keys | @sh" $PKGS_YML_PATH | tr -d \'\")
+ pacman -S --verbose --noconfirm $packages
+done
+echo "Pacman packages installed"
+echo "---"
+
+# NPM
+echo "Installing packages from npm"
+NPM_PKG_GROUPS=$(yq -r '.npm | keys | @sh' $PKGS_YML_PATH | tr -d \')
+for grp in $NPM_PKG_GROUPS
+do
+ echo "Group: ${grp}"
+ packages=$(yq -r ".npm.${grp} | keys | @sh" $PKGS_YML_PATH | tr -d \'\")
+ npm install -g $packages
+done
+echo "npm packages installed"
+echo "---"
+
+PYPI_PKG_GROUPS=$(yq -r '.pypi | keys' $PKGS_YML_PATH)
+for grp in $PYPI_PKG_GROUPS
+do
+ echo "Group: ${grp}"
+ packages=$(yq -r ".pypi.${grp} | keys | @sh" $PKGS_YML_PATH | tr -d \'\")
+ PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install $packages
+done
+echo "PyPI packages installed"
+echo "---"
+
+AUR_PKG_GROUPS=$(yq -r '.aur | keys' $PKGS_YML_PATH)
+# Create temporary build user to install yay
+echo "Setting up build user"
+cp /etc/sudoers /etc/sudoers.bak
+useradd --no-create-home --shell=/bin/false build
+usermod -L build
+echo "build ALL = NOPASSWD: /usr/bin/pacman" >> /etc/sudoers
+mkdir -p /home/build/{.gnupg,.config/pacman}
+chown -R build:users /home/build
+
+echo "Installing yay"
+sudo -u build bash /tmp/scripts/install_yay.sh
+
+echo "Installing packages from AUR"
+for grp in $AUR_PKG_GROUPS
+do
+ echo "Group: ${grp}"
+ packages=$(yq -r ".aur.${grp} | keys | @sh" $PKGS_YML_PATH | tr -d \'\")
+ sudo -u build yay -S --noconfirm $packages
+done
+echo "aur packages installed"
+
+echo "Deleting build user"
+userdel build
+mv /etc/sudoers.bak /etc/sudoers
+echo "---"
+