diff --git a/README.md b/README.md index 15f52c0..12e4713 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

+

Latest Version @@ -25,7 +25,7 @@ It's a fork of [CrazyMax's LibreNMS Docker image repository](https://github.com/ * Ability to configure [distributed polling](https://docs.librenms.org/#Extensions/Distributed-Poller/#distributed-poller) * Ability to add custom Monitoring plugins (Nagios) * OPCache enabled to store precompiled script bytecode in shared memory -* [Traefik](https://github.com/containous/traefik-library-image) as reverse proxy and creation/renewal of Let's Encrypt certificates +* [Traefik](https://github.com/containous/traefik-library-image) as reverse proxy and creation/renewal of Let's Encrypt certificates (see [this template](examples/traefik)) * [Memcached](https://github.com/docker-library/memcached) image ready to use for better scalability * [RRDcached](https://github.com/crazy-max/docker-rrdcached) image ready to use for better scalability * [Postfix SMTP relay](https://github.com/juanluisbaptiste/docker-postfix) image to send emails diff --git a/doc/usage.md b/doc/usage.md index 3a7d3ba..702ff94 100644 --- a/doc/usage.md +++ b/doc/usage.md @@ -2,11 +2,9 @@ ### Docker Compose -Docker compose is the recommended way to run this image. Copy the content of folder [examples/compose](../examples/compose) in `/var/librenms/` on your host for example. Edit the compose and env files with your preferences and run the following commands : +Docker compose is the recommended way to run this image. Copy the content of folder [examples/compose](../examples/compose) in `/var/librenms/` on your host for example. Edit the compose and env files with your preferences and run the following commands: ```bash -touch acme.json -chmod 600 acme.json docker-compose up -d docker-compose logs -f ``` diff --git a/examples/compose/docker-compose.yml b/examples/compose/docker-compose.yml index 2a4099e..6601c84 100644 --- a/examples/compose/docker-compose.yml +++ b/examples/compose/docker-compose.yml @@ -1,37 +1,6 @@ version: "3.5" services: - traefik: - image: traefik:1.7-alpine - container_name: traefik - command: - - "--logLevel=INFO" - - "--defaultentrypoints=http,https" - - "--entryPoints=Name:http Address::80 Redirect.EntryPoint:https" - - "--entryPoints=Name:https Address::443 TLS" - - "--docker" - - "--docker.exposedbydefault=false" - - "--docker.domain=example.com" - - "--acme=true" - - "--acme.acmelogging=true" - - "--acme.email=webmaster@example.com" - - "--acme.storage=acme.json" - - "--acme.entryPoint=https" - - "--acme.onhostrule=true" - - "--acme.httpchallenge=true" - - "--acme.httpchallenge.entrypoint=http" - ports: - - target: 80 - published: 80 - protocol: tcp - - target: 443 - published: 443 - protocol: tcp - volumes: - - "./acme.json:/acme.json" - - "/var/run/docker.sock:/var/run/docker.sock" - restart: always - db: image: mariadb:10.2 container_name: librenms_db @@ -91,6 +60,10 @@ services: container_name: librenms domainname: example.com hostname: librenms + ports: + - target: 80 + published: 80 + protocol: tcp depends_on: - db - memcached @@ -98,11 +71,6 @@ services: - smtp volumes: - "./librenms:/data" - labels: - - "traefik.enable=true" - - "traefik.backend=librenms" - - "traefik.port=80" - - "traefik.frontend.rule=Host:librenms.example.com" environment: - "TZ=${TZ}" - "PUID=${PUID}" diff --git a/examples/traefik/.env b/examples/traefik/.env new file mode 100644 index 0000000..a847768 --- /dev/null +++ b/examples/traefik/.env @@ -0,0 +1,11 @@ +MYSQL_DATABASE=librenms +MYSQL_USER=librenms +MYSQL_PASSWORD=asupersecretpassword + +SMTP_SERVER=smtp.example.com +SMTP_USERNAME=smtp@example.com +SMTP_PASSWORD= + +TZ=Europe/Paris +PUID=1000 +PGID=1000 diff --git a/examples/traefik/docker-compose.yml b/examples/traefik/docker-compose.yml new file mode 100644 index 0000000..2a4099e --- /dev/null +++ b/examples/traefik/docker-compose.yml @@ -0,0 +1,170 @@ +version: "3.5" + +services: + traefik: + image: traefik:1.7-alpine + container_name: traefik + command: + - "--logLevel=INFO" + - "--defaultentrypoints=http,https" + - "--entryPoints=Name:http Address::80 Redirect.EntryPoint:https" + - "--entryPoints=Name:https Address::443 TLS" + - "--docker" + - "--docker.exposedbydefault=false" + - "--docker.domain=example.com" + - "--acme=true" + - "--acme.acmelogging=true" + - "--acme.email=webmaster@example.com" + - "--acme.storage=acme.json" + - "--acme.entryPoint=https" + - "--acme.onhostrule=true" + - "--acme.httpchallenge=true" + - "--acme.httpchallenge.entrypoint=http" + ports: + - target: 80 + published: 80 + protocol: tcp + - target: 443 + published: 443 + protocol: tcp + volumes: + - "./acme.json:/acme.json" + - "/var/run/docker.sock:/var/run/docker.sock" + restart: always + + db: + image: mariadb:10.2 + container_name: librenms_db + command: + - "mysqld" + - "--sql-mode=" + - "--innodb-file-per-table=1" + - "--lower-case-table-names=0" + - "--character-set-server=utf8" + - "--collation-server=utf8_unicode_ci" + volumes: + - "./db:/var/lib/mysql" + environment: + - "TZ=${TZ}" + - "MYSQL_ALLOW_EMPTY_PASSWORD=yes" + - "MYSQL_DATABASE=${MYSQL_DATABASE}" + - "MYSQL_USER=${MYSQL_USER}" + - "MYSQL_PASSWORD=${MYSQL_PASSWORD}" + restart: always + + memcached: + image: memcached:alpine + container_name: librenms_memcached + environment: + - "TZ=${TZ}" + restart: always + + rrdcached: + image: crazymax/rrdcached + container_name: librenms_rrdcached + volumes: + - "./librenms/rrd:/data/db" + - "./rrd-journal:/data/journal" + environment: + - "TZ=${TZ}" + - "LOG_LEVEL=LOG_INFO" + - "WRITE_TIMEOUT=1800" + - "WRITE_JITTER=1800" + - "WRITE_THREADS=4" + - "FLUSH_DEAD_DATA_INTERVAL=3600" + restart: always + + smtp: + image: juanluisbaptiste/postfix + container_name: librenms_smtp + volumes: + - "/etc/localtime:/etc/localtime:ro" + environment: + - "SERVER_HOSTNAME=librenms.example.com" + - "SMTP_SERVER=${SMTP_SERVER}" + - "SMTP_USERNAME=${SMTP_USERNAME}" + - "SMTP_PASSWORD=${SMTP_PASSWORD}" + restart: always + + librenms: + image: librenms/librenms:latest + container_name: librenms + domainname: example.com + hostname: librenms + depends_on: + - db + - memcached + - rrdcached + - smtp + volumes: + - "./librenms:/data" + labels: + - "traefik.enable=true" + - "traefik.backend=librenms" + - "traefik.port=80" + - "traefik.frontend.rule=Host:librenms.example.com" + environment: + - "TZ=${TZ}" + - "PUID=${PUID}" + - "PGID=${PGID}" + - "DB_HOST=db" + - "DB_NAME=${MYSQL_DATABASE}" + - "DB_USER=${MYSQL_USER}" + - "DB_PASSWORD=${MYSQL_PASSWORD}" + - "DB_TIMEOUT=30" + env_file: + - "./librenms.env" + restart: always + + cron: + image: librenms/librenms:latest + container_name: librenms_cron + domainname: example.com + hostname: librenms + depends_on: + - librenms + volumes: + - "./librenms:/data" + environment: + - "TZ=${TZ}" + - "PUID=${PUID}" + - "PGID=${PGID}" + - "DB_HOST=db" + - "DB_NAME=${MYSQL_DATABASE}" + - "DB_USER=${MYSQL_USER}" + - "DB_PASSWORD=${MYSQL_PASSWORD}" + - "DB_TIMEOUT=30" + - "SIDECAR_CRON=1" + env_file: + - "./librenms.env" + restart: always + + syslog-ng: + image: librenms/librenms:latest + container_name: librenms_syslog + domainname: example.com + hostname: librenms + depends_on: + - librenms + ports: + - target: 514 + published: 514 + protocol: tcp + - target: 514 + published: 514 + protocol: udp + volumes: + - "./librenms:/data" + environment: + - "TZ=${TZ}" + - "PUID=${PUID}" + - "PGID=${PGID}" + - "DB_HOST=db" + - "DB_NAME=${MYSQL_DATABASE}" + - "DB_USER=${MYSQL_USER}" + - "DB_PASSWORD=${MYSQL_PASSWORD}" + - "DB_TIMEOUT=30" + - "SIDECAR_SYSLOGNG=1" + env_file: + - "./librenms.env" + restart: always diff --git a/examples/traefik/librenms.env b/examples/traefik/librenms.env new file mode 100644 index 0000000..d200733 --- /dev/null +++ b/examples/traefik/librenms.env @@ -0,0 +1,23 @@ +MEMORY_LIMIT=256M +UPLOAD_MAX_SIZE=16M +OPCACHE_MEM_SIZE=128 +REAL_IP_FROM=0.0.0.0/32 +REAL_IP_HEADER=X-Forwarded-For +LOG_IP_VAR=http_x_forwarded_for + +LIBRENMS_POLLER_THREADS=16 +LIBRENMS_POLLER_INTERVAL=5 + +LIBRENMS_CRON_DISCOVERY_ENABLE=true +LIBRENMS_CRON_DAILY_ENABLE=true +LIBRENMS_CRON_ALERTS_ENABLE=true +LIBRENMS_CRON_BILLING_ENABLE=true +LIBRENMS_CRON_BILLING_CALCULATE_ENABLE=true +LIBRENMS_CRON_CHECK_SERVICES_ENABLE=true +LIBRENMS_CRON_POLLER_ENABLE=true + +LIBRENMS_SNMP_COMMUNITY=librenmsdocker +MEMCACHED_HOST=memcached +MEMCACHED_PORT=11211 +RRDCACHED_HOST=rrdcached +RRDCACHED_PORT=42217