in-container (562B) - Raw
1 #!/bin/bash 2 set -euo pipefail 3 4 # Prefix the 'make <...>' with this script to build the artifact in an isolated 5 # container. This means host dependencies can only be Docker and a shell (to 6 # run this script). 7 # 8 # Usage: 9 # ./in-container make help 10 # ./in-container make -j2 mj-msc-full.pdf 11 # ... 12 13 NAME=wm-mj-build 14 if [[ -z "$(docker images -q --filter "reference=$NAME")" ]]; then 15 docker build -t "$NAME" . 16 fi 17 18 exec docker run -ti --rm \ 19 --net=host \ 20 -v /var/run/docker.sock:/var/run/docker.sock \ 21 -v ${PWD}:/x \ 22 -w /x \ 23 "$NAME" "$@"