From 755c3c75d6bfbca4f534b43c7a8a3b6220bf0b90 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 7 Mar 2022 18:59:28 -0300 Subject: [PATCH] configurable email --- .woodpecker.yml | 5 ++++- Dockerfile | 5 ++++- monitrc | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 419e59e..5b41c20 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -7,11 +7,14 @@ pipeline: - ${ALPINE_VERSION} - latest build_args: + - EMAIL=${MONIT_EMAIL} + - EMAIL_FROM=${MONIT_EMAIL_FROM} - ALPINE_VERSION=${ALPINE_VERSION} - BASE_IMAGE=alpine username: sutty secrets: - - docker_password + - DOCKER_PASSWORD + - MONIT_EMAIL cache_from: registry.nulo.in/sutty/monit:${ALPINE_VERSION} docker: purge: false diff --git a/Dockerfile b/Dockerfile index dc02004..2bec62a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,17 @@ ARG ALPINE_VERSION=3.13.6 ARG BASE_IMAGE=alpine ARG EMAIL=monit@sutty.nl +ARG EMAIL_FROM=monit@sutty.nl FROM ${BASE_IMAGE}:${ALPINE_VERSION} as build -ENV EMAIL ${EMAIL:-monit@sutty.nl} +ARG EMAIL +ARG EMAIL_FROM RUN apk add --no-cache tzdata COPY ./monitrc /etc/monitrc RUN chmod 600 /etc/monitrc RUN sed -re "s/@@EMAIL@@/${EMAIL}/" -i /etc/monitrc +RUN sed -re "s/@@EMAIL_FROM@@/${EMAIL_FROM}/" -i /etc/monitrc FROM ${BASE_IMAGE}:${ALPINE_VERSION} ARG ALPINE_VERSION diff --git a/monitrc b/monitrc index 80a42f4..2408173 100644 --- a/monitrc +++ b/monitrc @@ -18,4 +18,10 @@ check program nsupdate every 1 cycle if status = 0 then unmonitor +set mail-format { + from: Monit <@@EMAIL_FROM@@> + subject: $SERVICE@$HOST + message: $ACTION $SERVICE -- $DATE -- $HOST: $DESCRIPTION. +} + include /etc/monit.d/*.conf