diff --git a/Dockerfile b/Dockerfile index 1f83f624..6dd97cfb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +ARG ELASTALERT_HOME=/opt/elastalert + FROM alpine:latest as py-ea ARG ELASTALERT_VERSION=v0.1.38 ENV ELASTALERT_VERSION=${ELASTALERT_VERSION} @@ -5,7 +7,7 @@ ENV ELASTALERT_VERSION=${ELASTALERT_VERSION} ARG ELASTALERT_URL=https://github.com/Yelp/elastalert/archive/$ELASTALERT_VERSION.zip ENV ELASTALERT_URL=${ELASTALERT_URL} # Elastalert home directory full path. -ENV ELASTALERT_HOME /opt/elastalert +ARG ELASTALERT_HOME WORKDIR /opt @@ -21,29 +23,32 @@ WORKDIR "${ELASTALERT_HOME}" # Install Elastalert. # see: https://github.com/Yelp/elastalert/issues/1654 RUN sed -i 's/jira>=1.0.10/jira>=1.0.10,<1.0.15/g' setup.py && \ - python setup.py install && \ - pip install -r requirements.txt + pip install -r requirements.txt && \ + python setup.py install FROM node:alpine LABEL maintainer="BitSensor " # Set timezone for this container ENV TZ Etc/UTC +# Elastalert home directory full path. +ARG ELASTALERT_HOME RUN apk add --update --no-cache curl tzdata python2 make libmagic COPY --from=py-ea /usr/lib/python2.7/site-packages /usr/lib/python2.7/site-packages -COPY --from=py-ea /opt/elastalert /opt/elastalert +COPY --from=py-ea "${ELASTALERT_HOME}" "${ELASTALERT_HOME}" COPY --from=py-ea /usr/bin/elastalert* /usr/bin/ WORKDIR /opt/elastalert-server COPY . /opt/elastalert-server RUN npm install --production --quiet -COPY config/elastalert.yaml /opt/elastalert/config.yaml -COPY config/elastalert-test.yaml /opt/elastalert/config-test.yaml +COPY config/elastalert.yaml "${ELASTALERT_HOME}"/config.yaml +COPY config/elastalert-test.yaml "${ELASTALERT_HOME}"/config-test.yaml COPY config/config.json config/config.json -COPY rule_templates/ /opt/elastalert/rule_templates -COPY elastalert_modules/ /opt/elastalert/elastalert_modules +RUN sed -i "s|ELASTALERT_HOME|${ELASTALERT_HOME}|" config/config.json +COPY rule_templates/ "${ELASTALERT_HOME}"/rule_templates +COPY elastalert_modules/ "${ELASTALERT_HOME}"/elastalert_modules EXPOSE 3030 ENTRYPOINT ["npm", "start"] diff --git a/config/config.json b/config/config.json index d3afcf46..30395857 100644 --- a/config/config.json +++ b/config/config.json @@ -1,7 +1,7 @@ { "appName": "elastalert-server", "port": 3030, - "elastalertPath": "/opt/elastalert", + "elastalertPath": "ELASTALERT_HOME", "verbose": false, "es_debug": false, "debug": false,