mirror of
https://github.com/elastic/logstash.git
synced 2025-06-27 17:08:55 -04:00
updates to docker image template based on feedback (#17494)
* change base images to ubi9-minimal * do all env2yaml related copying in 1 COPY * use -trimpath in go build * move other COPY to end of dockerfile * don't run package manager upgrade * FROM and AS with same case * ENV x=y instead of ENV x y * remove indirect config folder
This commit is contained in:
parent
b9bac5dfc6
commit
815fa8be1c
1 changed files with 17 additions and 24 deletions
|
@ -13,7 +13,7 @@
|
||||||
<% license = 'Elastic License' -%>
|
<% license = 'Elastic License' -%>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<% if image_flavor == 'full' || image_flavor == 'oss' -%>
|
<% if image_flavor == 'full' || image_flavor == 'oss' -%>
|
||||||
<% base_image = 'docker.elastic.co/ubi9/ubi-minimal' -%>
|
<% base_image = 'redhat/ubi9-minimal:latest' -%>
|
||||||
<% go_image = 'golang:1.23' -%>
|
<% go_image = 'golang:1.23' -%>
|
||||||
<% package_manager = 'microdnf' -%>
|
<% package_manager = 'microdnf' -%>
|
||||||
<% else -%>
|
<% else -%>
|
||||||
|
@ -24,41 +24,28 @@
|
||||||
<% locale = 'C.UTF-8' -%>
|
<% locale = 'C.UTF-8' -%>
|
||||||
|
|
||||||
# Build env2yaml
|
# Build env2yaml
|
||||||
FROM <%= go_image %> as builder-env2yaml
|
FROM <%= go_image %> AS builder-env2yaml
|
||||||
|
|
||||||
COPY env2yaml/env2yaml.go /tmp/go/src/env2yaml/env2yaml.go
|
COPY env2yaml/env2yaml.go env2yaml/go.mod env2yaml/go.sum /tmp/go/src/env2yaml/
|
||||||
COPY env2yaml/go.mod /tmp/go/src/env2yaml/go.mod
|
|
||||||
COPY env2yaml/go.sum /tmp/go/src/env2yaml/go.sum
|
|
||||||
|
|
||||||
WORKDIR /tmp/go/src/env2yaml
|
WORKDIR /tmp/go/src/env2yaml
|
||||||
|
|
||||||
RUN go build
|
RUN go build -trimpath
|
||||||
|
|
||||||
# Build main image
|
# Build main image
|
||||||
# Minimal distributions do not ship with en language packs.
|
# Minimal distributions do not ship with en language packs.
|
||||||
FROM <%= base_image %>
|
FROM <%= base_image %>
|
||||||
|
|
||||||
ENV ELASTIC_CONTAINER true
|
ENV ELASTIC_CONTAINER=true
|
||||||
ENV PATH=/usr/share/logstash/bin:$PATH
|
ENV PATH=/usr/share/logstash/bin:$PATH
|
||||||
ENV LANG=<%= locale %> LC_ALL=<%= locale %>
|
ENV LANG=<%= locale %> LC_ALL=<%= locale %>
|
||||||
|
|
||||||
WORKDIR /usr/share
|
WORKDIR /usr/share
|
||||||
|
|
||||||
COPY --from=builder-env2yaml /tmp/go/src/env2yaml/env2yaml /usr/local/bin/env2yaml
|
|
||||||
COPY config/pipelines.yml config/log4j2.properties config/log4j2.file.properties config/
|
|
||||||
<% if image_flavor == 'oss' -%>
|
|
||||||
COPY config/logstash-oss.yml config/logstash.yml
|
|
||||||
<% else -%><%# 'full', 'wolfi' -%>
|
|
||||||
COPY config/logstash-full.yml config/logstash.yml
|
|
||||||
<% end -%>
|
|
||||||
COPY pipeline/default.conf pipeline/logstash.conf
|
|
||||||
COPY bin/docker-entrypoint /usr/local/bin/
|
|
||||||
|
|
||||||
# Install packages
|
# Install packages
|
||||||
RUN for iter in {1..10}; do \
|
RUN for iter in {1..10}; do \
|
||||||
<% if image_flavor == 'full' || image_flavor == 'oss' -%>
|
<% if image_flavor == 'full' || image_flavor == 'oss' -%>
|
||||||
<%= package_manager %> update -y && \
|
<%= package_manager %> update -y && \
|
||||||
<%= package_manager %> upgrade -y && \
|
|
||||||
<%= package_manager %> install -y procps findutils tar gzip && \
|
<%= package_manager %> install -y procps findutils tar gzip && \
|
||||||
<%= package_manager %> install -y openssl && \
|
<%= package_manager %> install -y openssl && \
|
||||||
<%= package_manager %> install -y which shadow-utils && \
|
<%= package_manager %> install -y which shadow-utils && \
|
||||||
|
@ -93,17 +80,23 @@ RUN addgroup -g 1000 logstash && \
|
||||||
curl -Lo - <%= url_root %>/<%= tarball %> | \
|
curl -Lo - <%= url_root %>/<%= tarball %> | \
|
||||||
tar zxf - -C /usr/share && \
|
tar zxf - -C /usr/share && \
|
||||||
mv /usr/share/logstash-<%= elastic_version %> /usr/share/logstash && \
|
mv /usr/share/logstash-<%= elastic_version %> /usr/share/logstash && \
|
||||||
chown -R logstash:root /usr/share/logstash config/ pipeline/ && \
|
chown -R logstash:root /usr/share/logstash && \
|
||||||
chmod -R g=u /usr/share/logstash && \
|
chmod -R g=u /usr/share/logstash && \
|
||||||
mv config/* /usr/share/logstash/config && \
|
|
||||||
mv pipeline /usr/share/logstash/pipeline && \
|
|
||||||
mkdir /licenses && \
|
mkdir /licenses && \
|
||||||
mv /usr/share/logstash/NOTICE.TXT /licenses/NOTICE.TXT && \
|
mv /usr/share/logstash/NOTICE.TXT /licenses/NOTICE.TXT && \
|
||||||
mv /usr/share/logstash/LICENSE.txt /licenses/LICENSE.txt && \
|
mv /usr/share/logstash/LICENSE.txt /licenses/LICENSE.txt && \
|
||||||
find /usr/share/logstash -type d -exec chmod g+s {} \; && \
|
find /usr/share/logstash -type d -exec chmod g+s {} \; && \
|
||||||
ln -s /usr/share/logstash /opt/logstash && \
|
ln -s /usr/share/logstash /opt/logstash
|
||||||
chmod 0755 /usr/local/bin/docker-entrypoint && \
|
|
||||||
rmdir config
|
COPY --from=builder-env2yaml /tmp/go/src/env2yaml/env2yaml /usr/local/bin/env2yaml
|
||||||
|
COPY --chown=logstash:root config/pipelines.yml config/log4j2.properties config/log4j2.file.properties /usr/share/logstash/config/
|
||||||
|
<% if image_flavor == 'oss' -%>
|
||||||
|
COPY --chown=logstash:root config/logstash-oss.yml /usr/share/logstash/config/logstash.yml
|
||||||
|
<% else -%><%# 'full', 'wolfi' -%>
|
||||||
|
COPY --chown=logstash:root config/logstash-full.yml /usr/share/logstash/config/logstash.yml
|
||||||
|
<% end -%>
|
||||||
|
COPY --chown=logstash:root pipeline/default.conf /usr/share/logstash/pipeline/logstash.conf
|
||||||
|
COPY --chmod=0755 bin/docker-entrypoint /usr/local/bin/
|
||||||
|
|
||||||
WORKDIR /usr/share/logstash
|
WORKDIR /usr/share/logstash
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue