feat: various modifications

- Default ubuntu user is removed
- Can add apt packages during image building with --apt-packages="list
  of pkg"
- Remove and/or prune podman image option
- Fix condition checks
This commit is contained in:
Ian
2026-10-04 15:42:03 +02:00
parent e95d6fa3bd
commit 35dcc67e6a
4 changed files with 39 additions and 65 deletions
+27 -2
View File
@@ -6,33 +6,58 @@ cd "$SCRIPT_DIR"
UBUNTU_VERSION="${UBUNTU_VERSION:-26.04}"
NODE_VERSION="${NODE_VERSION:-24.21.0}"
OPENCODE_VERSION="${OPENCODE_VERSION:-2.0.3}"
OPENCODE_VERSION="${OPENCODE_VERSION:-2.0.22}"
IMAGE="${IMAGE_REPO:-localhost/opencode-dev}"
usage() {
echo "Usage: $0 [--no-cache] [--update] [--dry-run]"
echo 'Usage: $0 [--no-cache] [--update] [--dry-run] [--remove] [--prune] [--apt-packages="pack1 pack2"]'
exit 2
}
BUILD_OPTS=()
DRY_RUN=0
REMOVE=0
PRUNE=0
# EXTRA_APT_PACKAGES="${EXTRA_APT_PACKAGES:-}"
EXTRA_APT_PACKAGES=()
while (($#)); do
case "$1" in
--no-cache) BUILD_OPTS+=(--no-cache) ;;
--update) BUILD_OPTS+=(--no-cache --pull=newer) ;;
--dry-run) DRY_RUN=1 ;;
--remove) REMOVE=1 ;;
--prune) PRUNE=1 ;;
--apt-packages=*)
read -ra _pkgs <<< "${1#*=}"
EXTRA_APT_PACKAGES="${_pkgs[@]}" ;;
-h|--help) usage ;;
*) echo "Unknown option: $1" >&2; usage ;;
esac
shift
done
if [[ -n "${EXTRA_APT_PACKAGES[@]}" ]]; then
echo "--> Apt extra pkg: ${EXTRA_APT_PACKAGES[*]}"
fi
if ((REMOVE || PRUNE)); then
if ((REMOVE)); then
podman image rm "${IMAGE}" 2>/dev/null
fi
if ((PRUNE)); then
podman image prune -f 2>/dev/null
fi
exit 0
fi
CMD=(
podman build
"${BUILD_OPTS[@]}"
--build-arg "UBUNTU_VERSION=${UBUNTU_VERSION}"
--build-arg "NODE_VERSION=${NODE_VERSION}"
--build-arg "OPENCODE_VERSION=${OPENCODE_VERSION}"
--build-arg "EXTRA_APT_PACKAGES=${EXTRA_APT_PACKAGES[*]}"
--build-arg "DEV_UID=$(id -u)"
--build-arg "DEV_GID=$(id -g)"
-t "$IMAGE"