diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..b03b075e75647928400c5f93af5f67fa6f9215bc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,27 @@ +##### Project related files ##### +config/config.json +Dockerfile +README.md +.git/ + +##### Python related files ##### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# pyenv +.python-version + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..207f4f6e5f4ec94844c90a994bc7e4cd3e4afb53 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,14 @@ +FROM python:3.7-alpine + +MAINTAINER kyane@kyane.fr + +# Copy all code +COPY . /code +WORKDIR /code + +# Install dependencies +RUN pip3 install -r requirements.txt + +VOLUME /code/config/config.json + +ENTRYPOINT ["/code/entrypoint.sh"] diff --git a/README.md b/README.md index 169d9acc33a3ab944752da9a4dc00cad44c40e4e..7c96717fdf7b61602d9194f0d43c468dbae83d7f 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,10 @@ Configuration for InfluxDB is under the `influxdb` key. It is a simple object wi ### Docker +A simple Docker image is provided in order to run this bot on a regular basis. It is a simple Python 3 (Alpine based) Docker image with all the requirements. The entrypoint is quite simple : a while loop that call the `main.py` script and sleep for some times. The interval to sleep between each calls can be configured with the environment variable `INTERVAL_SECONDS` (default to `60`). + +Also, don't forget to mount your configuration file on `/code/config/config.json` + ## Modules This bot is modular : each module provide an interface allow to collect metrics for a service. The main function use those modules and push all data to InfluxDB. diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000000000000000000000000000000000000..55700c1d12f2fa4a8232f18942137d40a9a214f8 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +INTERVAL_SECONDS=${INTERVAL_SECONDS:-60} + +while : +do + python3 main.py + sleep $INTERVAL_SECONDS +done