diff --git a/README.md b/README.md index 608197a..c2626d3 100644 --- a/README.md +++ b/README.md @@ -21,14 +21,26 @@ A public instance of the API and explorer web app can be accessed via: ## Building -Requires [git](https://git-scm.com/) and [go](https://golang.org) +#### Using locally installed go +Requires [git](https://git-scm.com/) and [go](https://golang.org) ``` go get -insecure git.dn42.us/burble/dn42regsrv ``` +#### Without installing go + +Using container runtime to build with the golang container: +``` +docker run -v ${PWD}:/go/bin golang go get -insecure git.dn42.us/burble/dn42regsrv +``` + +Or use the *contrib/build.sh* script after cloning the repo. + ## Running +#### As a service + Use --help to view configurable options ``` ${GOPATH}/bin/dn42regsrv --help @@ -47,6 +59,14 @@ ${GOPATH}/dn42regsrv A sample service file is included for running the server under systemd +#### Within a container + +A container build script (*contrib/buildah.sh*) is included in the +contrib directory. The script uses [buildah](https://buildah.io/). + +See the *contrib/entrypoint.sh* script for environment variables that can +be set when running the container. + ## Using By default the server will be listening on port 8042. diff --git a/contrib/build.sh b/contrib/build.sh new file mode 100755 index 0000000..f5d2a45 --- /dev/null +++ b/contrib/build.sh @@ -0,0 +1,26 @@ +#!/bin/bash +########################################################################## +# A small script to build a static dn42regsrv 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/dn42regsrv" \ + -v "${PWD}:/go/bin" \ + -w "/go/src/dn42regsrv" \ + docker.io/golang:1.12 \ + go get + +########################################################################## +# end of code diff --git a/contrib/buildah.sh b/contrib/buildah.sh new file mode 100755 index 0000000..bb474e0 --- /dev/null +++ b/contrib/buildah.sh @@ -0,0 +1,65 @@ +#!/bin/bash +########################################################################## +echo "Building dn42regsrv container" + +# find the source directory +SCRIPTPATH="$(cd "$(dirname "$0")" ; pwd -P)" +SOURCEPATH="$(cd "${SCRIPTPATH}/../"; pwd -P)" +echo "Source is in: ${SOURCEPATH}" + +########################################################################## + +DEPS='git' +B=$(which buildah) + +# initialise container +c=$(buildah from --name dn42regsrv-working docker.io/debian:buster) + +########################################################################## + +# install dependencies and initialise directories +$B run $c -- bash <