forked from StamusNetworks/scirius
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
202 lines (172 loc) · 6.33 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# Copyright(C) 2020, Gabor Seljan
# Copyright(C) 2021, Stamus Networks
#
# Adapted by Raphaël Brogat <[email protected]>
#
# This file comes with ABSOLUTELY NO WARRANTY!
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#Base containers
FROM python:3.9-slim-bullseye as base
RUN echo 'APT::Install-Recommends "0";' >> /etc/apt/apt.conf && \
echo 'APT::Install-Suggests "0";' >> /etc/apt/apt.conf
#Download STEP
FROM base as source
ARG VERSION
ENV VERSION ${VERSION:-master}
ARG CYBERCHEF_VERSION
ENV CYBERCHEF_VERSION ${CYBERCHEF_VERSION:-v9.32.3}
RUN \
echo "**** install packages ****" && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
apt-utils \
wget \
unzip
RUN \
echo "**** download Kibana dashboards ****" && \
wget --no-check-certificate --content-disposition -O /tmp/kibana7-dashboards.tar.gz https://github.com/StamusNetworks/KTS7/tarball/master && \
mkdir /tmp/kibana7-dashboards && \
tar zxf /tmp/kibana7-dashboards.tar.gz -C /tmp/kibana7-dashboards --strip-components 1 && \
mv /tmp/kibana7-dashboards /opt/kibana7-dashboards
RUN \
echo "**** download Cyberchef ****" && \
wget --no-check-certificate -O /tmp/cyberchef.zip https://github.com/gchq/CyberChef/releases/download/${CYBERCHEF_VERSION}/CyberChef_${CYBERCHEF_VERSION}.zip && \
mkdir /tmp/cyberchef && \
unzip /tmp/cyberchef.zip -d /tmp/cyberchef && \
mv /tmp/cyberchef/CyberChef_${CYBERCHEF_VERSION}.html /tmp/cyberchef/index.html
RUN echo "**** COPY Scirius ****"
COPY . /opt/scirius
RUN mv /opt/scirius/docker/scirius/scirius/local_settings.py /opt/scirius/scirius/local_settings.py
RUN chmod ugo+x /opt/scirius/docker/scirius/bin/*
# BUILD JS stuff
FROM base as build_js
RUN \
echo "**** install packages ****" && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
apt-utils && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
make \
wget \
gcc \
libc-dev
RUN \
echo "**** add NodeSource repository ****" && \
wget -O- https://deb.nodesource.com/setup_18.x | bash -
RUN \
echo "**** install Node.js ****" && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
nodejs
COPY --from=source /opt/scirius/*.js* /opt/scirius/.eslintrc /opt/scirius/
COPY --from=source /opt/scirius/ui /opt/scirius/ui
COPY --from=source /opt/scirius/npm /opt/scirius/npm
COPY --from=source /opt/scirius/scss /opt/scirius/scss
COPY --from=source /opt/scirius/rules /opt/scirius/rules
ENV REACT_APP_HAS_ACTION 1
WORKDIR /opt/scirius
RUN echo "**** install Node.js dependencies for Scirius ****" && \
npm install && \
npm install -g webpack webpack-cli && \
webpack && \
cd ui && \
npm install && \
npm run build && mv webpack-stats-ui.prod.json ../rules/static/
# Install python packages
FROM base as python_modules
COPY --from=source /opt/scirius/requirements.txt /opt/scirius/requirements.txt
RUN \
echo "**** install packages ****" && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
gnupg2 \
gcc \
libc-dev \
libsasl2-dev \
libldap2-dev \
libssl-dev \
python3-pip \
python-dev \
git
RUN \
echo "**** install Python dependencies for Scirius ****" && \
cd /opt/scirius && \
python -m pip install --user --upgrade\
six \
python-daemon \
suricatactl &&\
python -m pip install --user -r requirements.txt
FROM base as gophercap
RUN \
echo "**** install tools to get gophercap ****" && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
wget \
curl \
jq \
gzip
RUN \
echo "**** install gopherCap ****" && \
cd /tmp && \
wget -q -O gopherCap.gz $(curl --silent "https://api.github.com/repos/StamusNetworks/gophercap/releases/latest" | jq -r '.assets[] | select(.name=="gopherCap.gz") | .browser_download_url') && \
gunzip -c gopherCap.gz > /usr/local/bin/gopherCap && \
chmod +x /usr/local/bin/gopherCap
#BUILD doc
FROM base as build_docs
RUN \
echo "**** install packages ****" && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
apt-utils && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
make \
gcc \
libc-dev \
python3-sphinx
COPY --from=source /opt/scirius/doc /opt/scirius/doc
RUN \
echo "**** build docs ****" && \
cd /opt/scirius/doc && \
make html
# PACKAGING STEP
FROM base
ARG BUILD_DATE
ARG VCS_REF
LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vcs-url="https://github.com/StamusNetworks/SELKS.git" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.schema-version="1.0.0-rc1"
COPY --from=source /opt/scirius /opt/scirius
RUN \
echo "**** install packages ****" && \
echo "deb http://deb.debian.org/debian bullseye-backports main" > /etc/apt/sources.list.d/bullseye-backports.list && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
curl \
git \
gunicorn && \
DEBIAN_FRONTEND=noninteractive apt-get install -t bullseye-backports suricata -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir gunicorn
COPY --from=build_js /opt/scirius/rules/static /opt/scirius/rules/static
COPY --from=python_modules /root/.local /root/.local
COPY --from=gophercap /usr/local/bin/gopherCap /usr/local/bin/gopherCap
COPY --from=build_docs /opt/scirius/doc/_build/html /static/doc
COPY --from=source /opt/kibana7-dashboards /opt/kibana7-dashboards
COPY --from=source /tmp/cyberchef /static/cyberchef/
HEALTHCHECK --start-period=3m \
CMD curl --silent --fail http://127.0.0.1:8000 || exit 1
VOLUME /rules /data /static /logs
EXPOSE 8000
ENTRYPOINT ["/bin/bash", "/opt/scirius/docker/scirius/bin/start-scirius.sh"]