2021-05-09 16:51:54 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
2021-05-09 17:11:54 +03:00
|
|
|
# Prefix the 'make <...>' with this script to build the artifact in an isolated
|
|
|
|
# container. This means host dependencies can only be Docker and a shell (to
|
|
|
|
# run this script).
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
# ./in-container make help
|
|
|
|
# ./in-container make -j mj-msc-full.pdf
|
|
|
|
# ...
|
2021-05-09 16:51:54 +03:00
|
|
|
|
2021-05-09 17:11:54 +03:00
|
|
|
NAME=wm-mj-build
|
2021-05-09 16:51:54 +03:00
|
|
|
if [[ -z "$(docker images -q --filter "reference=$NAME")" ]]; then
|
2021-05-09 19:28:35 +03:00
|
|
|
docker build -t "$NAME" .
|
2021-05-09 16:51:54 +03:00
|
|
|
fi
|
|
|
|
|
2021-05-09 16:58:17 +03:00
|
|
|
exec docker run -ti --rm \
|
|
|
|
--net=host \
|
2021-05-09 16:51:54 +03:00
|
|
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
2021-05-09 17:03:40 +03:00
|
|
|
-v $(git rev-parse --show-toplevel):/x \
|
|
|
|
-w /x/$(basename ${PWD}) \
|
2021-05-09 16:51:54 +03:00
|
|
|
"$NAME" "$@"
|