Skip to content

Commit ae6da26

Browse files
mergify[bot]rdner
andauthored
Add elastic-agent-wolfi-complete Docker image (#5475) (#5516)
So, we have a Wolfi-based image with Synthetics. (cherry picked from commit f8fd7a7) Co-authored-by: Denis <denis.rechkunov@elastic.co>
1 parent b9f088b commit ae6da26

File tree

3 files changed

+72
-8
lines changed

3 files changed

+72
-8
lines changed

dev-tools/mage/dockervariants.go

+12-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ import (
1010
)
1111

1212
const (
13-
undefined = "undefined"
14-
basic = "basic"
15-
ubi = "ubi"
16-
wolfi = "wolfi"
17-
complete = "complete"
18-
cloud = "cloud"
13+
undefined = "undefined"
14+
basic = "basic"
15+
ubi = "ubi"
16+
wolfi = "wolfi"
17+
complete = "complete"
18+
wolfiComplete = "wolfi-complete"
19+
cloud = "cloud"
1920
)
2021

2122
// DockerVariant defines the docker variant to build.
@@ -27,6 +28,7 @@ const (
2728
Basic
2829
UBI
2930
Wolfi
31+
WolfiComplete
3032
Complete
3133
Cloud
3234
)
@@ -42,6 +44,8 @@ func (typ DockerVariant) String() string {
4244
return ubi
4345
case Wolfi:
4446
return wolfi
47+
case WolfiComplete:
48+
return wolfiComplete
4549
case Complete:
4650
return complete
4751
case Cloud:
@@ -67,6 +71,8 @@ func (typ *DockerVariant) UnmarshalText(text []byte) error {
6771
*typ = UBI
6872
case wolfi:
6973
*typ = Wolfi
74+
case wolfiComplete:
75+
*typ = WolfiComplete
7076
case complete:
7177
*typ = Complete
7278
case cloud:

dev-tools/packaging/packages.yml

+28
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ shared:
296296
<<: *agent_docker_spec
297297
docker_variant: 'complete'
298298

299+
- &agent_docker_wolfi_complete_spec
300+
<<: *agent_docker_spec
301+
docker_variant: 'wolfi-complete'
302+
299303
# Deb/RPM spec for community beats.
300304
- &deb_rpm_spec
301305
<<: *common
@@ -908,6 +912,18 @@ specs:
908912
files:
909913
'{{.BeatName}}{{.BinaryExt}}':
910914
source: ./build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}}
915+
- os: linux
916+
arch: amd64
917+
types: [docker]
918+
spec:
919+
<<: *docker_wolfi_spec
920+
<<: *docker_builder_spec
921+
<<: *agent_docker_wolfi_complete_spec
922+
<<: *docker_elastic_spec
923+
<<: *elastic_license_for_binaries
924+
files:
925+
'{{.BeatName}}{{.BinaryExt}}':
926+
source: ./build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}}
911927
- os: linux
912928
arch: arm64
913929
types: [docker]
@@ -920,6 +936,18 @@ specs:
920936
files:
921937
'{{.BeatName}}{{.BinaryExt}}':
922938
source: ./build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}}
939+
- os: linux
940+
arch: arm64
941+
types: [docker]
942+
spec:
943+
<<: *docker_wolfi_arm_spec
944+
<<: *docker_builder_arm_spec
945+
<<: *agent_docker_wolfi_complete_spec
946+
<<: *docker_elastic_spec
947+
<<: *elastic_license_for_binaries
948+
files:
949+
'{{.BeatName}}{{.BinaryExt}}':
950+
source: ./build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}}
923951
- os: linux
924952
arch: amd64
925953
types: [docker]

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

+32-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ LABEL \
118118
license="{{ .License }}" \
119119
description="{{ .BeatDescription }}"
120120

121-
ENV ELASTIC_CONTAINER "true"
121+
ENV ELASTIC_CONTAINER="true"
122122
ENV PATH={{ $beatHome }}:$PATH
123123
ENV GODEBUG="madvdontneed=1"
124124

@@ -192,7 +192,7 @@ RUN echo \
192192
ENV ELASTIC_SYNTHETICS_CAPABLE=true
193193
ENV ELASTIC_AGENT_COMPLETE=true
194194
ENV TZ=UTC
195-
ENV NODE_VERSION=18.20.3
195+
ENV NODE_VERSION=18.20.4
196196
ENV PATH="$NODE_PATH/node/bin:$PATH"
197197
# Install the latest version of @elastic/synthetics forcefully ignoring the previously
198198
# cached node_modules, heartbeat then calls the global executable to run test suites
@@ -239,8 +239,38 @@ RUN for iter in {1..10}; do \
239239
(exit $exit_code)
240240
{{- end }}
241241

242+
{{- if (and (eq .Variant "wolfi-complete") (contains .from "wolfi")) }}
243+
USER root
244+
# Install required dependencies from wolfi repository
245+
RUN for iter in {1..10}; do \
246+
apk update && \
247+
apk add --no-interactive --no-progress --no-cache nodejs-18=18.20.4-r0 npm=10.8.3-r0 glib dbus-glib libatk-1.0 \
248+
libatk-bridge-2.0 cups-libs libxcomposite libxdamage libxrandr libxkbcommon pango alsa-lib \
249+
font-opensans fontconfig gtk icu-data-full libnss mesa font-noto-cjk font-noto-emoji && \
250+
exit_code=0 && break || exit_code=$? && echo "apk error: retry $iter in 10s" && sleep 10; \
251+
done; \
252+
(exit $exit_code)
253+
254+
# Setup synthetics env vars
255+
ENV ELASTIC_SYNTHETICS_CAPABLE=true
256+
ENV TZ=UTC
257+
ENV NPM_CONFIG_PREFIX={{ $beatHome }}/.npm
258+
ENV PATH="$NPM_CONFIG_PREFIX/bin:$PATH"
259+
260+
RUN echo \
261+
$NPM_CONFIG_PREFIX \
262+
{{ $beatHome }}/.config \
263+
{{ $beatHome }}/.synthetics \
264+
{{ $beatHome }}/.npm \
265+
{{ $beatHome }}/.cache \
266+
| xargs -IDIR sh -c 'mkdir -m 0770 -p DIR && chown -R {{ .user }} DIR'
267+
242268
USER {{ .user }}
243269

270+
RUN (npm i -g --loglevel verbose --production --engine-strict @elastic/synthetics@stack_release || sh -c 'tail -n +1 ${NPM_CONFIG_PREFIX}/_logs/* && exit 1')
271+
{{- end }}
272+
273+
USER {{ .user }}
244274

245275
{{- range $i, $port := .ExposePorts }}
246276
EXPOSE {{ $port }}

0 commit comments

Comments
 (0)