66 lines
1.5 KiB
Bash
66 lines
1.5 KiB
Bash
|
#!/bin/bash
|
||
|
##########################################################################
|
||
|
echo "Building bird-lg container"
|
||
|
|
||
|
IMAGE='bird-lg'
|
||
|
|
||
|
# find the REPO directory
|
||
|
SCRIPTPATH="$(cd "$(dirname "$0")" ; pwd -P)"
|
||
|
REPOPATH="$(cd "${SCRIPTPATH}/../"; pwd -P)"
|
||
|
echo "Repo is in: ${REPOPATH}"
|
||
|
|
||
|
##########################################################################
|
||
|
|
||
|
DEPS=(
|
||
|
'python3'
|
||
|
'python3-flask'
|
||
|
'python3-dnspython'
|
||
|
'python3-pydot'
|
||
|
'python3-memcache'
|
||
|
'graphviz'
|
||
|
'whois'
|
||
|
'traceroute'
|
||
|
)
|
||
|
B=$(which buildah)
|
||
|
|
||
|
# initialise container
|
||
|
c=$($B 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 and copy over the repo
|
||
|
m=$($B mount $c)
|
||
|
mkdir "${m}/lg"
|
||
|
rsync -r "${REPOPATH}/" "${m}/lg/" \
|
||
|
--exclude ".git*" \
|
||
|
--exclude "init/" \
|
||
|
--exclude "contrib/" \
|
||
|
--exclude "README*"
|
||
|
$B umount $c
|
||
|
|
||
|
# configure
|
||
|
buildah config \
|
||
|
--author="Simon Marsh" \
|
||
|
--workingdir='/lg' \
|
||
|
--cmd='/usr/bin/python3 /lg/lg.py' \
|
||
|
$c
|
||
|
|
||
|
##########################################################################
|
||
|
# finally create the image
|
||
|
|
||
|
echo "Committing image ..."
|
||
|
i=$($B commit --squash $c ${IMAGE})
|
||
|
|
||
|
# clean up
|
||
|
$B rm $c
|
||
|
|
||
|
##########################################################################
|
||
|
# end of file
|