Skip to content

Commit

Permalink
Merge pull request #37 from tronyx/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
tronyx authored Aug 20, 2024
2 parents f1eec39 + 4f1c2f0 commit e3395b8
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 262 deletions.
122 changes: 20 additions & 102 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,56 +13,46 @@ on:
jobs:
build:
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
architecture: [linux-amd64, linux-arm64, linux-arm-v7]
architecture: [linux-amd64, linux-arm64]
outputs:
version: ${{ steps.prep.outputs.version }}
branch: ${{ steps.prep.outputs.branch }}
time: ${{ steps.vars.outputs.time }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Check if architecture exists
id: arch_check
run: |
(test -f Dockerfile.${{ matrix.architecture }} && echo "check=passed" >> $GITHUB_OUTPUT) || echo "check=failed" >> $GITHUB_OUTPUT
# Workaround for Cargo issue: https://github.com/rust-lang/cargo/issues/8719
- name: Set Swap Space
uses: pierotofy/[email protected]
with:
swap-size-gb: 10
- run: |
sudo mkdir -p /var/lib/docker
sudo mount -t tmpfs -o size=10G none /var/lib/docker
sudo systemctl restart docker
- name: Set up QEMU
if: "contains(steps.arch_check.outputs.check, 'passed')"
uses: docker/setup-qemu-action@v2.1.0
uses: docker/setup-qemu-action@v3.0.0

- name: Set up Docker Buildx
if: "contains(steps.arch_check.outputs.check, 'passed')"
uses: docker/setup-buildx-action@v2.4.1
uses: docker/setup-buildx-action@v3.3.0
with:
install: true
version: latest
# Fix for https://github.com/docker/buildx/issues/1509
driver-opts: image=moby/buildkit:v0.10.5 #:master
driver-opts: image=moby/buildkit:master

- name: Login to docker.io
if: "contains(steps.arch_check.outputs.check, 'passed')"
uses: docker/login-action@v2.1.0
uses: docker/login-action@v3.2.0
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Login to ghcr.io
if: "contains(steps.arch_check.outputs.check, 'passed')"
uses: docker/login-action@v2.1.0
uses: docker/login-action@v3.2.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand Down Expand Up @@ -96,41 +86,11 @@ jobs:
echo $GITHUB_OUTPUT
- name: Build and push - Attempt 1
- name: Build and push
continue-on-error: true
if: "contains(steps.arch_check.outputs.check, 'passed')"
id: build_attempt1
uses: docker/[email protected]
with:
push: true
platforms: ${{ steps.prep.outputs.platform }}
file: ./Dockerfile.${{ matrix.architecture }}
cache-from: docker.io/${{ steps.prep.outputs.cache }}
cache-to: docker.io/${{ steps.prep.outputs.cache }}
tags: |
docker.io/${{ steps.prep.outputs.tag }}
ghcr.io/${{ steps.prep.outputs.tag }}
labels: |
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.title=${{ steps.prep.outputs.title }}
org.opencontainers.image.revision=${{ steps.prep.outputs.revision }}
org.opencontainers.image.source=${{ steps.prep.outputs.source }}
org.opencontainers.image.vendor=${{ steps.prep.outputs.vendor }}
org.opencontainers.image.url=${{ steps.prep.outputs.url }}
org.opencontainers.image.version=${{ steps.prep.outputs.version }}
build-args: |
GITHUB_TOKEN=${{ secrets.GHCR_TOKEN }}
BUILD_ARCHITECTURE=${{ matrix.architecture }}
${{ steps.prep.outputs.build-args }}
- name: Sleep
if: (steps.build_attempt1.outcome == 'failure')
run: |
sleep 30
- name: Build and push - Attempt 2
if: (steps.build_attempt1.outcome == 'failure')
uses: docker/[email protected]
uses: docker/[email protected]
with:
push: true
platforms: ${{ steps.prep.outputs.platform }}
Expand All @@ -154,32 +114,32 @@ jobs:
${{ steps.prep.outputs.build-args }}
publish:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
registry: [docker.io, ghcr.io]
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Login to docker.io
if: matrix.registry == 'docker.io'
uses: docker/login-action@v2.1.0
uses: docker/login-action@v3.2.0
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Login to ghcr.io
if: matrix.registry == 'ghcr.io'
uses: docker/login-action@v2.1.0
uses: docker/login-action@v3.2.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHCR_TOKEN }}

- name: Create manifests - Attempt 1
- name: Create manifests
continue-on-error: true
id: manifest_attempt1
env:
Expand All @@ -189,50 +149,8 @@ jobs:
TAG=${{ needs.build.outputs.branch }}
SOURCE=${IMAGE}:${TAG}-${GITHUB_SHA:0:7}-${GITHUB_RUN_NUMBER}
VERSION=${{ needs.build.outputs.version }}
BRANCH=${{ needs.build.outputs.branch }}
[[ -f Dockerfile.linux-amd64 ]] && AMD64=${SOURCE}-linux-amd64
[[ -f Dockerfile.linux-arm64 ]] && ARM64=${SOURCE}-linux-arm64
[[ -f Dockerfile.linux-arm-v7 ]] && ARMV7=${SOURCE}-linux-arm-v7
docker manifest create ${IMAGE}:${TAG} ${AMD64} ${ARM64} ${ARMV7}
docker manifest push ${IMAGE}:${TAG}
docker manifest create ${IMAGE}:${TAG}-${VERSION} ${AMD64} ${ARM64} ${ARMV7}
docker manifest push ${IMAGE}:${TAG}-${VERSION}
docker manifest create ${IMAGE}:${TAG}-${VERSION} ${AMD64} ${ARM64} ${ARMV7}
docker manifest push ${IMAGE}:${TAG}-${VERSION}
if [[ ${BRANCH} == master ]]; then
docker manifest create ${IMAGE}:latest ${AMD64} ${ARM64} ${ARMV7}
docker manifest push ${IMAGE}:latest
fi
- name: Sleep
if: (steps.manifest_attempt1.outcome == 'failure')
run: |
sleep 30
- name: Create manifests - Attempt 2
if: (steps.manifest_attempt1.outcome == 'failure')
env:
DOCKER_CLI_EXPERIMENTAL: enabled
run: |
IMAGE=${{ matrix.registry }}/$(echo ${GITHUB_REPOSITORY} | tr '[:upper:]' '[:lower:]' | sed s/docker-//)
TAG=${{ needs.build.outputs.branch }}
SOURCE=${IMAGE}:${TAG}-${GITHUB_SHA:0:7}-${GITHUB_RUN_NUMBER}
VERSION=${{ needs.build.outputs.version }}
BRANCH=${{ needs.build.outputs.branch }}
[[ -f Dockerfile.linux-amd64 ]] && AMD64=${SOURCE}-linux-amd64
[[ -f Dockerfile.linux-arm64 ]] && ARM64=${SOURCE}-linux-arm64
[[ -f Dockerfile.linux-arm-v7 ]] && ARMV7=${SOURCE}-linux-arm-v7
docker manifest rm ${IMAGE}:${TAG} || true
docker manifest create ${IMAGE}:${TAG} ${AMD64} ${ARM64} ${ARMV7}
docker manifest push ${IMAGE}:${TAG}
docker manifest rm ${IMAGE}:${TAG}-${VERSION} || true
docker manifest create ${IMAGE}:${TAG}-${VERSION} ${AMD64} ${ARM64} ${ARMV7}
docker manifest push ${IMAGE}:${TAG}-${VERSION}
docker manifest rm ${IMAGE}:${TAG}-${VERSION} || true
docker manifest create ${IMAGE}:${TAG}-${VERSION} ${AMD64} ${ARM64} ${ARMV7}
docker manifest push ${IMAGE}:${TAG}-${VERSION}
if [[ ${BRANCH} == master ]]; then
docker manifest rm ${IMAGE}:latest || true
docker manifest create ${IMAGE}:latest ${AMD64} ${ARM64} ${ARMV7}
docker manifest push ${IMAGE}:latest
docker buildx imagetools create -t ${IMAGE}:${TAG} ${SOURCE}-linux-amd64 ${SOURCE}-linux-arm64
docker buildx imagetools create -t ${IMAGE}:${TAG}-${VERSION} ${SOURCE}-linux-amd64 ${SOURCE}-linux-arm64
if [[ ${GITHUB_REF//refs\/heads\//} == main ]]; then
docker buildx imagetools create -t ${IMAGE}:latest ${SOURCE}-linux-amd64 ${SOURCE}-linux-arm64
fi
100 changes: 53 additions & 47 deletions Dockerfile.linux-amd64
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,43 @@
ARG BUILDKIT_SBOM_SCAN_CONTEXT=true
ARG BUILDKIT_SBOM_SCAN_STAGE=true

FROM ubuntu:22.04

LABEL name="Nagios" \
nagiosVersion="4.5.1" \
nagiosPluginsVersion="2.4.9" \
nrpeVersion="4.1.0" \
nscaVersion="2.10.2" \
ncpaVersion="3.0.2" \
nagiostvVersion="0.8.7" \
homepage="https://www.nagios.com/" \
maintainer="Tronyx <[email protected]>"
FROM ubuntu:24.04

LABEL name="Nagios"
LABEL nagiosVersion="4.5.4"
LABEL nagiosPluginsVersion="2.4.11"
LABEL nrpeVersion="4.1.1"
LABEL nscaVersion="2.10.3"
LABEL ncpaVersion="3.1.0"
LABEL nagiostvVersion="0.9.2"
LABEL homepage="https://www.nagios.com/"
LABEL maintainer="Tronyx <[email protected]>"

# Environment variables
ENV NAGIOS_HOME=/opt/nagios \
NAGIOS_USER=nagios \
NAGIOS_GROUP=nagios \
NAGIOS_CMDUSER=nagios \
NAGIOS_CMDGROUP=nagios \
NAGIOS_FQDN=nagios.example.com \
NAGIOSADMIN_USER=nagiosadmin \
NAGIOSADMIN_PASS=nagios \
APACHE_RUN_USER=nagios \
APACHE_RUN_GROUP=nagios \
APACHE_LOCK_DIR=/var/run \
APACHE_LOG_DIR=/var/log/apache2 \
NAGIOS_TIMEZONE=UTC \
DEBIAN_FRONTEND=noninteractive \
NAGIOS_BRANCH=nagios-4.5.1 \
NAGIOS_PLUGINS_BRANCH=release-2.4.9 \
NRPE_BRANCH=nrpe-4.1.0 \
NSCA_TAG=nsca-2.10.2 \
NCPA_BRANCH=v3.0.2 \
NAGIOSTV_VERSION=0.8.7

ENV NG_CGI_URL=/cgi-bin \
NG_NAGIOS_CONFIG_FILE=${NAGIOS_HOME}/etc/nagios.cfg \
NG_CGI_DIR=${NAGIOS_HOME}/sbin \
NG_WWW_DIR=${NAGIOS_HOME}/share/nagiosgraph
ENV NAGIOS_HOME=/opt/nagios
ENV NAGIOS_USER=nagios
ENV NAGIOS_GROUP=nagios
ENV NAGIOS_CMDUSER=nagios
ENV NAGIOS_CMDGROUP=nagios
ENV NAGIOS_FQDN=nagios.example.com
ENV NAGIOSADMIN_USER=nagiosadmin
ENV NAGIOSADMIN_PASS=nagios
ENV APACHE_RUN_USER=nagios
ENV APACHE_RUN_GROUP=nagios
ENV APACHE_LOCK_DIR=/var/run
ENV APACHE_LOG_DIR=/var/log/apache2
ENV NAGIOS_TIMEZONE=UTC
ENV DEBIAN_FRONTEND=noninteractive
ENV NG_CGI_URL=/cgi-bin
ENV NG_NAGIOS_CONFIG_FILE=${NAGIOS_HOME}/etc/nagios.cfg
ENV NG_CGI_DIR=${NAGIOS_HOME}/sbin
ENV NG_WWW_DIR=${NAGIOS_HOME}/share/nagiosgraph
ENV NAGIOS_BRANCH=nagios-4.5.4
ENV NAGIOS_PLUGINS_BRANCH=release-2.4.11
ENV NRPE_BRANCH=nrpe-4.1.1
ENV NSCA_TAG=nsca-2.10.3
ENV NCPA_BRANCH=v3.1.0
ENV NAGIOSTV_VERSION=0.9.2

RUN echo postfix postfix/main_mailer_type string "'Internet Site'" | debconf-set-selections && \
echo postfix postfix/mynetworks string "127.0.0.0/8" | debconf-set-selections && \
Expand All @@ -56,6 +55,7 @@ RUN echo postfix postfix/main_mailer_type string "'Internet Site'" | debconf-set
bsd-mailx \
build-essential \
ca-certificates \
curl \
dnsutils \
fping \
freetds-dev \
Expand All @@ -69,6 +69,7 @@ RUN echo postfix postfix/main_mailer_type string "'Internet Site'" | debconf-set
libcgi-pm-perl \
libcrypt-des-perl \
libcrypt-rijndael-perl \
libcrypt-x509-perl \
libdbd-mysql-perl \
libdbd-pg-perl \
libdbi-dev \
Expand All @@ -81,30 +82,31 @@ RUN echo postfix postfix/main_mailer_type string "'Internet Site'" | debconf-set
libgd-gd2-perl \
libjson-perl \
libldap2-dev \
libmysqlclient-dev \
libmariadb-dev \
libnagios-object-perl \
libmonitoring-plugin-perl \
libnet-snmp-perl \
libnet-tftp-perl \
libnet-xmpp-perl \
libpq-dev \
libpython2-dev \
libpython3-dev \
libredis-perl \
librrds-perl \
libssl-dev \
libswitch-perl \
libtext-glob-perl \
libwww-perl \
m4 \
netcat \
netcat-traditional \
openssh-client \
parallel \
php-cli \
php-gd \
postfix \
python2 \
python3-pip \
python3-full \
python3-nagiosplugin \
python3-pip \
python3-venv \
rsync \
rsyslog \
runit \
Expand Down Expand Up @@ -219,11 +221,11 @@ RUN cd /tmp && \

# Install additional plugins
RUN cd /opt && \
wget -q -O get-pip.py https://bootstrap.pypa.io/pip/2.7/get-pip.py && \
python2 get-pip.py && \
pip install --no-cache-dir "pymssql<2.2.0" && \
pip3 install --no-cache-dir --find-links https://wheel-index.linuxserver.io/ubuntu/ pywbem paramiko pplogger paho-mqtt && \
pip3 install --no-cache-dir --find-links https://wheel-index.linuxserver.io/ubuntu/ --upgrade requests && \
#python3 -m venv .venv && \
#. .venv/bin/activate && \
pip3 install --break-system-packages --no-cache-dir pymssql && \
pip3 install --break-system-packages --no-cache-dir --find-links https://wheel-index.linuxserver.io/ubuntu/ pywbem paramiko pplogger paho-mqtt && \
pip3 install --break-system-packages --no-cache-dir --find-links https://wheel-index.linuxserver.io/ubuntu/ --upgrade requests && \
git clone https://github.com/willixix/naglio-plugins.git WL-Nagios-Plugins && \
git clone https://github.com/JasonRivers/nagios-plugins.git JR-Nagios-Plugins && \
git clone https://github.com/justintime/nagios-plugins.git JE-Nagios-Plugins && \
Expand Down Expand Up @@ -286,9 +288,13 @@ RUN echo "use_timezone=${NAGIOS_TIMEZONE}" >> ${NAGIOS_HOME}/etc/nagios.cfg
# Copy example config in-case the user has started with empty var or etc
RUN mkdir -p /orig/var && \
mkdir -p /orig/etc && \
mkdir -p /orig/graph-etc && \
mkdir -p /orig/graph-var && \
mkdir -p /orig/xinetd.d && \
cp -Rp ${NAGIOS_HOME}/var/* /orig/var/ && \
cp -Rp ${NAGIOS_HOME}/etc/* /orig/etc/ && \
cp -Rp /opt/nagiosgraph/etc/* /orig/graph-etc && \
cp -Rp /opt/nagiosgraph/var/* /orig/graph-var && \
cp -Rp /etc/xinetd.d/* /orig/xinetd.d/

## Set the permissions for example config
Expand All @@ -310,7 +316,7 @@ RUN cd /opt/nagiosgraph/etc && \
sh fix-nagiosgraph-multiple-selection.sh

# Enable all runit services
RUN ln -s /etc/sv/* /etc/service
RUN ln -sf /etc/sv/* /etc/service

# Fix ping permissions for Nagios user
RUN chmod u+s /usr/bin/ping
Expand Down
Loading

0 comments on commit e3395b8

Please sign in to comment.