diff --git a/dev-tools/mage/dockervariants.go b/dev-tools/mage/dockervariants.go index 81a8b5557b5..5545345b37b 100644 --- a/dev-tools/mage/dockervariants.go +++ b/dev-tools/mage/dockervariants.go @@ -10,12 +10,13 @@ import ( ) const ( - undefined = "undefined" - basic = "basic" - ubi = "ubi" - wolfi = "wolfi" - complete = "complete" - cloud = "cloud" + undefined = "undefined" + basic = "basic" + ubi = "ubi" + wolfi = "wolfi" + complete = "complete" + wolfiComplete = "wolfi-complete" + cloud = "cloud" ) // DockerVariant defines the docker variant to build. @@ -27,6 +28,7 @@ const ( Basic UBI Wolfi + WolfiComplete Complete Cloud ) @@ -42,6 +44,8 @@ func (typ DockerVariant) String() string { return ubi case Wolfi: return wolfi + case WolfiComplete: + return wolfiComplete case Complete: return complete case Cloud: @@ -67,6 +71,8 @@ func (typ *DockerVariant) UnmarshalText(text []byte) error { *typ = UBI case wolfi: *typ = Wolfi + case wolfiComplete: + *typ = WolfiComplete case complete: *typ = Complete case cloud: diff --git a/dev-tools/packaging/packages.yml b/dev-tools/packaging/packages.yml index 7eb3cc98e18..e389040e50f 100644 --- a/dev-tools/packaging/packages.yml +++ b/dev-tools/packaging/packages.yml @@ -296,6 +296,10 @@ shared: <<: *agent_docker_spec docker_variant: 'complete' + - &agent_docker_wolfi_complete_spec + <<: *agent_docker_spec + docker_variant: 'wolfi-complete' + # Deb/RPM spec for community beats. - &deb_rpm_spec <<: *common @@ -908,6 +912,18 @@ specs: files: '{{.BeatName}}{{.BinaryExt}}': source: ./build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}} + - os: linux + arch: amd64 + types: [docker] + spec: + <<: *docker_wolfi_spec + <<: *docker_builder_spec + <<: *agent_docker_wolfi_complete_spec + <<: *docker_elastic_spec + <<: *elastic_license_for_binaries + files: + '{{.BeatName}}{{.BinaryExt}}': + source: ./build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}} - os: linux arch: arm64 types: [docker] @@ -920,6 +936,18 @@ specs: files: '{{.BeatName}}{{.BinaryExt}}': source: ./build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}} + - os: linux + arch: arm64 + types: [docker] + spec: + <<: *docker_wolfi_arm_spec + <<: *docker_builder_arm_spec + <<: *agent_docker_wolfi_complete_spec + <<: *docker_elastic_spec + <<: *elastic_license_for_binaries + files: + '{{.BeatName}}{{.BinaryExt}}': + source: ./build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}} - os: linux arch: amd64 types: [docker] diff --git a/dev-tools/packaging/templates/docker/Dockerfile.elastic-agent.tmpl b/dev-tools/packaging/templates/docker/Dockerfile.elastic-agent.tmpl index 0e04c3f9ebd..362b97485d3 100644 --- a/dev-tools/packaging/templates/docker/Dockerfile.elastic-agent.tmpl +++ b/dev-tools/packaging/templates/docker/Dockerfile.elastic-agent.tmpl @@ -118,7 +118,7 @@ LABEL \ license="{{ .License }}" \ description="{{ .BeatDescription }}" -ENV ELASTIC_CONTAINER "true" +ENV ELASTIC_CONTAINER="true" ENV PATH={{ $beatHome }}:$PATH ENV GODEBUG="madvdontneed=1" @@ -192,7 +192,7 @@ RUN echo \ ENV ELASTIC_SYNTHETICS_CAPABLE=true ENV ELASTIC_AGENT_COMPLETE=true ENV TZ=UTC -ENV NODE_VERSION=18.20.3 +ENV NODE_VERSION=18.20.4 ENV PATH="$NODE_PATH/node/bin:$PATH" # Install the latest version of @elastic/synthetics forcefully ignoring the previously # cached node_modules, heartbeat then calls the global executable to run test suites @@ -239,8 +239,38 @@ RUN for iter in {1..10}; do \ (exit $exit_code) {{- end }} +{{- if (and (eq .Variant "wolfi-complete") (contains .from "wolfi")) }} +USER root +# Install required dependencies from wolfi repository +RUN for iter in {1..10}; do \ + apk update && \ + 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 \ + libatk-bridge-2.0 cups-libs libxcomposite libxdamage libxrandr libxkbcommon pango alsa-lib \ + font-opensans fontconfig gtk icu-data-full libnss mesa font-noto-cjk font-noto-emoji && \ + exit_code=0 && break || exit_code=$? && echo "apk error: retry $iter in 10s" && sleep 10; \ + done; \ + (exit $exit_code) + +# Setup synthetics env vars +ENV ELASTIC_SYNTHETICS_CAPABLE=true +ENV TZ=UTC +ENV NPM_CONFIG_PREFIX={{ $beatHome }}/.npm +ENV PATH="$NPM_CONFIG_PREFIX/bin:$PATH" + +RUN echo \ + $NPM_CONFIG_PREFIX \ + {{ $beatHome }}/.config \ + {{ $beatHome }}/.synthetics \ + {{ $beatHome }}/.npm \ + {{ $beatHome }}/.cache \ + | xargs -IDIR sh -c 'mkdir -m 0770 -p DIR && chown -R {{ .user }} DIR' + USER {{ .user }} +RUN (npm i -g --loglevel verbose --production --engine-strict @elastic/synthetics@stack_release || sh -c 'tail -n +1 ${NPM_CONFIG_PREFIX}/_logs/* && exit 1') +{{- end }} + +USER {{ .user }} {{- range $i, $port := .ExposePorts }} EXPOSE {{ $port }}