devbox/build-image.fish
2026-07-11 21:44:19 -07:00

54 lines
1.5 KiB
Fish

# Build script for the devcontainer image.
set -f DEFAULT_TAG 'devbox:questing'
set -f DEFAULT_BASE 'ubuntu:25.10'
set -f DEFAULT_USERNAME brent
set -f DEFAULT_FULL_NAME 'Brent Schroeter'
argparse -S 'b/base=' 't/tag=' 'u/username=' 'email=' 'full-name=' 'runtime=' no-cache -- $argv
or return 1
if not set -ql _flag_tag
set -f _flag_tag "$DEFAULT_TAG"
end
if not set -ql _flag_base
set -f _flag_base "$DEFAULT_BASE"
end
if not set -ql _flag_username
set -f _flag_username "$DEFAULT_USERNAME"
end
if not set -ql _flag_full_name
set -f _flag_full_name "$DEFAULT_FULL_NAME"
end
if not set -ql _flag_email
echo '--email is required for VCS configuration' >&2
return 1
end
if not set -ql _flag_runtime
set -f _flag_runtime container
end
if test "$_flag_runtime" != docker -a "$_flag_runtime" != container
echo '--runtime must be one of "docker" or "container"'
return 1
end
echo "Build configuration:"
echo " base = $_flag_base"
echo " tag = $_flag_tag"
echo " username = $_flag_username"
echo " email = $_flag_email"
echo " full name = $_flag_full_name"
echo " container runtime = $_flag_runtime"
set -ef no_cache_opt
if set -ql _flag_no_cache
set -f no_cache_opt --no-cache
end
$_flag_runtime build $no_cache_opt -t "$_flag_tag" \
--build-arg "BASE_IMAGE=$_flag_base" \
--build-arg "USERNAME=$_flag_username" \
--build-arg "VCS_EMAIL=$_flag_email" \
--build-arg "VCS_NAME=$_flag_full_name" \
-f Containerfile \
.