Skip to content

Commit

Permalink
Pre-install all contrib plugins (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
satterly authored May 2, 2019
1 parent 7927ff6 commit 78484c4
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 38 deletions.
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir virtualenv && \
virtualenv --python=python3 /venv && \
/venv/bin/pip install -r /app/requirements.txt
ENV PATH $PATH:/venv/bin

RUN /venv/bin/pip install alerta alerta-server==$VERSION
ENV PATH $PATH:/venv/bin
COPY install-plugins.sh /app/install-plugins.sh
COPY plugins.txt /app/plugins.txt
RUN /app/install-plugins.sh

ADD https://github.com/alerta/alerta-webui/releases/download/v${VERSION}/alerta-webui.tar.gz /tmp/webui.tar.gz
RUN tar zxvf /tmp/webui.tar.gz -C /tmp && \
Expand All @@ -60,7 +63,6 @@ ENV ALERTA_WEB_CONF_FILE /web/config.json
ENV HEARTBEAT_SEVERITY major

ENV BASE_URL /api
ENV INSTALL_PLUGINS ""

EXPOSE 8080

Expand Down
25 changes: 9 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ the `alerta-web` container specifically for Docker deployments:
`ADMIN_KEY`
- sets an admin API key.

`INSTALL_PLUGINS`
- list of plugins to automatically install.

`HEARTBEAT_SEVERITY`
- severity used to create alerts for stale heartbeats

Expand Down Expand Up @@ -121,26 +118,23 @@ To set configuration settings not supported by environment variables use
configuration files instead. For example:

$ docker run -v $PWD/config/alertad.conf:/app/alertad.conf \
-v $PWD/config/config.js:/app/config.js \
-v $PWD/config/config.json:/web/config.json \
-p <port>:8080 alerta/alerta-web

For a full list of server configuration options see https://docs.alerta.io.

Installing Plugins
------------------
Plugins
-------

Plugins listed in the `INSTALL_PLUGINS` environment variable will be installed
automatically at container start time. Only plugins listed in `PLUGINS` will be
enabled. This allows plugins to be installed and enabled at a later time.
All built-in and contributed plugins are installed at image build time. Only
plugins listed in `PLUGINS` environment variabled will be enabled.

In the example below, the `reject` and `blackout` plugins are installed by
default, the `slack` and `prometheus` plugins are also installed but of the
two only the `slack` plugin is enabled:
In the example below, of all the plugins installed only those listed will
be enabled at container start time:

PLUGINS=reject,blackout,slack
INSTALL_PLUGINS=slack,prometheus
PLUGINS=remote_ip,reject,heartbeat,blackout,slack,prometheus

Alternatively, install all wanted plugins as an additional image layer.
Custom plugins should be installed as an additional image layer.

Authentication
--------------
Expand Down Expand Up @@ -201,7 +195,6 @@ services:
- AUTH_REQUIRED=True
- [email protected],[email protected]
- PLUGINS=reject,blackout,normalise,enhance
- INSTALL_PLUGINS=normalise,enhance
restart: always
db:
image: postgres
Expand Down
1 change: 0 additions & 1 deletion docker-compose.simple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ services:
- AUTH_REQUIRED=True
- [email protected],[email protected]
- PLUGINS=reject,blackout,normalise,enhance
- INSTALL_PLUGINS=normalise,enhance
restart: always
db:
image: postgres
Expand Down
5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: '3.1'
services:
web:
# build: .
build: .
image: alerta/alerta-web
# volumes:
# - $PWD/config/alertad.conf.example:/app/alertad.conf
# - $PWD/config/alerta.conf.example:/app/alerta.conf
# - $PWD/config/config.js.example:/web/config.js
# - $PWD/config/config.json.example:/web/config.json
ports:
- 8080:8080
depends_on:
Expand All @@ -23,5 +23,4 @@ services:
- "SEVERITY={'fatal': 0}"
- TRACKING_ID=UA-44644195-6
- PLUGINS=reject,heartbeat,blackout,normalise,enhance
- INSTALL_PLUGINS=normalise,enhance
restart: always
17 changes: 4 additions & 13 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash
set -x

RUN_ONCE=/app/.run_once
set -e

# Generate web console config, if not supplied
if [ ! -f "${ALERTA_WEB_CONF_FILE}" ]; then
Expand All @@ -15,7 +13,10 @@ SECRET_KEY = '$(< /dev/urandom tr -dc A-Za-z0-9_\!\@\#\$\%\^\&\*\(\)-+= | head -
EOF
fi

RUN_ONCE=/app/.run_once

if [ ! -f "${RUN_ONCE}" ]; then
touch ${RUN_ONCE}
# Set base path
BASE_PATH=$(echo "/"${BASE_URL#*//*/} | tr -s /)
sed -i 's@!BASE_PATH!@'"${BASE_PATH}"'@' /app/uwsgi.ini
Expand All @@ -38,16 +39,6 @@ if [ ! -f "${RUN_ONCE}" ]; then
alertad key --username $(echo ${ADMIN_USERS} | cut -d, -f1) --key ${ADMIN_KEY}
fi
fi

# Install plugins
IFS_BCK=${IFS}
IFS=","
for plugin in ${INSTALL_PLUGINS}; do
echo "Installing plugin '${plugin}'"
/venv/bin/pip install git+https://github.com/alerta/alerta-contrib.git#subdirectory=plugins/$plugin
done
echo "BASE_URL=${BASE_URL}" > ${RUN_ONCE}
IFS=${IFS_BCK}
fi

# Generate client config, if not supplied
Expand Down
1 change: 0 additions & 1 deletion examples/gitlab/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ services:
- OAUTH2_CLIENT_SECRET=06b850ce35a171397e31b8ae85253450a5127049886e42cc670722ca2aa837ed
- GOOGLE_TRACKING_ID=UA-44644195-6
- PLUGINS=remote_ip,reject,heartbeat,blackout,normalise,enhance
- INSTALL_PLUGINS=normalise,enhance
restart: always

db:
Expand Down
1 change: 0 additions & 1 deletion examples/ldap/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ services:
- AUTH_REQUIRED=True
- [email protected],[email protected]
- PLUGINS=reject,blackout,normalise,enhance
- INSTALL_PLUGINS=normalise,enhance
restart: always
db:
image: postgres
Expand Down
1 change: 0 additions & 1 deletion examples/nagios/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ services:
- ADMIN_KEY=demo-key
- TRACKING_ID=UA-44644195-6
- PLUGINS=reject,heartbeat,blackout,normalise,enhance
- INSTALL_PLUGINS=normalise,enhance
restart: always

db:
Expand Down
6 changes: 6 additions & 0 deletions install-plugins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

while read plugin version; do
echo "Installing '${plugin}' (${version})"
/venv/bin/pip install git+https://github.com/alerta/alerta-contrib.git@${version}#subdirectory=${plugin}
done </app/plugins.txt
24 changes: 24 additions & 0 deletions plugins.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
plugins/amqp master
plugins/cachet master
plugins/enhance master
plugins/forward master
plugins/geoip master
plugins/hipchat master
plugins/influxdb master
plugins/logstash master
plugins/mattermost master
plugins/msteams master
plugins/normalise master
plugins/op5 master
plugins/opsgenie master
plugins/pagerduty master
plugins/prometheus master
plugins/pubsub master
plugins/pushover master
plugins/rocketchat master
plugins/slack master
plugins/sns master
plugins/syslog master
plugins/telegram master
plugins/twilio master
plugins/zabbix master

0 comments on commit 78484c4

Please sign in to comment.