2 stable releases

new 1.3.0 Jan 11, 2025
1.2.0 Nov 20, 2023

#243 in Unix APIs

Download history 4/week @ 2024-09-24 6/week @ 2024-10-01 1/week @ 2024-10-08 1/week @ 2024-10-15 1/week @ 2024-10-29 1/week @ 2024-11-05 125/week @ 2025-01-07

125 downloads per month

MIT license

19KB
311 lines

buildxargs ~ xargs for BuildKit with docker buildx bake

An efficient way of running multiple concurrent docker build jobs on the BuildKit toolkit.

# export DOCKER_HOST=ssh://...
❯ 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
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

This is equivalent to executing the following

 export DOCKER_BUILDKIT=1
 xargs -P0 -o -I{} {} <<EOF
docker build ...
docker build ...
...
docker build ...
EOF

Usage

xargs for BuildKit with docker buildx bake

Usage: buildxargs [OPTIONS]

Options:
      --allow <ALLOW>        Allow build to access specified resources
  -f, --file <FILE>          Read commands from file [default: -]
      --no-cache             Do not use cache when building the image
      --print                Print the options without building
      --progress <PROGRESS>  Set type of progress output ("plain", "tty") [default: auto]
      --pull                 Always attempt to pull all referenced images
      --debug                Print more things
      --retry <RETRY>        Retry each failed build at most this many times [default: 3]
  -h, --help                 Print help
  -V, --version              Print version

Installing

cargo install --locked --git https://github.com/fenollp/buildxargs
# also: install Docker ≥ 18.09

See also

My blog post about this.

Related:

  • My vi[sual]xargs tool
  • fmtd and a lib for piping data in & out of docker build tasks

TODO

  • Spawn tasks in background, attach to display logs, cancel.
OPTIONS:
        --attach ssh HOST -t /usr/bin/htop + replay daemon logs
        --background Spawns calls using bg daemon and logs text back for log replain

Dependencies

~3–12MB
~153K SLoC