@@ -134,10 +134,17 @@ RUN mkdir -p "$LIBGIT2TEMP" \
134
134
&& make \
135
135
&& make install
136
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
+
137
144
# use pyenv
138
145
ARG PYENV_VERSION=3.6.10
139
146
ENV PYENV_INSTALLER_URL=https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer
140
- ENV PYENV_ROOT=/usr/local /pyenv
147
+ ENV PYENV_ROOT=/opt /pyenv
141
148
ENV PATH=$PYENV_ROOT/bin:$PATH
142
149
RUN umask 022 \
143
150
&& curl -s -S -L "$PYENV_INSTALLER_URL" -o /usr/bin/pyenv-installer \
@@ -147,14 +154,8 @@ RUN umask 022 \
147
154
&& env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install $PYENV_VERSION \
148
155
&& pyenv global $PYENV_VERSION
149
156
150
- COPY pyinstaller-requirements.txt /
151
157
RUN eval "$(pyenv init -)" \
152
- && pip -v install --upgrade pip \
153
- && pip -v install -r pyinstaller-requirements.txt
154
-
155
- # fpm package making requirements start
156
- RUN yum install -y ruby ruby-devel rpmbuild rpm-build rubygems gcc make \
157
- && gem install --no-ri --no-rdoc fpm
158
+ && pip -v install --upgrade pip
158
159
159
160
# pyinstaller start
160
161
# commands specified for ENTRYPOINT and CMD are executed when the container is run, not when the image is built
@@ -165,62 +166,24 @@ ENV HUBBLE_ITERATION=1
165
166
ENV HUBBLE_URL=https://github.com/hubblestack/hubble
166
167
ENV HUBBLE_DESCRIPTION="Hubble is a modular, open-source, security & compliance auditing framework which is built in python, using SaltStack as a library."
167
168
ENV HUBBLE_SUMMARY="Profile based on-demand auditing and monitoring tool"
168
- ENV HUBBLE_GIT_URL=https://github.com/hubblestack/hubble.git
169
+ ARG HUBBLE_GIT_URL=https://github.com/hubblestack/hubble.git
169
170
ENV HUBBLE_SRC_PATH=/hubble_src
170
171
ENV _HOOK_DIR="./pkg/"
171
172
ENV _BINARY_LOG_LEVEL="INFO"
172
173
ENV _INCLUDE_PATH=""
173
174
ENV LD_LIBRARY_PATH=/opt/hubble/lib:/lib:/lib64:/usr/lib:/usr/lib64:/usr/local/lib:/usr/local/lib64
174
- RUN git clone "$HUBBLE_GIT_URL" "$HUBBLE_SRC_PATH" \
175
+ RUN set -x; git clone "$HUBBLE_GIT_URL" "$HUBBLE_SRC_PATH" \
175
176
&& cd "$HUBBLE_SRC_PATH" \
176
177
&& git checkout -B hubble-build && git reset --hard "$HUBBLE_CHECKOUT" && git clean -dfx \
177
178
&& cp -rf "$HUBBLE_SRC_PATH" /hubble_build \
178
179
&& sed -i "s/BRANCH_NOT_SET/${HUBBLE_CHECKOUT}/g" /hubble_build/hubblestack/__init__.py \
179
180
&& sed -i "s/COMMIT_NOT_SET/`git describe`/g" /hubble_build/hubblestack/__init__.py
181
+ RUN eval "$(pyenv init -)" \
182
+ && cd "$HUBBLE_SRC_PATH" \
183
+ && python setup.py egg_info \
184
+ && pip install --upgrade -r hubblestack.egg-info/requires.txt -r optional-requirements.txt
180
185
RUN mkdir /data
181
186
VOLUME /data
182
187
WORKDIR /hubble_build
183
- ENTRYPOINT [ "/bin/bash" , "-o" , "xtrace" , "-c" ]
184
- CMD [ "if [ -f /data/hubble_buildinfo ] ; then echo \"\" >> /hubble_build/hubblestack/__init__.py ; cat /data/hubble_buildinfo >> /hubble_build/hubblestack/__init__.py; fi \
185
- && eval \" $(pyenv init -)\" \
186
- && pyinstaller --onedir --noconfirm --log-level ${_BINARY_LOG_LEVEL} --additional-hooks-dir=${_HOOK_DIR} --runtime-hook=pkg/pyinstaller-runtimehooks/pathopthubble.py hubble.py \
187
- && mkdir -p /var/log/hubble_osquery/backuplogs \
188
- # hubble default configuration file
189
- && cp -rf /hubble_build/conf/hubble /etc/hubble/ \
190
- && cp -rf /hubble_build/conf/hubble-profile.sh /etc/profile.d/ \
191
- && cp -pr /hubble_build/dist/hubble /opt/hubble/hubble-libs \
192
- && ln -s /opt/hubble/hubble-libs/hubble /opt/hubble/hubble \
193
- # make sure rpm shared libs are taken out to avoid mismatch between rpm database and shared libs that pyinstaller includes
194
- && rm -rf /opt/hubble/hubble-libs/librpm* \
195
- #rpm pkg start
196
- && 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 \
197
- && mkdir -p /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION} \
198
- && tar -xzvf /data/hubblestack-${HUBBLE_VERSION}.tar.gz -C /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION} \
199
- && mkdir -p /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION}/usr/lib/systemd/system \
200
- && cp /hubble_build/pkg/hubble.service /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION}/usr/lib/systemd/system/ \
201
- && cp -f /hubble_build/conf/hubble /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION}/etc/hubble/ \
202
- #during container run, if a configuration file exists in a /data copy it over the existing one so it would be
203
- #possile to optionally include a custom one with the package
204
- && if [ -f /data/hubble ] ; then cp /data/hubble /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION}/etc/hubble/ ; fi \
205
- #also bring in anything from a /data/opt/ directory so we can bundle other executables if needed
206
- && if [ -d /data/opt ] ; then cp -r /data/opt/* /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION}/opt/ ; fi \
207
- && cd /hubble_build/debbuild/hubblestack-${HUBBLE_VERSION} \
208
- && mkdir -p usr/bin \
209
- #symlink to have hubble binary in path
210
- && ln -s /opt/hubble/hubble usr/bin/hubble \
211
- #fpm start
212
- && fpm -s dir -t rpm \
213
- -n hubblestack \
214
- -v ${HUBBLE_VERSION} \
215
- --iteration ${HUBBLE_ITERATION} \
216
- --url ${HUBBLE_URL} \
217
- --description \" ${HUBBLE_DESCRIPTION}\" \
218
- --rpm-summary \" ${HUBBLE_SUMMARY}\" \
219
- --after-install /hubble_build/conf/afterinstall-systemd.sh \
220
- --after-upgrade /hubble_build/conf/afterupgrade-systemd.sh \
221
- --before-remove /hubble_build/conf/beforeremove.sh \
222
- etc/hubble opt usr /var/log/hubble_osquery/backuplogs \
223
- #edit to change iteration number, if necessary
224
- && cp hubblestack-${HUBBLE_VERSION}-${HUBBLE_ITERATION}.x86_64.rpm /data/hubblestack-${HUBBLE_VERSION}-${HUBBLE_ITERATION}.el7.x86_64.rpm \
225
- && openssl dgst -sha256 /data/hubblestack-${HUBBLE_VERSION}-${HUBBLE_ITERATION}.el7.x86_64.rpm \
226
- > /data/hubblestack-${HUBBLE_VERSION}-${HUBBLE_ITERATION}.el7.x86_64.rpm.sha256" ]
188
+ COPY entrypoint.sh /entrypoint.sh
189
+ ENTRYPOINT [ "/bin/bash" , "/entrypoint.sh" ]
0 commit comments