Add Dockerfile
Addresses #1535.
Tested with
# build Docker image
$ docker build . -t yelp/elastalert
...
# test Docker image by printing help output
$ docker run --rm yelp/elastalert:mine python -m elastalert -h
usage: elastalert.py [-h] [--config CONFIG] [--debug] [--rule RULE]
[--silence SILENCE] [--start START] [--end END]
[--verbose] [--patience TIMEOUT] [--pin_rules]
[--es_debug] [--es_debug_trace ES_DEBUG_TRACE]
...
Could a maintainer please set up a Docker automated build based off of this Dockerfile after merging? It should build from this Dockerfile with docker build . and tag it with each git commit and tag (release).
https://hub.docker.com/u/yelp/ https://docs.docker.com/docker-hub/builds/
@Qmando
@julianvmodesto This works for me, but only if the elastalert_* indices are already created in ES; what's the preferred way with this to run elastalert-create-index within the container? These, for example, don't work:
$ docker run --rm julianvmodesto/elastalert elastalert-create-index
Traceback (most recent call last):
...
ImportError: No module named elastalert.create_index
$ docker run --rm julianvmodesto/elastalert python -m elastalert.create_index
/usr/bin/python: No module named elastalert.create_index
This is the best I've found, but seems unwieldy:
$ docker run --rm julianvmodesto/elastalert python /opt/elastalert/create_index.py --host $ESHOST --port 9200 --no-ssl --no-auth --url-prefix '' --index elastalert --old-index ''
Here's a bit improved Dockerfile based on https://github.com/bitsensor/elastalert/blob/master/Dockerfile
FROM alpine:3.8 as build
ENV ELASTALERT_HOME /opt/elastalert
WORKDIR "${ELASTALERT_HOME}"
RUN apk add --update --no-cache ca-certificates openssl-dev openssl python2-dev python2 py2-pip py2-yaml libffi-dev gcc musl-dev libmagic
COPY . ./
RUN pip install --upgrade pip && \
pip install -r requirements.txt && \
python setup.py install
RUN elastalert-test-rule --help && elastalert --help
# Multistage build, copy build results from first intermediate image
FROM alpine:3.8
ENV ELASTALERT_HOME /opt/elastalert
WORKDIR "${ELASTALERT_HOME}"
RUN apk add --update --no-cache python2 libmagic
COPY --from=build /usr/lib/python2.7/site-packages /usr/lib/python2.7/site-packages
COPY --from=build /opt/elastalert /opt/elastalert
COPY --from=build /usr/bin/elastalert* /usr/bin/
ENTRYPOINT ["/usr/bin/elastalert"]
@Qmando Any update on this being merged?