Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 16 additions & 41 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# SPDX-FileCopyrightText: 2025 Icinga GmbH <https://icinga.com>
# SPDX-License-Identifier: GPL-2.0-or-later

FROM debian:trixie-slim AS build-base
ARG DEBIAN_VERSION="trixie"
ARG PLUGINS_VERSION=${DEBIAN_VERSION}

# Alias the container to plugins as the ARG substitution is not allowed in the RUN bindmount on Docker.
FROM ghcr.io/icinga/icinga2-plugins-container:${PLUGINS_VERSION} AS plugins

FROM debian:${DEBIAN_VERSION}-slim AS build-base

# Install all the necessary build dependencies for building Icinga 2 and the plugins.
#
Expand Down Expand Up @@ -46,37 +52,6 @@ RUN apt-get update && \
# Set the default working directory for subsequent commands of the next stages.
WORKDIR /icinga2-build

FROM build-base AS build-plugins

# Install all the plugins that are not included in the monitoring-plugins package.
ADD https://github.com/lausser/check_mssql_health.git#747af4c3c261790341da164b58d84db9c7fa5480 /check_mssql_health
ADD https://github.com/lausser/check_nwc_health.git#a5295475c9bbd6df9fe7432347f7c5aba16b49df /check_nwc_health
ADD https://github.com/bucardo/check_postgres.git#58de936fdfe4073413340cbd9061aa69099f1680 /check_postgres
ADD https://github.com/matteocorti/check_ssl_cert.git#341b5813108fb2367ada81e866da989ea4fb29e7 /check_ssl_cert

WORKDIR /check_mssql_health
RUN mkdir bin && \
autoconf && \
autoreconf && \
./configure "--build=$(uname -m)-unknown-linux-gnu" --libexecdir=/usr/lib/nagios/plugins && \
make && \
make install DESTDIR="$(pwd)/bin"

WORKDIR /check_nwc_health
RUN mkdir bin && \
autoreconf && \
./configure "--build=$(uname -m)-unknown-linux-gnu" --libexecdir=/usr/lib/nagios/plugins && \
make && \
make install DESTDIR="$(pwd)/bin"

WORKDIR /check_postgres
RUN mkdir bin && \
perl Makefile.PL INSTALLSITESCRIPT=/usr/lib/nagios/plugins && \
make && \
make install DESTDIR="$(pwd)/bin" && \
# This is necessary because of this build error: cannot copy to non-directory: /var/lib/docker/.../merged/usr/local/man
rm -rf bin/usr/local/man

FROM build-base AS build-icinga2

# To access the automated build arguments in the Dockerfile originated from the Docker BuildKit [^1],
Expand Down Expand Up @@ -139,14 +114,18 @@ RUN rm -rf /icinga2-install/etc/icinga2/features-enabled/mainlog.conf \
strip -g /icinga2-install/usr/lib/nagios/plugins/check_nscp_api

# Prepare the final image with the necessary configuration files and runtime dependencies.
FROM debian:trixie-slim AS icinga2
FROM debian:${DEBIAN_VERSION}-slim AS icinga2

# The real UID of the Icinga user to be used in the final image.
ARG ICINGA_USER_ID=5665

COPY --from=plugins /usr/lib/nagios/plugins/* /usr/lib/nagios/plugins/
COPY --from=plugins /plugins.cdx.json /usr/share/sbom/

# Install the necessary runtime dependencies for the Icinga 2 binary and the monitoring-plugins.
RUN apt-get update && \
apt-get upgrade -y && \
RUN --mount=from=plugins,target=/plugins \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends --no-install-suggests \
bc \
ca-certificates \
Expand Down Expand Up @@ -176,7 +155,8 @@ RUN apt-get update && \
msmtp \
msmtp-mta \
openssh-client \
openssl && \
openssl \
$(cat /plugins/debian-packages) && \
# Official Debian images automatically run `apt-get clean` after every install, so we don't need to do it here.
rm -rf /var/lib/apt/lists/*

Expand All @@ -191,11 +171,6 @@ RUN adduser \
--no-create-home \
--uid ${ICINGA_USER_ID} icinga

COPY --from=build-plugins /check_mssql_health/bin/ /
COPY --from=build-plugins /check_nwc_health/bin/ /
COPY --from=build-plugins /check_postgres/bin/ /
COPY --from=build-plugins /check_ssl_cert/check_ssl_cert /usr/lib/nagios/plugins/check_ssl_cert

COPY --from=build-icinga2 /icinga2-install/ /

# Create a corresponding symlink in the root filesystem for all Icinga 2 directories in /data.
Expand Down
Loading