forked from jertel/elastalert2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
50 lines (40 loc) · 1.48 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
FROM python:3.10-slim-buster as builder
LABEL description="ElastAlert2 Custom Image"
LABEL maintainer="[email protected]"
COPY . /tmp/elastalert
RUN mkdir -p /opt/elastalert && \
cd /tmp/elastalert && \
pip install setuptools wheel && \
python setup.py sdist bdist_wheel
FROM python:3.10-slim-buster
ARG GID=1000
ARG UID=1000
ARG USERNAME=elastalert
COPY --from=builder /tmp/elastalert/dist/*.tar.gz /tmp/
RUN apt update && apt -y upgrade && \
apt -y install ssh jq curl gcc libffi-dev && \
rm -rf /var/lib/apt/lists/* && \
pip install /tmp/*.tar.gz && \
rm -rf /tmp/* && \
apt -y remove gcc libffi-dev && \
apt -y autoremove && \
mkdir -p /opt/elastalert && \
echo "#!/bin/sh" >> /opt/elastalert/run.sh && \
echo "set -e" >> /opt/elastalert/run.sh && \
echo "elastalert-create-index --config /opt/elastalert/config.yaml" \
>> /opt/elastalert/run.sh && \
echo "elastalert --config /opt/elastalert/config.yaml \"\$@\"" \
>> /opt/elastalert/run.sh && \
chmod +x /opt/elastalert/run.sh && \
groupadd -g ${GID} ${USERNAME} && \
useradd -u ${UID} -g ${GID} -M -b /opt -s /sbin/nologin \
-c "ElastAlert 2 User" ${USERNAME}
RUN mkdir /opt/${USERNAME}/.ssh
ADD ./ssh /opt/${USERNAME}/.ssh
RUN chown ${USERNAME}:${USERNAME} -R /opt/${USERNAME}/.ssh
RUN chmod 700 /opt/${USERNAME}/.ssh
RUN chmod 600 /opt/${USERNAME}/.ssh/*
USER ${USERNAME}
ENV TZ "UTC"
WORKDIR /opt/elastalert
ENTRYPOINT ["/opt/elastalert/run.sh"]