diff --git a/action-base.Dockerfile b/action-base.Dockerfile new file mode 100644 index 0000000..e707806 --- /dev/null +++ b/action-base.Dockerfile @@ -0,0 +1,39 @@ +FROM buildpack-deps:scm as clone +SHELL ["/bin/bash", "-exo", "pipefail", "-c"] + +RUN mkdir actions ;\ + cd actions ;\ + git clone --bare https://github.com/actions/checkout.git ;\ + git -C checkout.git archive --prefix=checkout/ v2 |tar -x ;\ + git clone --bare https://github.com/actions/cache.git ;\ + git -C cache.git archive --prefix=cache/ v2 |tar -x ;\ + git clone --bare https://github.com/actions/upload-artifact.git ;\ + git -C upload-artifact.git archive --prefix=upload-artifact/ v2 |tar -x ;\ + rm -rf *.git + + +FROM debian:buster-slim +SHELL ["/bin/bash", "-exo", "pipefail", "-c"] +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update ;\ + apt-get install --no-install-{recommends,suggests} -y \ + apt-transport-https gnupg2 dirmngr ca-certificates ;\ + apt-get clean ;\ + rm -vrf /var/lib/apt/lists/* ;\ + apt-key adv --fetch-keys https://download.docker.com/linux/debian/gpg ;\ + apt-get purge -y gnupg2 dirmngr ;\ + apt-get autoremove --purge -y + +ADD action-base.list /etc/apt/sources.list.d/misc.list + +RUN apt-get update ;\ + apt-get install --no-install-{recommends,suggests} -y \ + bison cmake docker-ce-cli flex g++ \ + libboost{,-{context,coroutine,date-time,filesystem,program-options,regex,system,thread}}1.67-dev \ + libedit-dev libmariadbclient-dev libpq-dev libssl-dev make nodejs ;\ + apt-get install --no-install-{recommends,suggests} -y ccache ;\ + apt-get clean ;\ + rm -vrf /var/lib/apt/lists/* + +COPY --from=clone /actions /actions diff --git a/action-base.list b/action-base.list new file mode 100644 index 0000000..6b92268 --- /dev/null +++ b/action-base.list @@ -0,0 +1,2 @@ +deb http://deb.debian.org/debian buster-backports main +deb [arch=amd64] https://download.docker.com/linux/debian buster stable diff --git a/action.Dockerfile b/action.Dockerfile index 831e9a0..b1a762b 100644 --- a/action.Dockerfile +++ b/action.Dockerfile @@ -1,19 +1,4 @@ -FROM buildpack-deps:scm as clone -SHELL ["/bin/bash", "-exo", "pipefail", "-c"] - -RUN mkdir actions ;\ - cd actions ;\ - git clone --bare https://github.com/actions/checkout.git ;\ - git -C checkout.git archive --prefix=checkout/ v2 |tar -x ;\ - git clone --bare https://github.com/actions/upload-artifact.git ;\ - git -C upload-artifact.git archive --prefix=upload-artifact/ v2 |tar -x ;\ - rm -rf *.git - - -FROM docker - -RUN ["apk", "add", "bash", "grep", "nodejs"] -COPY --from=clone /actions /actions +FROM icinga/icinga2-builder COPY action.bash Dockerfile / diff --git a/action.bash b/action.bash index 9ded191..9587239 100755 --- a/action.bash +++ b/action.bash @@ -3,11 +3,40 @@ set -exo pipefail TARGET=icinga/icinga2 +cache () { + INPUT_KEY=docker-image/ccache INPUT_PATH=ccache \ + STATE_CACHE_KEY=1 STATE_CACHE_RESULT=2 \ + node "/actions/cache/dist/${1}/index.js" +} + mkimg () { test -n "$TAG" node /actions/checkout/dist/index.js |grep -vFe ::add-matcher:: + cache restore + + export PATH="/usr/lib/ccache:$PATH" + mkdir -p ccache + ln -vs "$(pwd)/ccache" ~/.ccache + + mkdir icinga2-bin + mkdir build + cd build + + cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_SYSCONFDIR=/etc \ + -DCMAKE_INSTALL_LOCALSTATEDIR=/var -DICINGA2_RUNDIR=/run \ + -DICINGA2_SYSCONFIGFILE=/etc/sysconfig/icinga2 -DICINGA2_WITH_{COMPAT,LIVESTATUS}=OFF .. + + make + make test + + make install "DESTDIR=$(pwd)/../icinga2-bin" + + cd .. + + cache save docker build -f /Dockerfile -t "${TARGET}:$TAG" . + STATE_isPost=1 node /actions/checkout/dist/index.js docker save "${TARGET}:$TAG" |gzip >docker-save.tgz