-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix permissions for synthetics docker image #23576
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,6 @@ FROM {{ .buildFrom }} AS home | |
|
||
COPY beat {{ $beatHome }} | ||
|
||
{{- 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 {} \; && \ | ||
|
@@ -48,6 +40,16 @@ RUN yum -y --setopt=tsflags=nodocs update \ | |
# See https://access.redhat.com/discussions/3195102 for why rm is needed | ||
{{- end }} | ||
|
||
{{- if (and (eq .BeatName "heartbeat") (not (contains .from "ubi-minimal"))) }} | ||
ENV NODE_PATH={{ $beatHome }}/.node | ||
RUN echo \ | ||
$NODE_PATH \ | ||
{{ $beatHome }}/.config \ | ||
{{ $beatHome }}/suites \ | ||
{{ $beatHome }}/.npm \ | ||
{{ $beatHome }}/.cache \ | ||
| xargs -IDIR sh -c 'mkdir -p DIR && chmod 0770 DIR' | ||
{{- end }} | ||
|
||
LABEL \ | ||
org.label-schema.build-date="{{ date }}" \ | ||
|
@@ -98,28 +100,30 @@ RUN mkdir /licenses | |
COPY --from=home {{ $beatHome }}/LICENSE.txt /licenses | ||
COPY --from=home {{ $beatHome }}/NOTICE.txt /licenses | ||
|
||
{{- if ne .user "root" }} | ||
RUN groupadd --gid 1000 {{ .BeatName }} | ||
RUN useradd -M --uid 1000 --gid 1000 --groups 0 --home {{ $beatHome }} {{ .user }} | ||
{{- if (and (eq .BeatName "heartbeat") (not (contains .from "ubi-minimal"))) }} | ||
RUN chown {{ .user }} $NODE_PATH | ||
{{- end }} | ||
{{- end }} | ||
USER {{ .user }} | ||
|
||
{{- 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" | ||
ENV NODE_VERSION=12.18.4 | ||
ENV PATH="$NODE_PATH/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 }} | ||
# cached node_modules, heartbeat then calls the global executable to run test suites | ||
# Setup node | ||
RUN cd /usr/share/heartbeat/.node \ | ||
&& mkdir -p node \ | ||
&& curl https://nodejs.org/dist/v12.18.4/node-v12.18.4-linux-x64.tar.xz | tar -xJ --strip 1 -C node \ | ||
&& chmod ug+rwX -R $NODE_PATH \ | ||
&& npm i -g -f @elastic/synthetics && chmod ug+rwX -R $NODE_PATH | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we still need -f for this as this happens only when we build the heartbeat image? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that this is tested and works, I'd rather postpone this change to a subsequent PR and unbreak the current build |
||
{{- end }} | ||
USER {{ .user }} | ||
|
||
{{- range $i, $port := .ExposePorts }} | ||
EXPOSE {{ $port }} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use NODE_VERSION var here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fix this in a follow-up, I think we want to bump this version before beta anyway.