From 991478a0b0444a4de231a8364334870a2b83e9db Mon Sep 17 00:00:00 2001 From: Pallav Vasa Date: Fri, 16 May 2025 23:28:39 +0000 Subject: [PATCH] feat: split images into 2 - base and workspace --- build-base.sh | 24 ++++++++++++++++++++++++ build-workspace.sh | 17 +++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) create mode 100755 build-base.sh diff --git a/build-base.sh b/build-base.sh new file mode 100755 index 0000000..fe1940d --- /dev/null +++ b/build-base.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -euo pipefail + +BASE_IMG_NAME="analytics-backend-base" +DEV_USER=devuser +DEV_UID=1001 +DEV_GID=1001 + +ctr=$(buildah from archlinux) + +buildah run "$ctr" -- bash -c " + pacman -Sy --noconfirm && \ + pacman -S --noconfirm --needed base-devel neovim git fish tmux \ + nodejs python podman fzf fd ripgrep jdk-openjdk fisher yazi less buildah \ + lazygit luarocks python-pynvim npm bash-completion tree-sitter-cli kitty-terminfo \ + lua51 openssh && \ + pacman -Scc --noconfirm && \ + groupadd -g $DEV_GID $DEV_USER && \ + groupadd -g 1002 secproc && \ + useradd -ms /bin/fish -G secproc -u $DEV_UID -g $DEV_GID $DEV_USER +" + +buildah commit "$ctr" $BASE_IMG_NAME +echo "✅ $BASE_IMG_NAME built." diff --git a/build-workspace.sh b/build-workspace.sh index 4152c4d..53cf163 100755 --- a/build-workspace.sh +++ b/build-workspace.sh @@ -1,22 +1,12 @@ #!/bin/bash - set -euo pipefail +BASE_IMG_NAME="analytics-backend-base" IMG_NAME="analytics-backend-workspace" DEV_USER=devuser -DEV_UID=1001 -DEV_GID=1001 DEV_HOME=/home/$DEV_USER -ctr=$(buildah from archlinux) - -buildah run "$ctr" -- bash -c "\ - pacman -Sy --noconfirm && pacman -S --noconfirm --needed base-devel neovim git fish tmux \ - nodejs python podman fzf fd ripgrep jdk-openjdk fisher yazi less buildah \ - lazygit luarocks python-pynvim npm bash-completion tree-sitter-cli kitty-terminfo \ - lua51 openssh && pacman -Scc --noconfirm && groupadd secproc && groupadd -g $DEV_GID $DEV_USER && \ - useradd -ms /bin/fish -G secproc -u $DEV_UID -g $DEV_GID $DEV_USER -" +ctr=$(buildah from "$BASE_IMG_NAME") buildah add "$ctr" home.tar.gz $DEV_HOME @@ -38,5 +28,4 @@ buildah config \ "$ctr" buildah commit "$ctr" $IMG_NAME - -echo "✅ $IMG_NAME built." +echo "✅ $IMG_NAME built from $BASE_IMG_NAME."