diff --git a/Dockerfile b/Dockerfile index 3e14e7d..25341ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,36 @@ # Icinga Web 2 Docker image | (c) 2020 Icinga GmbH | GPLv2+ -FROM icinga/icingaweb2-deps +FROM golang:buster as entrypoint + +COPY entrypoint /entrypoint + +WORKDIR /entrypoint +RUN ["go", "build", "."] + + +FROM debian:buster-slim + +RUN ["bash", "-exo", "pipefail", "-c", "export DEBIAN_FRONTEND=noninteractive; apt-get update; apt-get install --no-install-{recommends,suggests} -y apache2 libapache2-mod-php7.3 locales-all php-{imagick,redis} php7.3-{bcmath,bz2,common,curl,dba,enchant,gd,gmp,imap,interbase,intl,json,ldap,mbstring,mysql,odbc,opcache,pgsql,pspell,readline,recode,snmp,soap,sqlite3,sybase,tidy,xml,xmlrpc,xsl,zip}; apt-get clean; rm -vrf /var/lib/apt/lists/*"] + +COPY --from=entrypoint /entrypoint/entrypoint /entrypoint +COPY entrypoint/db-init /entrypoint-db-init + +RUN ["a2enmod", "rewrite"] +RUN ["ln", "-vsf", "/dev/stdout", "/var/log/apache2/access.log"] +RUN ["ln", "-vsf", "/dev/stderr", "/var/log/apache2/error.log"] +RUN ["ln", "-vsf", "/dev/stdout", "/var/log/apache2/other_vhosts_access.log"] + +RUN ["perl", "-pi", "-e", "if (/Listen/) { s/80/8080/ }", "/etc/apache2/ports.conf"] +RUN ["perl", "-pi", "-e", "if (/VirtualHost/) { s/80/8080/ }", "/etc/apache2/sites-available/000-default.conf"] +EXPOSE 8080 + +RUN ["chmod", "-R", "u=rwX,go=rX", "/entrypoint-db-init"] +RUN ["chmod", "o+x", "/var/log/apache2"] +RUN ["chown", "www-data:www-data", "/var/run/apache2"] +RUN ["ln", "-vs", "/data/etc/icingaweb2", "/etc/icingaweb2"] +RUN ["install", "-o", "www-data", "-g", "www-data", "-d", "/data"] + +ENTRYPOINT ["/entrypoint"] COPY icingaweb2 /usr/share/icingaweb2 COPY icinga-php /usr/share/icinga-php diff --git a/action-base.Dockerfile b/action-base.Dockerfile deleted file mode 100644 index 254a0cf..0000000 --- a/action-base.Dockerfile +++ /dev/null @@ -1,34 +0,0 @@ -# Icinga Web 2 Docker image | (c) 2020 Icinga GmbH | GPLv2+ - -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 ;\ - 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/docker.list - -RUN apt-get update ;\ - apt-get install --no-install-{recommends,suggests} -y \ - composer docker-ce-cli git nodejs patch php7.3-zip ;\ - apt-get clean ;\ - rm -vrf /var/lib/apt/lists/* - -COPY --from=clone /actions /actions diff --git a/action.Dockerfile b/action.Dockerfile index 3de5935..917ba7a 100644 --- a/action.Dockerfile +++ b/action.Dockerfile @@ -1,7 +1,39 @@ # Icinga Web 2 Docker image | (c) 2020 Icinga GmbH | GPLv2+ -FROM icinga/icingaweb2-builder +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 ;\ + 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/docker.list + +RUN apt-get update ;\ + apt-get install --no-install-{recommends,suggests} -y \ + composer docker-ce-cli git nodejs patch php7.3-zip ;\ + apt-get clean ;\ + rm -vrf /var/lib/apt/lists/* + +COPY --from=clone /actions /actions COPY action.bash composer.bash Dockerfile get-mods.sh icingaweb2.patch / +COPY entrypoint /entrypoint CMD ["/action.bash"] diff --git a/action.bash b/action.bash index 520f199..b11ce6c 100755 --- a/action.bash +++ b/action.bash @@ -15,6 +15,7 @@ mkimg () { /composer.bash patch -d icingaweb2 -p0 < /icingaweb2.patch + cp -r /entrypoint . docker build -f /Dockerfile -t "${TARGET}:$TAG" . STATE_isPost=1 node /actions/checkout/dist/index.js diff --git a/build.bash b/build.bash index 6042e0e..208b689 100755 --- a/build.bash +++ b/build.bash @@ -16,8 +16,7 @@ fi IW2SRC="$(realpath "$IW2SRC")" BLDCTX="$(realpath "$(dirname "$0")")" -docker build -f "${BLDCTX}/action-base.Dockerfile" -t icinga/icingaweb2-builder "$BLDCTX" -docker build -f "${BLDCTX}/deps.Dockerfile" -t icinga/icingaweb2-deps "$BLDCTX" +docker build -f "${BLDCTX}/action.Dockerfile" -t icinga/icingaweb2-builder "$BLDCTX" docker run --rm -i \ -v "${IW2SRC}:/iw2src:ro" \ @@ -34,5 +33,6 @@ cd /iw2cp /bldctx/composer.bash patch -d icingaweb2 -p0 < /bldctx/icingaweb2.patch +cp -r /entrypoint . docker build -f /bldctx/Dockerfile -t icinga/icingaweb2 . EOF diff --git a/deps.Dockerfile b/deps.Dockerfile deleted file mode 100644 index 8a42b27..0000000 --- a/deps.Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -# Icinga Web 2 Docker image | (c) 2020 Icinga GmbH | GPLv2+ - -FROM golang:buster as entrypoint - -COPY entrypoint /entrypoint - -WORKDIR /entrypoint -RUN ["go", "build", "."] - - -FROM debian:buster-slim - -RUN ["bash", "-exo", "pipefail", "-c", "export DEBIAN_FRONTEND=noninteractive; apt-get update; apt-get install --no-install-{recommends,suggests} -y apache2 libapache2-mod-php7.3 locales-all php-{imagick,redis} php7.3-{bcmath,bz2,common,curl,dba,enchant,gd,gmp,imap,interbase,intl,json,ldap,mbstring,mysql,odbc,opcache,pgsql,pspell,readline,recode,snmp,soap,sqlite3,sybase,tidy,xml,xmlrpc,xsl,zip}; apt-get clean; rm -vrf /var/lib/apt/lists/*"] - -COPY --from=entrypoint /entrypoint/entrypoint /entrypoint -COPY entrypoint/db-init /entrypoint-db-init - -RUN ["a2enmod", "rewrite"] -RUN ["ln", "-vsf", "/dev/stdout", "/var/log/apache2/access.log"] -RUN ["ln", "-vsf", "/dev/stderr", "/var/log/apache2/error.log"] -RUN ["ln", "-vsf", "/dev/stdout", "/var/log/apache2/other_vhosts_access.log"] - -RUN ["perl", "-pi", "-e", "if (/Listen/) { s/80/8080/ }", "/etc/apache2/ports.conf"] -RUN ["perl", "-pi", "-e", "if (/VirtualHost/) { s/80/8080/ }", "/etc/apache2/sites-available/000-default.conf"] -EXPOSE 8080 - -RUN ["chmod", "-R", "u=rwX,go=rX", "/entrypoint-db-init"] -RUN ["chmod", "o+x", "/var/log/apache2"] -RUN ["chown", "www-data:www-data", "/var/run/apache2"] -RUN ["ln", "-vs", "/data/etc/icingaweb2", "/etc/icingaweb2"] -RUN ["install", "-o", "www-data", "-g", "www-data", "-d", "/data"] - -ENTRYPOINT ["/entrypoint"]