wm/in-container
2021-05-19 22:57:50 +03:00

24 lines
619 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
# 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
# ...
NAME=wm-mj-build
if [[ -z "$(docker images -q --filter "reference=$NAME")" ]]; then
docker build -t "$NAME" - < Dockerfile
fi
exec docker run -ti --rm \
--net=host \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(git rev-parse --show-toplevel):/x \
-w /x/$(basename ${PWD}) \
"$NAME" "$@"