configurable email

This commit is contained in:
f 2022-03-07 18:59:28 -03:00
parent 0c9ca5f55b
commit 755c3c75d6
3 changed files with 14 additions and 2 deletions

View file

@ -7,11 +7,14 @@ pipeline:
- ${ALPINE_VERSION} - ${ALPINE_VERSION}
- latest - latest
build_args: build_args:
- EMAIL=${MONIT_EMAIL}
- EMAIL_FROM=${MONIT_EMAIL_FROM}
- ALPINE_VERSION=${ALPINE_VERSION} - ALPINE_VERSION=${ALPINE_VERSION}
- BASE_IMAGE=alpine - BASE_IMAGE=alpine
username: sutty username: sutty
secrets: secrets:
- docker_password - DOCKER_PASSWORD
- MONIT_EMAIL
cache_from: registry.nulo.in/sutty/monit:${ALPINE_VERSION} cache_from: registry.nulo.in/sutty/monit:${ALPINE_VERSION}
docker: docker:
purge: false purge: false

View file

@ -1,14 +1,17 @@
ARG ALPINE_VERSION=3.13.6 ARG ALPINE_VERSION=3.13.6
ARG BASE_IMAGE=alpine ARG BASE_IMAGE=alpine
ARG EMAIL=monit@sutty.nl ARG EMAIL=monit@sutty.nl
ARG EMAIL_FROM=monit@sutty.nl
FROM ${BASE_IMAGE}:${ALPINE_VERSION} as build FROM ${BASE_IMAGE}:${ALPINE_VERSION} as build
ENV EMAIL ${EMAIL:-monit@sutty.nl} ARG EMAIL
ARG EMAIL_FROM
RUN apk add --no-cache tzdata RUN apk add --no-cache tzdata
COPY ./monitrc /etc/monitrc COPY ./monitrc /etc/monitrc
RUN chmod 600 /etc/monitrc RUN chmod 600 /etc/monitrc
RUN sed -re "s/@@EMAIL@@/${EMAIL}/" -i /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} FROM ${BASE_IMAGE}:${ALPINE_VERSION}
ARG ALPINE_VERSION ARG ALPINE_VERSION

View file

@ -18,4 +18,10 @@ check program nsupdate
every 1 cycle every 1 cycle
if status = 0 then unmonitor 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 include /etc/monit.d/*.conf