-
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
Build cloud docker images for elastic-agent #28134
Changes from all commits
472a660
a0dec42
f902af5
14c5499
093a855
34dfc14
3c6520d
0fe8ad0
f160c7e
6b8e09d
f2bab33
8167e47
304ed83
636c46a
5c2c93e
203c429
98ebbc8
de602d3
1737576
eb2cc55
2d8119d
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 |
---|---|---|
|
@@ -433,6 +433,7 @@ shared: | |
docker_entrypoint: 'docker-entrypoint.elastic-agent.tmpl' | ||
user: '{{ .BeatName }}' | ||
linux_capabilities: '' | ||
image_name: '' | ||
files: | ||
'elastic-agent.yml': | ||
source: 'elastic-agent.docker.yml' | ||
|
@@ -449,6 +450,11 @@ shared: | |
from: 'arm64v8/centos:7' | ||
buildFrom: 'arm64v8/centos:7' | ||
|
||
- &agent_docker_cloud_spec | ||
<<: *agent_docker_spec | ||
extra_vars: | ||
image_name: '{{.BeatName}}-cloud' | ||
|
||
# Deb/RPM spec for community beats. | ||
- &deb_rpm_spec | ||
<<: *common | ||
|
@@ -1007,6 +1013,19 @@ specs: | |
'{{.BeatName}}{{.BinaryExt}}': | ||
source: ./build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}} | ||
|
||
# Cloud specific docker image | ||
- os: linux | ||
arch: amd64 | ||
types: [docker] | ||
spec: | ||
<<: *agent_docker_spec | ||
<<: *agent_docker_cloud_spec | ||
<<: *elastic_docker_spec | ||
<<: *elastic_license_for_binaries | ||
Comment on lines
+1016
to
+1024
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. If I used a previous defined spec (like the complete variant), then docker images were not correctly generated:
so the |
||
files: | ||
'{{.BeatName}}{{.BinaryExt}}': | ||
source: ./build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}} | ||
|
||
- os: linux | ||
arch: amd64 | ||
types: [docker] | ||
|
@@ -1033,6 +1052,19 @@ specs: | |
'{{.BeatName}}{{.BinaryExt}}': | ||
source: ./build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}} | ||
|
||
# Cloud specific docker image | ||
- os: linux | ||
arch: arm64 | ||
types: [docker] | ||
spec: | ||
<<: *agent_docker_arm_spec | ||
<<: *agent_docker_cloud_spec | ||
<<: *elastic_docker_spec | ||
<<: *elastic_license_for_binaries | ||
files: | ||
'{{.BeatName}}{{.BinaryExt}}': | ||
source: ./build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}} | ||
|
||
- os: linux | ||
arch: arm64 | ||
types: [docker] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,11 @@ RUN mkdir -p {{ $beatHome }}/data {{ $beatHome }}/data/elastic-agent-{{ commit_s | |
{{- end }} | ||
{{- range $i, $modulesd := .ModulesDirs }} | ||
chmod 0775 {{ $beatHome}}/{{ $modulesd }} && \ | ||
{{- end }} | ||
{{- if contains .image_name "-cloud" }} | ||
mkdir -p /opt/filebeat /opt/metricbeat && \ | ||
tar xf {{ $beatHome }}/data/elastic-agent-*/downloads/metricbeat-*.tar.gz -C /opt/metricbeat --strip-components=1 && \ | ||
tar xf {{ $beatHome }}/data/elastic-agent-*/downloads/filebeat-*.tar.gz -C /opt/filebeat --strip-components=1 && \ | ||
{{- end }} | ||
true | ||
|
||
|
@@ -41,7 +46,6 @@ RUN case $(arch) in aarch64) YUM_FLAGS="-x bind-license";; esac; \ | |
yum install -y epel-release && \ | ||
yum update -y $YUM_FLAGS && \ | ||
yum install -y jq && \ | ||
|
||
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. Unrelated to this particular change, but let's keep it tidy |
||
yum clean all && \ | ||
exit_code=0 && break || exit_code=$? && echo "yum error: retry $iter in 10s" && sleep 10; \ | ||
done; \ | ||
|
@@ -134,12 +138,26 @@ RUN mkdir /licenses | |
COPY --from=home {{ $beatHome }}/LICENSE.txt /licenses | ||
COPY --from=home {{ $beatHome }}/NOTICE.txt /licenses | ||
|
||
{{- if ne .user "root" }} | ||
{{- if contains .image_name "-cloud" }} | ||
COPY --from=home /opt /opt | ||
{{- end }} | ||
|
||
{{- if eq .user "root" }} | ||
{{- if contains .image_name "-cloud" }} | ||
# Generate folder for a stub command that will be overwritten at runtime | ||
RUN mkdir /app | ||
{{- end }} | ||
{{- else }} | ||
RUN groupadd --gid 1000 {{ .BeatName }} | ||
RUN useradd -M --uid 1000 --gid 1000 --groups 0 --home {{ $beatHome }} {{ .user }} | ||
{{- if (and (eq .Variant "complete") (not (contains .from "ubi-minimal"))) }} | ||
RUN chown {{ .user }} $NODE_PATH | ||
{{- end }} | ||
{{- if contains .image_name "-cloud" }} | ||
# Generate folder for a stub command that will be overwritten at runtime | ||
RUN mkdir /app | ||
RUN chown {{ .user }} /app | ||
{{- end }} | ||
{{- end }} | ||
USER {{ .user }} | ||
|
||
|
@@ -172,7 +190,6 @@ RUN cd {{$beatHome}}/.node \ | |
{{- end }} | ||
|
||
|
||
|
||
{{- range $i, $port := .ExposePorts }} | ||
EXPOSE {{ $port }} | ||
{{- end }} | ||
|
@@ -183,4 +200,13 @@ EXPOSE {{ $port }} | |
ENV LIBBEAT_MONITORING_CGROUPS_HIERARCHY_OVERRIDE=/ | ||
|
||
WORKDIR {{ $beatHome }} | ||
|
||
{{- if contains .image_name "-cloud" }} | ||
ENTRYPOINT ["/usr/bin/tini", "--"] | ||
CMD ["/app/apm.sh"] | ||
# Generate a stub command that will be overwritten at runtime | ||
RUN echo -e '#!/bin/sh\nexec /usr/local/bin/docker-entrypoint' > /app/apm.sh && \ | ||
chmod 0555 /app/apm.sh | ||
{{- else }} | ||
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/docker-entrypoint"] | ||
{{- end }} |
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.
Forced to redefine this particular arg, otherwise: