-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathDockerfile
83 lines (61 loc) · 2.29 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
FROM alpine:3.20 as build-elastalert
ARG ELASTALERT_VERSION=2.21.0
ENV ELASTALERT_VERSION=${ELASTALERT_VERSION}
# URL from which to download ElastAlert 2
ARG ELASTALERT_URL=https://github.com/jertel/elastalert2/archive/refs/tags/$ELASTALERT_VERSION.zip
ENV ELASTALERT_URL=${ELASTALERT_URL}
# ElastAlert 2 home directory full path
ENV ELASTALERT_HOME /opt/elastalert
WORKDIR /opt
RUN apk add --update --no-cache \
python3 \
py3-pip \
py3-setuptools \
py3-wheel \
wget && \
# Download and unpack ElastAlert 2
wget -O elastalert.zip "${ELASTALERT_URL}" && \
unzip elastalert.zip && \
rm elastalert.zip && \
mv e* "${ELASTALERT_HOME}"
WORKDIR "${ELASTALERT_HOME}"
# Temp fix before new alpine release
RUN sed -i "s/python_requires='>=3.13'/python_requires='>=3.12'/" setup.py
# Building ElastAlert 2
RUN python3 setup.py sdist bdist_wheel
# Installing ElastAlert 2 in Virtual Environment
RUN python3 -m venv /opt/elastalert2-venv && \
. /opt/elastalert2-venv/bin/activate && \
pip3 install dist/*.tar.gz && \
deactivate
FROM node:22.11-alpine3.20 as build-server
WORKDIR /opt/elastalert-server
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:22.11-alpine3.20
LABEL description="ElastAlert2 Server"
LABEL maintainer="Karql <[email protected]>"
# Set timezone for this container
ENV TZ Etc/UTC
RUN apk add --update --no-cache tzdata python3
COPY --from=build-elastalert /opt/elastalert2-venv/lib/python3.12/site-packages /usr/lib/python3.12/site-packages
COPY --from=build-elastalert /opt/elastalert2-venv/bin/elastalert* /usr/bin/
RUN mkdir -p /opt/elastalert
COPY --from=build-server /opt/elastalert-server/dist /opt/elastalert-server/dist
WORKDIR /opt/elastalert-server
COPY package*.json ./
RUN npm ci --omit=dev
COPY config/elastalert.yaml /opt/elastalert/config.yaml
COPY config/elastalert-test.yaml /opt/elastalert/config-test.yaml
COPY config/config.json config/config.json
COPY rule_templates/ /opt/elastalert/rule_templates
COPY elastalert_modules/ /opt/elastalert/elastalert_modules
# Add default rules directory
# Set permission as unpriviledged user (1000:1000), compatible with Kubernetes
RUN mkdir -p /opt/elastalert/rules/ /opt/elastalert/server_data/tests/ \
&& chown -R node:node /opt
USER node
EXPOSE 3030
CMD ["node", "dist/index.js"]