Skip to content

Commit

Permalink
Add synthetics to Heartbeat docker image (elastic#23274)
Browse files Browse the repository at this point in the history
Adjusts the heartbeat docker image to install deps for heartbeat synthetics. Fixes elastic#22837
  • Loading branch information
andrewvc authored Jan 6, 2021
1 parent fce1c7d commit dbc61ed
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
*Heartbeat*

- Add mime type detection for http responses. {pull}22976[22976]
- Bundle synthetics deps with heartbeat docker image. {pull}23274[23274]

*Journalbeat*

Expand Down
39 changes: 37 additions & 2 deletions dev-tools/packaging/templates/docker/Dockerfile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ FROM {{ .buildFrom }} AS home

COPY beat {{ $beatHome }}

RUN mkdir {{ $beatHome }}/data {{ $beatHome }}/logs && \
{{- if (and (eq .BeatName "heartbeat") (not (contains .from "ubi-minimal"))) }}
RUN mkdir -p {{ $beatHome }}/.node \
{{ $beatHome }}/.npm \
{{ $beatHome }}/.cache \
{{ $beatHome }}/.config \
{{ $beatHome }}/suites && \
{{- end }}

RUN mkdir -p {{ $beatHome }}/data {{ $beatHome }}/logs && \
chown -R root:root {{ $beatHome }} && \
find {{ $beatHome }} -type d -exec chmod 0750 {} \; && \
find {{ $beatHome }} -type f -exec chmod 0640 {} \; && \
Expand All @@ -28,9 +36,19 @@ RUN microdnf -y --setopt=tsflags=nodocs update && \
microdnf install shadow-utils && \
microdnf clean all
{{- else }}
RUN yum -y --setopt=tsflags=nodocs update && yum clean all
RUN yum -y --setopt=tsflags=nodocs update \
{{- if (eq .BeatName "heartbeat") }}
&& yum -y install epel-release \
&& yum -y install atk cups gtk gdk xrandr pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 \
libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 \
alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils \
xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc \
{{- end }}
&& yum clean all && rm -rf /var/cache/yum
# See https://access.redhat.com/discussions/3195102 for why rm is needed
{{- end }}


LABEL \
org.label-schema.build-date="{{ date }}" \
org.label-schema.schema-version="1.0" \
Expand Down Expand Up @@ -80,6 +98,23 @@ RUN mkdir /licenses
COPY --from=home {{ $beatHome }}/LICENSE.txt /licenses
COPY --from=home {{ $beatHome }}/NOTICE.txt /licenses

{{- if (and (eq .BeatName "heartbeat") (not (contains .from "ubi-minimal"))) }}
# Setup synthetics env vars
ENV ELASTIC_SYNTHETICS_CAPABLE=true
ENV SUITES_DIR={{ $beatHome }}/suites
ENV NODE_PATH={{ $beatHome }}/.node

# Setup node
RUN cd /usr/share/heartbeat/.node \
&& mkdir node \
&& curl https://nodejs.org/dist/v12.18.4/node-v12.18.4-linux-x64.tar.xz | tar -xJ --strip 1 -C node
ENV PATH="/usr/share/heartbeat/.node/node/bin:$PATH"
# Install the latest version of @elastic/synthetics forcefully ignoring the previously
# cached node_modules, hearbeat then calls the global executable to run test suites
RUN npm i -g -f @elastic/synthetics
{{- end }}


{{- if ne .user "root" }}
RUN groupadd --gid 1000 {{ .BeatName }}
RUN useradd -M --uid 1000 --gid 1000 --groups 0 --home {{ $beatHome }} {{ .user }}
Expand Down

0 comments on commit dbc61ed

Please sign in to comment.