Add container build files
This commit is contained in:
parent
46e83bcb68
commit
56fd6dc687
26
contrib/build.sh
Executable file
26
contrib/build.sh
Executable file
@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
##########################################################################
|
||||
# A small script to build a static lgregmapper image
|
||||
# using the golang container image
|
||||
#
|
||||
# the binary will be built in to the current directory
|
||||
##########################################################################
|
||||
RUNTIME=$(which podman || which docker)
|
||||
echo "Using container runtime: ${RUNTIME}"
|
||||
|
||||
# find the source directory
|
||||
SCRIPTPATH="$(cd "$(dirname "$0")" ; pwd -P)"
|
||||
SOURCEPATH="$(cd "${SCRIPTPATH}/../"; pwd -P)"
|
||||
echo "Source is in: ${SOURCEPATH}"
|
||||
|
||||
# do the thing
|
||||
${RUNTIME} run --rm \
|
||||
-e CGO_ENABLED=0 \
|
||||
-v "${SOURCEPATH}:/go/src/lgregmapper" \
|
||||
-v "${PWD}:/go/bin" \
|
||||
-w "/go/src/lgregmapper" \
|
||||
docker.io/golang:1.12 \
|
||||
go get
|
||||
|
||||
##########################################################################
|
||||
# end of code
|
68
contrib/buildah.sh
Executable file
68
contrib/buildah.sh
Executable file
@ -0,0 +1,68 @@
|
||||
#!/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
|
16
contrib/entrypoint.sh
Executable file
16
contrib/entrypoint.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
##########################################################################
|
||||
|
||||
LGREGMAPPER_API=${LGREGMAPPER_WEBAPP:-https://explorer.burble.dn42/}
|
||||
LGREGMAPPER_BIND=${LGREGMAPPER_BIND:-localhost:11211}
|
||||
LGREGMAPPER_INTERVAL=${LGREGMAPPER_INTERVAL:-10m}
|
||||
LGREGMAPPER_LOGLVL=${LGREGMAPPER_LOGLVL:-info}
|
||||
|
||||
exec /app/lgregmapper \
|
||||
-a "$LGREGMAPPER_API" \
|
||||
-b "$LGREGMAPPER_BIND" \
|
||||
-i "$LGREGMAPPER_INTERVAL" \
|
||||
-l "$LGREGMAPPER_LOGLVL" \
|
||||
|
||||
##########################################################################
|
||||
# end of file
|
@ -53,10 +53,10 @@ func main() {
|
||||
// declare cmd line options
|
||||
var (
|
||||
logLevel = flag.StringP("LogLevel", "l", "Info", "Log level")
|
||||
refreshInterval = flag.StringP("Refresh", "i", "60m", "Refresh interval")
|
||||
refreshInterval = flag.StringP("Refresh", "i", "10m", "Refresh interval")
|
||||
bindAddress = flag.StringP("BindAddress", "b", "localhost:11211",
|
||||
"Server bind address")
|
||||
apiAddress = flag.StringP("APIAddress", "a", "http://collector.dn42:8042",
|
||||
apiAddress = flag.StringP("APIAddress", "a", "https://explorer.burble.dn42/",
|
||||
"DN42 API server address")
|
||||
)
|
||||
flag.Parse()
|
||||
|
Loading…
x
Reference in New Issue
Block a user