Skip to content

Commit 5cd6efe

Browse files
authored
Revert "[Fix] Agent incapable of running on Azure Container Instances (#3576) (#3614)" (#3712)
This reverts commit 7eb6e4a.
1 parent c359647 commit 5cd6efe

File tree

2 files changed

+14
-46
lines changed

2 files changed

+14
-46
lines changed

changelog/fragments/1689328899-Elastic-Agent-container-runs-on-Azure-Container-Instances-.yaml

Lines changed: 0 additions & 31 deletions
This file was deleted.

dev-tools/packaging/templates/docker/Dockerfile.elastic-agent.tmpl

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ FROM {{ .buildFrom }} AS home
99
COPY beat {{ $beatHome }}
1010

1111
RUN mkdir -p {{ $beatHome }}/data {{ $beatHome }}/data/elastic-agent-{{ commit_short }}/logs && \
12+
chown -R root:root {{ $beatHome }} && \
1213
find {{ $beatHome }} -type d -exec chmod 0755 {} \; && \
1314
find {{ $beatHome }} -type f -exec chmod 0644 {} \; && \
1415
find {{ $beatHome }}/data -type d -exec chmod 0770 {} \; && \
@@ -126,16 +127,25 @@ COPY --from=home {{ $beatHome }}/NOTICE.txt /licenses
126127
COPY --from=home /opt /opt
127128
{{- end }}
128129

130+
131+
RUN setcap cap_net_raw,cap_setuid+p {{ $beatHome }}/data/elastic-agent-{{ commit_short }}/components/heartbeat && \
132+
{{- if .linux_capabilities }}
133+
# Since the beat is stored at the other end of a symlink we must follow the symlink first
134+
# For security reasons setcap does not support symlinks. This is smart in the general case
135+
# but in our specific case since we're building a trusted image from trusted binaries this is
136+
# fine. Thus, we use readlink to follow the link and setcap on the actual binary
137+
readlink -f {{ $beatBinary }} | xargs setcap {{ .linux_capabilities }} && \
138+
{{- end }}
139+
true
140+
129141
{{- if eq .user "root" }}
130142
{{- if contains .image_name "-cloud" }}
131143
# Generate folder for a stub command that will be overwritten at runtime
132144
RUN mkdir /app
133145
{{- end }}
134146
{{- else }}
135-
RUN groupadd --gid 1000 {{ .BeatName }} && \
136-
useradd -M --uid 1000 --gid 1000 --groups 0 --home {{ $beatHome }} {{ .user }} && \
137-
chown -R {{ .user }}:{{ .user }} {{ $beatHome }} && \
138-
true
147+
RUN groupadd --gid 1000 {{ .BeatName }}
148+
RUN useradd -M --uid 1000 --gid 1000 --groups 0 --home {{ $beatHome }} {{ .user }}
139149

140150
{{- if contains .image_name "-cloud" }}
141151
# Generate folder for a stub command that will be overwritten at runtime
@@ -144,17 +154,6 @@ RUN chown {{ .user }} /app
144154
{{- end }}
145155
{{- end }}
146156

147-
# Keep this after any chown command, chown resets any applied capabilities
148-
RUN setcap cap_net_raw,cap_setuid+p {{ $beatHome }}/data/elastic-agent-{{ commit_short }}/components/heartbeat && \
149-
{{- if .linux_capabilities }}
150-
# Since the beat is stored at the other end of a symlink we must follow the symlink first
151-
# For security reasons setcap does not support symlinks. This is smart in the general case
152-
# but in our specific case since we're building a trusted image from trusted binaries this is
153-
# fine. Thus, we use readlink to follow the link and setcap on the actual binary
154-
setcap {{ .linux_capabilities }} $(readlink -f {{ $beatBinary }}) && \
155-
{{- end }}
156-
true
157-
158157
{{- if (and (contains .image_name "-complete") (not (contains .from "ubi-minimal"))) }}
159158
USER root
160159
ENV NODE_PATH={{ $beatHome }}/.node

0 commit comments

Comments
 (0)