elastalert icon indicating copy to clipboard operation
elastalert copied to clipboard

Add Dockerfile

Open julianvmodesto opened this issue 7 years ago • 5 comments

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]
...

julianvmodesto avatar Apr 12 '18 19:04 julianvmodesto

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/

julianvmodesto avatar Apr 12 '18 19:04 julianvmodesto

@Qmando

julianvmodesto avatar Apr 12 '18 19:04 julianvmodesto

@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 ''

hackery avatar Sep 04 '18 15:09 hackery

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"]

kshcherban avatar Sep 21 '18 09:09 kshcherban

@Qmando Any update on this being merged?

thommor avatar Jan 25 '19 08:01 thommor