-
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 docker images based on Red Hat UBI #20576
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
32fd76c
Recover previous changes for UBI images
jsoriano 0f03307
Copy licenses
jsoriano e136dcc
Use ubi-minimal
jsoriano 655595f
Move licenses to the expected location
jsoriano ddd4f2f
Add labels
jsoriano 90a1b76
Use latest ubi-minimal for UBI docker builds
jsoriano 4898800
Add more labels
jsoriano 60b413c
Copy proper licenses and add test for them
jsoriano 1c5ee97
Add checks for labels
jsoriano 902f574
Fix package tests for elastic-agent
jsoriano d7933ff
Explicitly select Dockerfile and entrypoint
jsoriano 38085a8
Leverage the use of PLATFORMS when selecting required packages for agent
jsoriano f978f4a
Fix package tests for elastic-agent
jsoriano b7ef2b0
Install jq in ubi image for agent
jsoriano e1539d1
Add changelog entry
jsoriano File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,36 @@ | |
{{- $beatBinary := printf "%s/%s" $beatHome .BeatName }} | ||
{{- $repoInfo := repo }} | ||
|
||
# Prepare home in a different stage to avoid creating additional layers on | ||
# the final image because of permission changes. | ||
FROM {{ .buildFrom }} AS home | ||
|
||
COPY beat {{ $beatHome }} | ||
|
||
RUN mkdir -p {{ $beatHome }}/data {{ $beatHome }}/logs && \ | ||
chown -R root:root {{ $beatHome }} && \ | ||
find {{ $beatHome }} -type d -exec chmod 0750 {} \; && \ | ||
find {{ $beatHome }} -type f -exec chmod 0640 {} \; && \ | ||
chmod 0750 {{ $beatBinary }} && \ | ||
{{- if .linux_capabilities }} | ||
setcap {{ .linux_capabilities }} {{ $beatBinary }} && \ | ||
{{- end }} | ||
{{- range $i, $modulesd := .ModulesDirs }} | ||
chmod 0770 {{ $beatHome}}/{{ $modulesd }} && \ | ||
{{- end }} | ||
chmod 0770 {{ $beatHome }}/data {{ $beatHome }}/logs | ||
|
||
FROM {{ .from }} | ||
|
||
{{- if contains .from "ubi-minimal" }} | ||
RUN for iter in {1..10}; do microdnf update -y && microdnf install -y shadow-utils && microdnf clean all && exit_code=0 && break || exit_code=$? && echo "microdnf error: retry $iter in 10s" && sleep 10; done; (exit $exit_code) | ||
RUN curl -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -o /usr/local/bin/jq && \ | ||
chmod +x /usr/local/bin/jq | ||
{{- else }} | ||
# Installing jq needs to be installed after epel-release and cannot be in the same yum install command. | ||
RUN for iter in {1..10}; do yum update --setopt=tsflags=nodocs -y && yum install --setopt=tsflags=nodocs -y epel-release && yum clean all && exit_code=0 && break || exit_code=$? && echo "yum error: retry $iter in 10s" && sleep 10; done; (exit $exit_code) | ||
RUN for iter in {1..10}; do yum update -y && yum install -y jq && yum clean all && exit_code=0 && break || exit_code=$? && echo "yum error: retry $iter in 10s" && sleep 10; done; (exit $exit_code) | ||
{{- end }} | ||
|
||
LABEL \ | ||
org.label-schema.build-date="{{ date }}" \ | ||
|
@@ -18,33 +43,37 @@ LABEL \ | |
org.label-schema.url="{{ .BeatURL }}" \ | ||
org.label-schema.vcs-url="{{ $repoInfo.RootImportPath }}" \ | ||
org.label-schema.vcs-ref="{{ commit }}" \ | ||
io.k8s.description="{{ .BeatDescription }}" \ | ||
io.k8s.display-name="{{ .BeatName | title }} image" \ | ||
org.opencontainers.image.created="{{ date }}" \ | ||
org.opencontainers.image.licenses="{{ .License }}" \ | ||
org.opencontainers.image.title="{{ .BeatName | title }}" \ | ||
org.opencontainers.image.vendor="{{ .BeatVendor }}" \ | ||
name="{{ .BeatName }}" \ | ||
maintainer="[email protected]" \ | ||
vendor="{{ .BeatVendor }}" \ | ||
version="{{ beat_version }}" \ | ||
release="1" \ | ||
url="{{ .BeatURL }}" \ | ||
summary="{{ .BeatName }}" \ | ||
license="{{ .License }}" \ | ||
description="{{ .BeatDescription }}" | ||
|
||
ENV ELASTIC_CONTAINER "true" | ||
ENV PATH={{ $beatHome }}:$PATH | ||
|
||
COPY beat {{ $beatHome }} | ||
COPY docker-entrypoint /usr/local/bin/docker-entrypoint | ||
RUN chmod 755 /usr/local/bin/docker-entrypoint | ||
|
||
RUN groupadd --gid 1000 {{ .BeatName }} | ||
COPY --from=home {{ $beatHome }} {{ $beatHome }} | ||
|
||
RUN mkdir -p {{ $beatHome }}/data {{ $beatHome }}/logs && \ | ||
chown -R root:{{ .BeatName }} {{ $beatHome }} && \ | ||
find {{ $beatHome }} -type d -exec chmod 0750 {} \; && \ | ||
find {{ $beatHome }} -type f -exec chmod 0640 {} \; && \ | ||
chmod 0750 {{ $beatBinary }} && \ | ||
{{- if .linux_capabilities }} | ||
setcap {{ .linux_capabilities }} {{ $beatBinary }} && \ | ||
{{- end }} | ||
{{- range $i, $modulesd := .ModulesDirs }} | ||
chmod 0770 {{ $beatHome}}/{{ $modulesd }} && \ | ||
{{- end }} | ||
chmod 0770 {{ $beatHome }}/data {{ $beatHome }}/logs | ||
RUN mkdir /licenses | ||
COPY --from=home {{ $beatHome }}/LICENSE.txt /licenses | ||
COPY --from=home {{ $beatHome }}/NOTICE.txt /licenses | ||
|
||
{{- if ne .user "root" }} | ||
RUN useradd -M --uid 1000 --gid 1000 --home {{ $beatHome }} {{ .user }} | ||
RUN groupadd --gid 1000 {{ .BeatName }} | ||
RUN useradd -M --uid 1000 --gid 1000 --groups 0 --home {{ $beatHome }} {{ .user }} | ||
{{- end }} | ||
USER {{ .user }} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
👍