-
Notifications
You must be signed in to change notification settings - Fork 22
/
Dockerfile-buster
97 lines (70 loc) · 2.51 KB
/
Dockerfile-buster
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
FROM python:3-slim-buster as build-elastalert
ARG ELASTALERT_VERSION=2.2.2
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 apt update && \
apt -y upgrade && \
apt -y install wget unzip
# Download and unpack ElastAlert 2.
RUN wget -O elastalert.zip "${ELASTALERT_URL}" && \
unzip elastalert.zip && \
rm elastalert.zip && \
mv e* "${ELASTALERT_HOME}"
WORKDIR "${ELASTALERT_HOME}"
# Install ElastAlert 2.
RUN pip install setuptools wheel && \
python setup.py sdist bdist_wheel
FROM node:14-alpine3.14 as build-server
COPY package*.json ./
RUN npm ci
WORKDIR /opt/elastalert-server
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM python:3-slim-buster
LABEL description="ElastAlert2 Server"
LABEL maintainer="Karql <[email protected]>"
SHELL ["/bin/bash", "--login", "-c"]
# Set timezone for this container
ENV TZ Etc/UTC
ARG GID=1000
ARG UID=1000
ARG GROUPNAME=elastalert2-server
ARG USERNAME=elastalert2-server
RUN groupadd -g ${GID} ${GROUPNAME} && \
useradd -u ${UID} -g ${GID} -M -s /sbin/nologin \
-c "ElastAlert2 Server User" ${USERNAME}
RUN apt update && apt -y upgrade && \
apt -y install jq curl gcc libffi-dev make
COPY --from=build-elastalert /opt/elastalert/dist/*.tar.gz /tmp/
RUN pip install /tmp/*.tar.gz && \
rm -rf /tmp/* && \
mkdir -p /opt/elastalert
WORKDIR /opt/elastalert-server
RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - && \
apt-get install -y nodejs
COPY package*.json ./
RUN npm ci --production
COPY --from=build-server /opt/elastalert-server/dist /opt/elastalert-server/dist
COPY scripts scripts
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
RUN apt -y remove gcc libffi-dev && \
apt -y autoremove && \
rm -rf /var/lib/apt/lists/*
# 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 ${USERNAME}:${GROUPNAME} /opt
USER ${USERNAME}
EXPOSE 3030
ENTRYPOINT ["npm", "start"]