ansible skeleton, tweaking packer Docker build.

This commit is contained in:
2023-04-10 23:02:14 -07:00
parent 1fda2a7dd2
commit 3534b1274f
9 changed files with 102 additions and 3 deletions

View File

@@ -2,12 +2,14 @@
FROM ubuntu:22.04
LABEL org.opencontainers.image.authors=kyle@imap.cc
RUN apt-get update && apt-get -y install git curl sudo
RUN apt-get update && apt-get -y install git curl sudo xz-utils
RUN git clone https://git.wntrmute.dev/kyle/bladerunner
RUN bladerunner/tools/install-go.sh
ADD . packer
WORKDIR packer
VOLUME build
RUN ./install-packer.sh
WORKDIR build/packer-builder-arm
ENTRYPOINT ["/usr/bin/env", "bash"]

View File

@@ -8,11 +8,12 @@ ARCH=amd64
PACKER_FILE=packer_${PACKER_VERSION}_linux_${ARCH}
UPSTREAM="https://github.com/mkaczanowski/packer-builder-arm"
UPGRADE="false"
BUILD_DIR="$(pwd)/build"
prep () {
sudo apt-get update && sudo apt-get -y install git unzip qemu-user-static e2fsprogs dosfstools 'bsdtar|libarchive-tools'
mkdir -p build
pushd build
mkdir -p ${BUILD_DIR}
pushd ${BUILD_DIR}
}
install_packer () {

48
packer/run-docker.sh Executable file
View File

@@ -0,0 +1,48 @@
#!/usr/bin/env bash
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}"
}
preflight
run_image