buildxargs: xargs for BuildKit

A specialization of vixargs for docker build commands.

Fork buildxargs!

❯ cargo install --git https://github.com/fenollp/buildxargs

# export DOCKER_HOST=ssh://much.oomphr.dev
❯ buildxargs <<EOF
docker build --build-arg ARGs='--format mp4 -- https://www.youtube.com/watch?v=Hj7LwZqTflc' --output=$HOME https://github.com/fenollp/dockerhost-tools--yt-dlp.git#main
docker build -o=. --platform=local --build-arg PREBUILT=1 https://github.com/FuzzyMonkeyCo/monkey.git
docker build --platform=local -o . https://github.com/docker/buildx.git
EOF

Player seems out of frame and/or text looks squashed? Please head over here.


For instance here’s a script for concurrent video downloads:

#!/bin/bash -eu

[[ $# -eq 0 ]] && echo "Usage: $0  <URL>+" && exit 1

repo=https://github.com/fenollp/dockerhost-tools--yt-dlp.git#main
# TODO: once https://github.com/moby/moby/pull/42968 is in docker-ce:
#repo=https://github.com/fenollp/dockerhost-tools.git#:yt-dlp

commands=''
for ((i=1; i<=$#; i++)); do
    url="${!i}"

    ARGs="$url"
    if [[ "$url" = *youtube* ]]; then
        ARGs="--format mp4 -- $url"
    fi
    commands+=$(printf "docker build --build-arg ARGs='%s' --output=$HOME/ %s" "$ARGs" "$repo")
    commands+=$'\n'
done

if [[ "${DOCKER_HOST-unset}" = 'unset' ]]; then
    export DOCKER_HOST=ssh://oomphy
fi

buildxargs <<<"$commands"

docker builder prune --keep-storage 20000000000 -f