#!/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 git-lfs 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."