bazel: remote oci rules, packer building

Container building in Bazel seems like a dead end right now. This is
removed.

I'm splitting out a separate packer build script from the run-docker
script.
This commit is contained in:
2023-04-11 13:41:16 -07:00
parent 3534b1274f
commit 798c634aa6
4 changed files with 44 additions and 57 deletions

View File

@@ -3,6 +3,12 @@
This directory contains the tooling to build raspberry pi images using
packer.
- `install-packer.sh` will set up packer and packer-builder-arm. It will
also install additional dependencies assuming a Debian-ish system. This
is mostly intended for use in containers, as my Ansible config should
cover this for hardware.
- `run-docker.sh` runs the builder in Docker.
### Resources

37
packer/build-image.sh Normal file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -euxo pipefail
IMAGE_TYPE="${1:-ubuntu}"
PACKER_BUILD_FILE=
errmsg () {
echo "$@" > /dev/stderr
}
preflight () {
case "${IMAGE_TYPE}" in
ubuntu) PACKER_BUILD_FILE="boards/raspberry-pi-4/ubuntu_server_20.04_arm64.json" ;;
raspbian) PACKER_BUILD_FILE="boards/raspberry-pi/raspios-lite-arm.json" ;;
custom)
PACKER_BUILD_FILE="${2:-}"
if [ -z "${PACKER_BUILD_FILE}" ]
then
errmsg "[!] custom board requires a board file path"
exit 1
fi
;;
*)
errmsg "[!] invalid image type ${IMAGE_TYPE}."
errmsg "[!] valid image types are"
errmsg " - raspbian"
errmsg " - ubuntu"
errmsg " - custom path/to/board/file"
exit 1
;;
esac
}
build_image () {
packer build ${PACKER_BUILD_FILE}
}

View File

@@ -2,46 +2,18 @@
set -euxo pipefail
IMAGE_TYPE="${1:-ubuntu}"
PACKER_IMAGE_NAME="bladerunner/packer:latest"
PACKER_BUILD_FILE=
errmsg () {
echo "$@" > /dev/stderr
}
preflight () {
case "${IMAGE_TYPE}" in
ubuntu) PACKER_BUILD_FILE="boards/raspberry-pi-4/ubuntu_server_20.04_arm64.json" ;;
raspbian) PACKER_BUILD_FILE="boards/raspberry-pi/raspios-lite-arm.json" ;;
custom)
PACKER_BUILD_FILE="${2:-}"
if [ -z "${PACKER_BUILD_FILE}" ]
then
errmsg "[!] custom board requires a board file path"
exit 1
fi
;;
*)
errmsg "[!] invalid image type ${IMAGE_TYPE}."
errmsg "[!] valid image types are"
errmsg " - raspbian"
errmsg " - ubuntu"
errmsg " - custom path/to/board/file"
exit 1
;;
esac
if [ -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 "packer build ${PACKER_BUILD_FILE}"
docker run --privileged=true -i -t -v build:/packer/build -v /dev:/dev ${PACKER_IMAGE_NAME} -c "./build-image.sh"
}
preflight