bladerunner/packer/run-docker.sh

22 lines
524 B
Bash
Raw Normal View History

#!/usr/bin/env bash
set -euxo pipefail
PACKER_IMAGE_NAME="bladerunner/packer:latest"
2023-04-12 08:01:57 +00:00
FORCE_DOCKER_BUILD="${FORCE_DOCKER_BUILD:-no}"
preflight () {
2023-04-12 08:01:57 +00:00
if [ "${FORCE_DOCKER_BUILD}" = "yes" -o -z "$(docker image ls -q ${PACKER_IMAGE_NAME})" ]
then
docker image build -t "${PACKER_IMAGE_NAME}" .
fi
}
run_image () {
# privileged is required for loopback devices
docker run --privileged=true -i -t -v build:/packer/build -v /dev:/dev ${PACKER_IMAGE_NAME} -c "./build-image.sh"
}
preflight
run_image