diff --git a/Dockerfile b/Dockerfile index d2b3f54..fc8f879 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,6 +9,7 @@ ENV MONIT_VERSION=5.26.0 \ PATH=$PATH:/opt/monit/bin COPY slack /bin/slack +COPY pushover /bin/pushover # Compile and install monit RUN \ @@ -23,4 +24,8 @@ RUN \ EXPOSE 2812 +COPY docker-entrypoint.sh /usr/local/bin/ +RUN ln -s /usr/local/bin/docker-entrypoint.sh /entrypoint.sh # backwards compat +ENTRYPOINT ["/entrypoint.sh"] + CMD ["monit", "-I", "-B"] diff --git a/README.md b/README.md index 494dd59..7ff395d 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,15 @@ Docker documentation: https://docs.docker.com/ - build docker image `docker build -t monit .` - start monit: `docker run -ti -p 2812:2812 -v $(pwd)/monitrc:/etc/monitrc monit` +## ENV VARS + +| ENVs | Description | +|----------------- |---------------------------------------------------------- | +| SLACK_URL | Webhook url for slack notifications (required for slack) | +| PUSH_OVER_TOKEN | Push over api token (required for pushover) | +| PUSH_OVER_USER | Push over api user (requiredfor pushover) | +| DEBUG | If set with 1 it will put monit in verbose mode | + ### Docker Hub image - pull docker image from docker hub: `docker pull diogopms/monit-docker-kubernetes` @@ -24,6 +33,7 @@ Docker documentation: https://docs.docker.com/ - create a docker container: ``` +#Normal mode (support slack and pushover) docker run -it \ -p 2812:2812 \ -v $(pwd)/monitrc:/etc/monitrc \ @@ -31,6 +41,16 @@ docker run -it \ -e "PUSH_OVER_TOKEN=" \ -e "PUSH_OVER_USER=" \ diogopms/monit-docker-kubernetes + +#Debug mode +docker run -it \ + -p 2812:2812 \ + -v $(pwd)/monitrc:/etc/monitrc \ + -e "SLACK_URL=" \ + -e "PUSH_OVER_TOKEN=" \ + -e "PUSH_OVER_USER=" \ + -e "DEBUG=1" \ + diogopms/monit-docker-kubernetes ``` ### Example monitrc (Slack) @@ -78,6 +98,8 @@ EOF - [Slack](https://www.slack.com) - [Pushover](https://pushover.net) +### Kubernetes + ### Troubleshooting If when starting Monit returns the following message: `The control file '/etc/monitrc' permission 0755 is wrong, maximum 0700 allowed`, simply give the appropriate permissions to _monitrc_: `chmod 700 monitrc`. diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..df67ceb --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ "$DEBUG" = "1" ] +then + exec monit -I -B -v +else + exec "$@" +fi