From dd938835c8c12d23a36b5fffc630b194282671ce Mon Sep 17 00:00:00 2001 From: Kevin Eaton Date: Fri, 16 Mar 2018 17:20:03 -0400 Subject: [PATCH 1/2] Added basic docker support --- Dockerfile | 6 ++++++ README.md | 13 +++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..786ceba --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM python:3 + +RUN pip install --no-cache-dir minitor +WORKDIR /app +COPY config.yml /app/config.yml +CMD minitor \ No newline at end of file diff --git a/README.md b/README.md index aae97d0..b41de2c 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,19 @@ make run It will read the contents of `config.yml` and begin its loop. You could also run it directly and provide a new config file via the `--config` argument. + +#### Docker + +You can pull this repository directly from Docker: + +`docker pull kevineaton/minitor` + +The Docker image uses a default `config.yml` that simply pings a server every 30 seconds with exponential backup. This is likely not what you want, so when you run the Docker image, you should supply your own `config.yml` file: + +`docker run -v $PWD/config.yml:/app/config.yml kevineaton/minitor` + +Note that the image uses the version of minitor in `pip` and does not build from source. + ### Configuring In this repo, you can explore the `sample-config.yml` file for an example, but the general structure is as follows. It should be noted that environment variable interpolation happens on load of the YAML file. Also, when alerts are executed, they will be passed through Python's format function with arguments for some attributes of the Monitor. Currently this is limited to `{monitor_name}`. From f4952b61d113f21f3e96a82c2ea315b751ac2f68 Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Tue, 17 Apr 2018 21:01:58 -0700 Subject: [PATCH 2/2] Update Dockerfile to build the current working copy This will allow `latest` to be `master` and allow git tags to dictate tagged versions on Docker. Also update readme to describe how it's now building --- .dockerignore | 6 ++++++ Dockerfile | 13 ++++++++++--- Makefile | 5 +++++ README.md | 8 +++----- 4 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9e09577 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +*$py.class +*.egg +*.egg-info/ +*.py[cod] +*.so +**/__pycache__/ diff --git a/Dockerfile b/Dockerfile index 786ceba..12f249f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,13 @@ FROM python:3 +LABEL maintainer="ian@iamthefij.com" +# Minitor: https://git.iamthefij.com/iamthefij/minitor -RUN pip install --no-cache-dir minitor +COPY ./sample-config.yml /app/config.yml WORKDIR /app -COPY config.yml /app/config.yml -CMD minitor \ No newline at end of file + +COPY ./README.md /app/ +COPY ./setup.py /app/ +COPY ./minitor /app/minitor +RUN pip install -e . + +ENTRYPOINT python -m minitor.main diff --git a/Makefile b/Makefile index b23d769..84c91e8 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +DOCKER_TAG := minitor-dev OPEN_CMD := $(shell type xdg-open > /dev/null && echo 'xdg-open' || echo 'open') .PHONY: default @@ -80,3 +81,7 @@ htmlcov/index.html: .coverage .PHONY: open-coverage open-coverage: htmlcov/index.html $(OPEN_CMD) htmlcov/index.html + +.PHONY: docker-build +docker-build: + docker build . -t $(DOCKER_TAG) diff --git a/README.md b/README.md index b41de2c..343e7de 100644 --- a/README.md +++ b/README.md @@ -34,13 +34,11 @@ It will read the contents of `config.yml` and begin its loop. You could also run You can pull this repository directly from Docker: -`docker pull kevineaton/minitor` +`docker pull iamthefij/minitor` -The Docker image uses a default `config.yml` that simply pings a server every 30 seconds with exponential backup. This is likely not what you want, so when you run the Docker image, you should supply your own `config.yml` file: +The Docker image uses a default `config.yml` that is copied from `sample-config.yml`. This won't really do anything for you, so when you run the Docker image, you should supply your own `config.yml` file: -`docker run -v $PWD/config.yml:/app/config.yml kevineaton/minitor` - -Note that the image uses the version of minitor in `pip` and does not build from source. +`docker run -v $PWD/config.yml:/app/config.yml iamthefij/minitor` ### Configuring