6
6
# To run the container: docker run -it --rm -v `pwd`:/data <image_name>
7
7
# Requires docker 17.05 or higher
8
8
9
- # Set this arguement to "local" if you want to build osquery for local code.
9
+ # Set this argument to "local" if you want to build osquery for local code.
10
10
# In that case, osquery folder must exist besides Dockerfile
11
11
ARG OSQUERY_BUILD_ENV=remote
12
12
@@ -29,7 +29,7 @@ ONBUILD RUN cd / \
29
29
&& echo "Fetching osquery from git"
30
30
31
31
32
- # --------------- TEMP CONTAINER FOR OSQUERY ( BASED ON ARGUMENT ) --------------
32
+ # --------------- TEMP CONTAINER FOR OSQUERY ( BASED ON ARGUMENT ) ---------------
33
33
FROM osquery_"$OSQUERY_BUILD_ENV" as osquery_image
34
34
35
35
@@ -40,7 +40,6 @@ RUN yum makecache fast && yum -y update
40
40
41
41
# paths that hubble or hubble parts need in the package
42
42
RUN mkdir -p /etc/hubble/hubble.d /opt/hubble /opt/osquery /var/log/hubble_osquery/backuplogs
43
-
44
43
# osquery build start
45
44
# osquery should be built first since requirements for other packages can interfere with osquery dependencies
46
45
# to build, osquery scripts want sudo and a user to sudo with.
@@ -74,10 +73,9 @@ RUN ls -lahR /opt/osquery/ && /opt/osquery/osqueryi --version
74
73
75
74
# install packages that should be needed for ligbit2 compilation and successful pyinstaller run
76
75
RUN yum -y install \
77
- python27-devel libffi-devel openssl-devel libssh2-devel autoconf automake libtool \
78
- libxml2-devel libxslt-devel libjpeg-devel \
79
- zlib-devel make cmake python27-setuptools \
80
- gcc python-devel python-setuptools wget openssl
76
+ libffi-devel openssl-devel libffi libssh2-devel autoconf automake libtool \
77
+ libxml2-devel libxslt-devel libjpeg-devel zlib-devel \
78
+ make cmake gcc python-devel python-setuptools wget openssl
81
79
82
80
# libcurl install start
83
81
# install libcurl to avoid depending on host version
@@ -136,27 +134,29 @@ RUN mkdir -p "$LIBGIT2TEMP" \
136
134
&& make \
137
135
&& make install
138
136
137
+ # fpm package making requirements start
138
+ RUN yum install -y ruby ruby-devel rpmbuild rpm-build rubygems gcc make \
139
+ && gem install --no-ri --no-rdoc fpm
140
+
141
+ # things we may need to build a python
142
+ RUN yum install -y bzip2-devel
143
+
139
144
# use pyenv
140
145
ARG PYENV_VERSION=3.6.10
141
146
ENV PYENV_INSTALLER_URL=https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer
142
- ENV PYENV_ROOT=/usr/local /pyenv
147
+ ENV PYENV_ROOT=/opt/hubble /pyenv
143
148
ENV PATH=$PYENV_ROOT/bin:$PATH
149
+ ENV PYTHON_CONFIGURE_OPTS="--enable-shared"
144
150
RUN umask 022 \
145
151
&& curl -s -S -L "$PYENV_INSTALLER_URL" -o /usr/bin/pyenv-installer \
146
152
&& chmod 0755 /usr/bin/pyenv-installer \
147
153
&& /usr/bin/pyenv-installer \
148
154
&& eval "$(pyenv init -)" \
149
- && env PYTHON_CONFIGURE_OPTS= "--enable-shared" pyenv install $PYENV_VERSION \
155
+ && pyenv install $PYENV_VERSION \
150
156
&& pyenv global $PYENV_VERSION
151
157
152
- COPY pyinstaller-requirements.txt /
153
158
RUN eval "$(pyenv init -)" \
154
- && pip -v install --upgrade pip \
155
- && pip -v install -r pyinstaller-requirements.txt
156
-
157
- # fpm package making requirements start
158
- RUN yum install -y ruby ruby-devel rpmbuild rpm-build rubygems gcc make \
159
- && gem install --no-ri --no-rdoc fpm
159
+ && pip -v install --upgrade pip
160
160
161
161
# pyinstaller start
162
162
# commands specified for ENTRYPOINT and CMD are executed when the container is run, not when the image is built
@@ -173,58 +173,21 @@ ENV _HOOK_DIR="./pkg/"
173
173
ENV _BINARY_LOG_LEVEL="INFO"
174
174
ENV _INCLUDE_PATH=""
175
175
ENV LD_LIBRARY_PATH=/opt/hubble/lib:/lib:/lib64:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64
176
- RUN git clone "$HUBBLE_GIT_URL" "$HUBBLE_SRC_PATH" \
176
+ RUN set -x; git clone "$HUBBLE_GIT_URL" "$HUBBLE_SRC_PATH" \
177
177
&& cd "$HUBBLE_SRC_PATH" \
178
178
&& git checkout -B hubble-build && git reset --hard "$HUBBLE_CHECKOUT" && git clean -dfx \
179
179
&& cp -rf "$HUBBLE_SRC_PATH" /hubble_build \
180
180
&& sed -i "s/BRANCH_NOT_SET/${HUBBLE_CHECKOUT}/g" /hubble_build/hubblestack/__init__.py \
181
181
&& sed -i "s/COMMIT_NOT_SET/`git describe`/g" /hubble_build/hubblestack/__init__.py
182
+ RUN eval "$(pyenv init -)" \
183
+ && cd "$HUBBLE_SRC_PATH" \
184
+ && python setup.py egg_info \
185
+ && pip install --upgrade \
186
+ -r hubblestack.egg-info/requires.txt \
187
+ -r optional-requirements.txt \
188
+ -r package-requirements.txt
182
189
RUN mkdir /data
183
190
VOLUME /data
184
191
WORKDIR /hubble_build
185
- ENTRYPOINT [ "/bin/bash" , "-o" , "xtrace" , "-c" ]
186
- CMD [ "if [ -f /data/hubble_buildinfo ] ; then echo \"\" >> /hubble_build/hubblestack/__init__.py ; cat /data/hubble_buildinfo >> /hubble_build/hubblestack/__init__.py; fi \
187
- && eval \" $(pyenv init -)\" \
188
- && pyinstaller --onedir --noconfirm --log-level ${_BINARY_LOG_LEVEL} --additional-hooks-dir=${_HOOK_DIR} --runtime-hook=pkg/pyinstaller-runtimehooks/pathopthubble.py hubble.py \
189
- && mkdir -p /var/log/hubble_osquery/backuplogs \
190
- # hubble default configuration file
191
- && cp -rf /hubble_build/conf/hubble /etc/hubble/ \
192
- && cp -rf /hubble_build/conf/hubble-profile.sh /etc/profile.d/ \
193
- && cp -pr /hubble_build/dist/hubble /opt/hubble/hubble-libs \
194
- && ln -s /opt/hubble/hubble-libs/hubble /opt/hubble/hubble \
195
- # make sure rpm shared libs are taken out to avoid mismatch between rpm database and shared libs that pyinstaller includes
196
- && rm -rf /opt/hubble/hubble-libs/librpm* \
197
- #rpm pkg start
198
- && tar -cPvzf /data/hubblestack-${HUBBLE_VERSION}.tar.gz /etc/hubble /opt/hubble /opt/osquery /etc/profile.d/hubble-profile.sh /var/log/hubble_osquery/backuplogs \
199
- && mkdir -p /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION} \
200
- && tar -xzvf /data/hubblestack-${HUBBLE_VERSION}.tar.gz -C /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION} \
201
- && mkdir -p /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION}/etc/init.d \
202
- && if [ -f /data/hubble-autostart ] ; then mkdir -p /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION}/etc/cron.d ; fi \
203
- && cp /hubble_build/pkg/hubble /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION}/etc/init.d/ \
204
- && if [ -f /data/hubble-autostart ] ; then cp /hubble_build/pkg/hubble-autostart /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION}/etc/cron.d/ ; fi \
205
- && cp -f /hubble_build/conf/hubble /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION}/etc/hubble/ \
206
- #during container run, if a configuration file exists in a /data copy it over the existing one so it would be
207
- #possile to optionally include a custom one with the package
208
- && if [ -f /data/hubble ] ; then cp /data/hubble /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION}/etc/hubble/ ; fi \
209
- #also bring in anything from a /data/opt/ directory so we can bundle other executables if needed
210
- && if [ -d /data/opt ] ; then cp -r /data/opt/* /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION}/opt/ ; fi \
211
- && cd /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION} \
212
- && mkdir -p usr/bin \
213
- #symlink to have hubble binary in path
214
- && ln -s /opt/hubble/hubble usr/bin/hubble \
215
- #fpm start
216
- && fpm -s dir -t rpm \
217
- -n hubblestack \
218
- -v ${HUBBLE_VERSION} \
219
- --iteration ${HUBBLE_ITERATION} \
220
- --url ${HUBBLE_URL} \
221
- --description \" ${HUBBLE_DESCRIPTION}\" \
222
- --rpm-summary \" ${HUBBLE_SUMMARY}\" \
223
- --after-install /hubble_build/conf/afterinstall.sh \
224
- --after-upgrade /hubble_build/conf/afterupgrade.sh \
225
- --before-remove /hubble_build/conf/beforeremove.sh \
226
- etc opt usr /var/log/hubble_osquery/backuplogs \
227
- #edit to change iteration number, if necessary
228
- && cp hubblestack-${HUBBLE_VERSION}-${HUBBLE_ITERATION}.x86_64.rpm /data/hubblestack-${HUBBLE_VERSION}-${HUBBLE_ITERATION}.al1609.x86_64.rpm \
229
- && openssl dgst -sha256 /data/hubblestack-${HUBBLE_VERSION}-${HUBBLE_ITERATION}.al1609.x86_64.rpm \
230
- > /data/hubblestack-${HUBBLE_VERSION}-${HUBBLE_ITERATION}.al1609.x86_64.rpm.sha256" ]
192
+ COPY entrypoint.sh /entrypoint.sh
193
+ ENTRYPOINT [ "/bin/bash" , "/entrypoint.sh" ]
0 commit comments