From 14f92d7c741ce30f5d8ad2dcb0a44148f3e21323 Mon Sep 17 00:00:00 2001 From: Alvaro Olmedo Date: Fri, 1 Mar 2019 12:58:18 +0100 Subject: [PATCH 1/6] var to define elastalert_home used --- Dockerfile | 19 +++++++++++++------ config/config.json | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1f83f624..aa489d33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +ARG ELASTALERT_HOME_GLOBAL=/opt/elastalert + FROM alpine:latest as py-ea ARG ELASTALERT_VERSION=v0.1.38 ENV ELASTALERT_VERSION=${ELASTALERT_VERSION} @@ -5,7 +7,8 @@ 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 +ENV ELASTALERT_HOME=$ELASTALERT_HOME_GLOBAL WORKDIR /opt @@ -28,22 +31,26 @@ FROM node:alpine LABEL maintainer="BitSensor " # Set timezone for this container ENV TZ Etc/UTC +# Elastalert home directory full path. +ARG ELASTALERT_HOME +ENV ELASTALERT_HOME=$ELASTALERT_HOME_GLOBAL 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, From 48d64f90cae9210286728d36cb532fd1bdda5320 Mon Sep 17 00:00:00 2001 From: Alvaro Olmedo Date: Fri, 1 Mar 2019 13:06:19 +0100 Subject: [PATCH 2/6] Typo fixed --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index aa489d33..d221d0c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,7 @@ ARG ELASTALERT_URL=https://github.com/Yelp/elastalert/archive/$ELASTALERT_VERSIO ENV ELASTALERT_URL=${ELASTALERT_URL} # Elastalert home directory full path. ARG ELASTALERT_HOME -ENV ELASTALERT_HOME=$ELASTALERT_HOME_GLOBAL +ENV ELASTALERT_HOME=${ELASTALERT_HOME_GLOBAL} WORKDIR /opt @@ -33,7 +33,7 @@ LABEL maintainer="BitSensor " ENV TZ Etc/UTC # Elastalert home directory full path. ARG ELASTALERT_HOME -ENV ELASTALERT_HOME=$ELASTALERT_HOME_GLOBAL +ENV ELASTALERT_HOME=${ELASTALERT_HOME_GLOBAL} RUN apk add --update --no-cache curl tzdata python2 make libmagic From 15cf9509a5b9aab37b9372cdec74c31f43b99bcc Mon Sep 17 00:00:00 2001 From: Alvaro Olmedo Date: Fri, 1 Mar 2019 13:13:08 +0100 Subject: [PATCH 3/6] dockerfile fixed --- Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index d221d0c1..63813436 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG ELASTALERT_HOME_GLOBAL=/opt/elastalert +ARG ELASTALERT_HOME=/opt/elastalert FROM alpine:latest as py-ea ARG ELASTALERT_VERSION=v0.1.38 @@ -8,7 +8,6 @@ ARG ELASTALERT_URL=https://github.com/Yelp/elastalert/archive/$ELASTALERT_VERSIO ENV ELASTALERT_URL=${ELASTALERT_URL} # Elastalert home directory full path. ARG ELASTALERT_HOME -ENV ELASTALERT_HOME=${ELASTALERT_HOME_GLOBAL} WORKDIR /opt @@ -17,6 +16,7 @@ RUN apk add --update --no-cache ca-certificates openssl-dev openssl python2-dev wget -O elastalert.zip "${ELASTALERT_URL}" && \ unzip elastalert.zip && \ rm elastalert.zip && \ + echo "${ELASTALERT_HOME}" && \ mv e* "${ELASTALERT_HOME}" WORKDIR "${ELASTALERT_HOME}" @@ -33,7 +33,6 @@ LABEL maintainer="BitSensor " ENV TZ Etc/UTC # Elastalert home directory full path. ARG ELASTALERT_HOME -ENV ELASTALERT_HOME=${ELASTALERT_HOME_GLOBAL} RUN apk add --update --no-cache curl tzdata python2 make libmagic From 2b707c4d17b5d072e1ffda9f2837f1b00a8a866b Mon Sep 17 00:00:00 2001 From: Alvaro Olmedo Date: Fri, 1 Mar 2019 13:25:27 +0100 Subject: [PATCH 4/6] Solving problems with deps --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 63813436..7c3b8d75 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,8 +24,8 @@ 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 " From 5f3c7e5b0353f1c9ab7e2c55248cb6472401025e Mon Sep 17 00:00:00 2001 From: Alvaro Olmedo Date: Fri, 1 Mar 2019 14:02:06 +0100 Subject: [PATCH 5/6] Echo removed --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7c3b8d75..2ce8a870 100644 --- a/Dockerfile +++ b/Dockerfile @@ -47,7 +47,7 @@ RUN npm install --production --quiet 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 -RUN sed -i 's|ELASTALERT_HOME|"${ELASTALERT_HOME}"|' config/config.json +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 From ce63e4e0a4141cd78f5db4ed0f7eed618b320deb Mon Sep 17 00:00:00 2001 From: Alvaro Olmedo Date: Fri, 1 Mar 2019 14:13:11 +0100 Subject: [PATCH 6/6] Double quoted --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2ce8a870..6dd97cfb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,6 @@ RUN apk add --update --no-cache ca-certificates openssl-dev openssl python2-dev wget -O elastalert.zip "${ELASTALERT_URL}" && \ unzip elastalert.zip && \ rm elastalert.zip && \ - echo "${ELASTALERT_HOME}" && \ mv e* "${ELASTALERT_HOME}" WORKDIR "${ELASTALERT_HOME}" @@ -47,7 +46,7 @@ RUN npm install --production --quiet 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 -RUN sed -i 's|ELASTALERT_HOME|${ELASTALERT_HOME}|' config/config.json +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