69 lines
1.7 KiB
Bash
Executable File
69 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
##########################################################################
|
|
IMAGE='lgregmapper'
|
|
echo "Building ${IMAGE} container"
|
|
|
|
# find the source directory
|
|
SCRIPTPATH="$(cd "$(dirname "$0")" ; pwd -P)"
|
|
SOURCEPATH="$(cd "${SCRIPTPATH}/../"; pwd -P)"
|
|
echo "Source is in: ${SOURCEPATH}"
|
|
|
|
##########################################################################
|
|
|
|
DEPS=(
|
|
'ca-certificates'
|
|
)
|
|
B=$(which buildah)
|
|
|
|
# initialise container
|
|
c=$(buildah from --name ${IMAGE}-working docker.io/debian:buster)
|
|
|
|
##########################################################################
|
|
|
|
# install dependencies and initialise directories
|
|
$B run $c -- bash <<EOF
|
|
apt-get -y update
|
|
apt-get -y install --no-install-recommends ${DEPS[@]}
|
|
rm -r /var/lib/apt/lists
|
|
EOF
|
|
|
|
# mount the container
|
|
m=$($B mount $c)
|
|
|
|
cpath="${m}/usr/local/share/ca-certificates/burble.dn42"
|
|
mkdir "$m/app" "${cpath}"
|
|
|
|
curl -o "${cpath}/ca-burble-dn42.crt" \
|
|
'https://dn42.burble.com/home/certificate-authority/certs/ca-burble-dn42.pem'
|
|
$B run $c -- /usr/sbin/update-ca-certificates
|
|
|
|
cp ${SOURCEPATH}/contrib/entrypoint.sh ${m}/app/
|
|
chmod +x ${m}/app/entrypoint.sh
|
|
|
|
# build the binary directly in to the container
|
|
pushd "$m/app"
|
|
"$SOURCEPATH/contrib/build.sh"
|
|
popd
|
|
|
|
# unmount the container
|
|
$B unmount $c
|
|
|
|
# configure
|
|
buildah config \
|
|
--author="Simon Marsh" \
|
|
--workingdir='/app' \
|
|
--cmd='/app/entrypoint.sh' \
|
|
$c
|
|
|
|
##########################################################################
|
|
# finally create the image
|
|
|
|
echo "Committing image ..."
|
|
i=$($B commit --squash $c ${IMAGE})
|
|
|
|
# clean up
|
|
$B rm $c
|
|
|
|
##########################################################################
|
|
# end of file
|