Skip to content

Commit

Permalink
version 22.7.0 based on ubuntu 22.04
Browse files Browse the repository at this point in the history
  • Loading branch information
jarischaefer committed Jul 23, 2022
1 parent e58eb91 commit 2ecb60f
Show file tree
Hide file tree
Showing 44 changed files with 225 additions and 192 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!post_install
!pre_install
!qemu*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Thumbs.db
.project
nbproject
!.gitignore
docker-persistence
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM jarischaefer/baseimage-librenms:3.3
FROM jarischaefer/baseimage-librenms:4.0

EXPOSE 80 443

ENV TZ=UTC \
RRDCACHED_LISTEN=unix:/var/run/rrdcached/rrdcached.sock \
Expand All @@ -7,8 +9,9 @@ ENV TZ=UTC \
WEATHERMAP_CRON="*/5 * * * *" \
POLLERS=8 \
POLLERS_CRON="*/5 * * * *" \
INSTALL=false
EXPOSE 80 443
INSTALL=false \
PHP_FPM_WORKERS_MIN=1 \
PHP_FPM_WORKERS_MAX=4

ADD pre_install /

Expand All @@ -17,7 +20,7 @@ RUN chmod +x /build/install && /build/install && rm -r /build
ADD post_install /

RUN chmod -R +x /etc/my_init.d /etc/service /usr/local/bin && \
find /opt/librenms \( ! -user librenms -o ! -group librenms \) -exec chown librenms:librenms {} \; && \
find /opt/librenms \( ! -user librenms -o ! -group librenms \) | xargs -L25 -r chown -h librenms:librenms && \
chmod 644 /etc/cron.d/* /etc/librenms/cron/*

VOLUME ["/opt/librenms/logs", "/opt/librenms/rrd", "/opt/librenms/storage"]
Expand Down
11 changes: 7 additions & 4 deletions Dockerfile.arm32v7
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
FROM --platform=linux/arm32v7 jarischaefer/baseimage-librenms:3.2-arm32v7
FROM --platform=linux/arm32v7 jarischaefer/baseimage-librenms:4.0-arm32v7
ADD qemu-arm-static /usr/bin

EXPOSE 80 443

ENV TZ=UTC \
RRDCACHED_LISTEN=unix:/var/run/rrdcached/rrdcached.sock \
RRDCACHED_CONNECT=unix:/var/run/rrdcached/rrdcached.sock \
SNMP_SCAN_CRON="0 0 * * *" \
WEATHERMAP_CRON="*/5 * * * *" \
POLLERS=8 \
POLLERS_CRON="*/5 * * * *" \
INSTALL=false
EXPOSE 80 443
INSTALL=false \
PHP_FPM_WORKERS_MIN=1 \
PHP_FPM_WORKERS_MAX=4

ADD pre_install /

Expand All @@ -18,7 +21,7 @@ RUN chmod +x /build/install && /build/install && rm -r /build
ADD post_install /

RUN chmod -R +x /etc/my_init.d /etc/service /usr/local/bin && \
find /opt/librenms \( ! -user librenms -o ! -group librenms \) -exec chown librenms:librenms {} \; && \
find /opt/librenms \( ! -user librenms -o ! -group librenms \) | xargs -L25 -r chown -h librenms:librenms && \
chmod 644 /etc/cron.d/* /etc/librenms/cron/*

VOLUME ["/opt/librenms/logs", "/opt/librenms/rrd", "/opt/librenms/storage"]
Expand Down
11 changes: 7 additions & 4 deletions Dockerfile.arm64v8
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
FROM --platform=linux/arm64v8 jarischaefer/baseimage-librenms:3.2-arm64v8
FROM --platform=linux/arm64v8 jarischaefer/baseimage-librenms:4.0-arm64v8
ADD qemu-aarch64-static /usr/bin

EXPOSE 80 443

ENV TZ=UTC \
RRDCACHED_LISTEN=unix:/var/run/rrdcached/rrdcached.sock \
RRDCACHED_CONNECT=unix:/var/run/rrdcached/rrdcached.sock \
SNMP_SCAN_CRON="0 0 * * *" \
WEATHERMAP_CRON="*/5 * * * *" \
POLLERS=8 \
POLLERS_CRON="*/5 * * * *" \
INSTALL=false
EXPOSE 80 443
INSTALL=false \
PHP_FPM_WORKERS_MIN=1 \
PHP_FPM_WORKERS_MAX=4

ADD pre_install /

Expand All @@ -18,7 +21,7 @@ RUN chmod +x /build/install && /build/install && rm -r /build
ADD post_install /

RUN chmod -R +x /etc/my_init.d /etc/service /usr/local/bin && \
find /opt/librenms \( ! -user librenms -o ! -group librenms \) -exec chown librenms:librenms {} \; && \
find /opt/librenms \( ! -user librenms -o ! -group librenms \) | xargs -L25 -r chown -h librenms:librenms && \
chmod 644 /etc/cron.d/* /etc/librenms/cron/*

VOLUME ["/opt/librenms/logs", "/opt/librenms/rrd", "/opt/librenms/storage"]
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ Releases are listed on the [Releases page](https://github.com/jarischaefer/docke

docker-librenms is a customizable Docker image for [LibreNMS](http://www.librenms.org/) based on Ubuntu.

The container runs nginx 1.15+ with HTTP/2 support and PHP 7.4 FPM with [OPCache](http://php.net/manual/en/book.opcache.php)
The container runs nginx 1.18+ with HTTP/2 support and PHP 8.1 FPM with [OPCache](http://php.net/manual/en/book.opcache.php)
and [rrdcached](https://oss.oetiker.ch/rrdtool/doc/rrdcached.en.html) for maximum performance.

> :warning: ARM is not supported currently, see [here](https://github.com/jarischaefer/docker-librenms/issues/114) for more details.
> :warning: ARM support is experimental, see [here](https://github.com/jarischaefer/docker-librenms/issues/114) for more details.
---

Expand Down Expand Up @@ -229,6 +229,8 @@ The following keys can be passed directly via the `-e` switch:
|TZ |UTC |Timezone (e.g. Europe/Zurich)
|PUID | |User ID
|PGID | |Group ID
|PHP_FPM_WORKERS_MIN |1 |Minimum number of PHP-FPM workers
|PHP_FPM_WORKERS_MAX |4 |Maximum number of PHP-FPM workers

## Enabling/disabling container features

Expand Down
21 changes: 15 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '2'
version: '3.9'

services:
web:
Expand All @@ -7,27 +7,36 @@ services:
ports:
- "80:80"
volumes:
- /my/persistent/directory/logs:/opt/librenms/logs
- /my/persistent/directory/rrd:/opt/librenms/rrd
- ./docker-persistence/logs:/opt/librenms/logs
- ./docker-persistence/rrd:/opt/librenms/rrd
environment:
- APP_KEY=REPLACE-WITH-GENERATED-KEY
- APP_KEY=base64:7cVDlhFEZ1dyxIuP38Yy72YuXrcGg1ISwAwZ2dKt4Pk=
- DB_HOST=db
- DB_NAME=librenms
- DB_USER=librenms
- DB_PASS=librenms
- POLLERS=16
- BASE_URL=http://localhost
- DAILY_ON_STARTUP=true
links:
- mysql:db
depends_on:
mysql:
condition: service_healthy
mysql:
image: mysql:5.6
image: mysql:8.0
command: --sql-mode=""
ports:
- "3306"
volumes:
- /my/persistent/directory/mysql:/var/lib/mysql
- ./docker-persistence/mysql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_USER=librenms
- MYSQL_PASSWORD=librenms
- MYSQL_DATABASE=librenms
healthcheck:
test: "mysql -h localhost -u root -p$$MYSQL_ROOT_PASSWORD -e 'USE librenms'"
interval: 5s
timeout: 5s
retries: 20
6 changes: 3 additions & 3 deletions hooks/post_checkout
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -eu
#!/bin/sh -eu

curl -qsSL "https://github.com/multiarch/qemu-user-static/releases/download/v5.2.0-2/qemu-arm-static.tar.gz" | tar -xz
curl -qsSL "https://github.com/multiarch/qemu-user-static/releases/download/v5.2.0-2/qemu-aarch64-static.tar.gz" | tar -xz
curl -qsSL "https://github.com/multiarch/qemu-user-static/releases/download/v6.1.0-8/qemu-arm-static.tar.gz" | tar -xz
curl -qsSL "https://github.com/multiarch/qemu-user-static/releases/download/v6.1.0-8/qemu-aarch64-static.tar.gz" | tar -xz

chmod 755 qemu-arm-static qemu-aarch64-static
2 changes: 1 addition & 1 deletion hooks/pre_build
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash -eu
#!/bin/sh -eu

docker run --rm --privileged multiarch/qemu-user-static:register --reset
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/bin/bash -e
# Bash supports the ${!...} construct for indirect variable expansion

LOCK_FILE=/var/lock/librenms_environment.lock

if [ -f "$LOCK_FILE" ]; then
exit 0
fi

function addConfig() {
addConfig () {
if [ -n "${!1}" ]; then
echo "export $1=\"${!1}\"" >> /etc/librenms_environment
fi
Expand Down
52 changes: 0 additions & 52 deletions post_install/etc/my_init.d/librenms_000_permissions

This file was deleted.

22 changes: 22 additions & 0 deletions post_install/etc/my_init.d/librenms_001_early_permissions
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh -e

# Create a new librenms user and remap it to the given UID
if [ ! -z "$PUID" ]; then
if [ -z "$PGID" ]; then
PGID=${PUID}
fi

deluser librenms
delgroup www-data librenms
delgroup librenms
groupadd --gid ${PGID} librenms
usermod --append --groups librenms www-data
useradd librenms --gid librenms --home-dir /opt/librenms --system --shell /bin/bash --uid ${PUID}
fi

# avoids problems when mounting volumes via NFS
set +e

/usr/local/bin/set_permissions_basic

exit 0
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -eu
#!/bin/sh -eu

NAGIOS_PLUGINS_MOUNT=/mount/nagios_plugins
TARGET_DIR=/usr/lib/nagios/plugins
Expand Down
2 changes: 1 addition & 1 deletion post_install/etc/my_init.d/librenms_100_cron
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/bin/sh -e

LOCK_FILE=/var/lock/librenms_cron.lock

Expand Down
12 changes: 2 additions & 10 deletions post_install/etc/my_init.d/librenms_101_ssl
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
#!/bin/bash -eu

LOCK_FILE=/var/lock/librenms_ssl.lock

if [ -f "$LOCK_FILE" ]; then
exit 0
fi
#!/bin/sh -eu

CONF_FILE=/etc/nginx/sites-available/librenms.https
SSL_CERT=/etc/nginx/ssl/ssl.crt
Expand All @@ -16,7 +10,5 @@ if [ -f "$SSL_CERT" ] && [ -f "$SSL_KEY" ]; then
sed -i 's/#ssl_trusted_certificate/ssl_trusted_certificate/g' "$CONF_FILE"
fi

ln -s "$CONF_FILE" /etc/nginx/sites-enabled/librenms.https
ln -sf "$CONF_FILE" /etc/nginx/sites-enabled/librenms.https
fi

touch "$LOCK_FILE"
2 changes: 1 addition & 1 deletion post_install/etc/my_init.d/librenms_102_ipv6
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/bin/sh -e

LOCK_FILE=/var/lock/librenms_ipv6.lock

Expand Down
12 changes: 6 additions & 6 deletions post_install/etc/my_init.d/librenms_103_timezone
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash -e
#!/bin/sh -e

if [ -n "$TZ" ]; then
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ln -snf "/usr/share/zoneinfo/${TZ}" /etc/localtime && echo "$TZ" > /etc/timezone

if [ ! -f /etc/php/7.4/cli/conf.d/100-timezone.ini ]; then
echo "date.timezone=$TZ" > /etc/php/7.4/cli/conf.d/100-timezone.ini
if [ ! -f /etc/php/8.1/cli/conf.d/100-timezone.ini ]; then
echo "date.timezone=${TZ}" > /etc/php/8.1/cli/conf.d/100-timezone.ini
fi

if [ ! -f /etc/php/7.4/fpm/conf.d/100-timezone.ini ]; then
echo "date.timezone=$TZ" > /etc/php/7.4/fpm/conf.d/100-timezone.ini
if [ ! -f /etc/php/8.1/fpm/conf.d/100-timezone.ini ]; then
echo "date.timezone=${TZ}" > /etc/php/8.1/fpm/conf.d/100-timezone.ini
fi
fi
6 changes: 6 additions & 0 deletions post_install/etc/my_init.d/librenms_104_php_fpm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh -eu

configFile=/etc/php/8.1/fpm/pool.d/www.conf

sed -i "s/PLACEHOLDER_MAX_WORKERS/${PHP_FPM_WORKERS_MAX}/g" "$configFile"
sed -i "s/PLACEHOLDER_MIN_WORKERS/${PHP_FPM_WORKERS_MIN}/g" "$configFile"
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash -eu
# Bash supports the ${!...} construct for indirect variable expansion

function requireConfig() {
requireConfig () {
if [ -z ${!1:-} ]; then
echo "Error: $1 is unset" >&2
exit 1
Expand Down Expand Up @@ -40,19 +41,7 @@ fi
requireConfig DB_NAME
requireConfig BASE_URL

# Deprecated legacy config support
# TODO remove legacy config

if [ -f /opt/librenms/config.custom.php ]; then
echo -e "\033[1;33mWARNING: Detected deprecated config.custom.php file, please check the docs\033[0m" >&2

echo "<?php" > /opt/librenms/conf.internal.d/config.custom.php
cat /opt/librenms/config.custom.php >> /opt/librenms/conf.internal.d/config.custom.php
chown librenms:librenms /opt/librenms/conf.internal.d/config.custom.php
fi


# Generate Laravel .env file from legacy config
# Generate Laravel .env file
COMPOSER_PROCESS_TIMEOUT=3600 APP_ENV=local /sbin/setuser librenms composer run-script post-install-cmd -d /opt/librenms

# Not deleting the directory causes validation errors in LibreNMS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -eu
#!/bin/sh -eu

if [ ! -f /opt/librenms/logs/.gitignore ]; then
cp /opt/helpers/default_files/logs/.gitignore /opt/librenms/logs/.gitignore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash -e
#!/bin/sh -e

LOCK_FILE=/var/lock/librenms_services.lock

Expand Down
Loading

0 comments on commit 2ecb60f

Please sign in to comment.