Skip to content

Commit d968b9c

Browse files
Merge branch 'deric-docker' into develop
2 parents 4e0af59 + 0609f26 commit d968b9c

File tree

3 files changed

+74
-4
lines changed

3 files changed

+74
-4
lines changed

Dockerfile

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,42 @@
1-
FROM ivankrizsan/elastalert AS py-ea
1+
FROM alpine:latest as py-ea
2+
ARG ELASTALERT_VERSION=v0.1.31
3+
ENV ELASTALERT_VERSION=${ELASTALERT_VERSION}
4+
# URL from which to download Elastalert.
5+
ARG ELASTALERT_URL=https://github.com/Yelp/elastalert/archive/$ELASTALERT_VERSION.zip
6+
ENV ELASTALERT_URL=${ELASTALERT_URL}
7+
# Elastalert home directory full path.
8+
ENV ELASTALERT_HOME /opt/elastalert
9+
10+
WORKDIR /opt
11+
12+
RUN apk add --update --no-cache ca-certificates openssl-dev openssl python2-dev python2 py2-pip py2-yaml libffi-dev gcc musl-dev wget && \
13+
# Download and unpack Elastalert.
14+
wget -O elastalert.zip "${ELASTALERT_URL}" && \
15+
unzip elastalert.zip && \
16+
rm elastalert.zip && \
17+
mv e* "${ELASTALERT_HOME}"
18+
19+
WORKDIR "${ELASTALERT_HOME}"
20+
21+
# Install Elastalert.
22+
# see: https://github.com/Yelp/elastalert/issues/1654
23+
RUN sed -i 's/jira>=1.0.10/jira>=1.0.10,<1.0.15/g' setup.py && \
24+
python setup.py install && \
25+
pip install -r requirements.txt
26+
227
FROM node:alpine
328
LABEL maintainer="BitSensor <[email protected]>"
4-
EXPOSE 3030
29+
# Set this environment variable to True to set timezone on container start.
30+
ENV SET_CONTAINER_TIMEZONE False
31+
# Default container timezone as found under the directory /usr/share/zoneinfo/.
32+
ENV CONTAINER_TIMEZONE Etc/UTC
533

6-
RUN apk add --update --no-cache python2 curl make
34+
RUN apk add --update --no-cache curl tzdata python2 make
735

836
COPY --from=py-ea /usr/lib/python2.7/site-packages /usr/lib/python2.7/site-packages
937
COPY --from=py-ea /opt/elastalert /opt/elastalert
38+
COPY --from=py-ea /usr/bin/elastalert* /usr/bin/
1039

11-
RUN mkdir server_data
1240
WORKDIR /opt/elastalert-server
1341
COPY . /opt/elastalert-server
1442

@@ -18,4 +46,5 @@ COPY config/config.json config/config.json
1846
COPY rule_templates/ /opt/elastalert/rule_templates
1947
COPY elastalert_modules/ /opt/elastalert/elastalert_modules
2048

49+
EXPOSE 3030
2150
ENTRYPOINT ["npm", "start"]

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
v ?= v0.1.31
2+
3+
all: build
4+
5+
build:
6+
docker pull alpine:latest && docker pull node:alpine
7+
docker build --build-arg ELASTALERT_VERSION=$(v) -t elastalert .
8+
9+
server: build
10+
docker run -it --rm -p 3030:3030 \
11+
--net="host" \
12+
elastalert:latest
13+
14+
.PHONY: build

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,33 @@ If you want to build the server and run the build version:
5555

5656
You can then start the build by running `node lib/index.js`.
5757

58+
59+
60+
## Building Docker image
61+
62+
1. Clone the repository
63+
```bash
64+
git clone https://github.com/bitsensor/elastalert.git && cd elastalert
65+
```
66+
2. Build the image using
67+
```
68+
make build
69+
```
70+
which is equivalent of:
71+
```
72+
docker pull alpine:latest && docker pull node:latest
73+
docker build -t elastalert .
74+
```
75+
76+
Custom Yelp's Elastalert version (a [release from github](https://github.com/Yelp/elastalert/releases)) e.g. `master` or `v0.1.28`:
77+
```bash
78+
make build v=v0.1.28
79+
```
80+
Custom mirror:
81+
```bash
82+
docker build --build-arg ELASTALERT_URL=http://example.mirror.com/master.zip -t elastalert .
83+
```
84+
5885
### Install ElastAlert to /opt/elastalert
5986
And run `pip install -r requirements.txt` or read the installation guide of ElastAlert.
6087

0 commit comments

Comments
 (0)