Skip to content

Commit 23f45de

Browse files
committed
updates to docker image template based on feedback
* 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
1 parent eeb2162 commit 23f45de

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

docker/templates/Dockerfile.erb

+17-24
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<% license = 'Elastic License' -%>
1414
<% end -%>
1515
<% if image_flavor == 'full' || image_flavor == 'oss' -%>
16-
<% base_image = 'docker.elastic.co/ubi9/ubi-minimal' -%>
16+
<% base_image = 'redhat/ubi9-minimal:latest' -%>
1717
<% go_image = 'golang:1.23' -%>
1818
<% package_manager = 'microdnf' -%>
1919
<% else -%>
@@ -24,41 +24,28 @@
2424
<% locale = 'C.UTF-8' -%>
2525

2626
# Build env2yaml
27-
FROM <%= go_image %> as builder-env2yaml
27+
FROM <%= go_image %> AS builder-env2yaml
2828

29-
COPY env2yaml/env2yaml.go /tmp/go/src/env2yaml/env2yaml.go
30-
COPY env2yaml/go.mod /tmp/go/src/env2yaml/go.mod
31-
COPY env2yaml/go.sum /tmp/go/src/env2yaml/go.sum
29+
COPY env2yaml/env2yaml.go env2yaml/go.mod env2yaml/go.sum /tmp/go/src/env2yaml/
3230

3331
WORKDIR /tmp/go/src/env2yaml
3432

35-
RUN go build
33+
RUN go build -trimpath
3634

3735
# Build main image
3836
# Minimal distributions do not ship with en language packs.
3937
FROM <%= base_image %>
4038

41-
ENV ELASTIC_CONTAINER true
39+
ENV ELASTIC_CONTAINER=true
4240
ENV PATH=/usr/share/logstash/bin:$PATH
4341
ENV LANG=<%= locale %> LC_ALL=<%= locale %>
4442

4543
WORKDIR /usr/share
4644

47-
COPY --from=builder-env2yaml /tmp/go/src/env2yaml/env2yaml /usr/local/bin/env2yaml
48-
COPY config/pipelines.yml config/log4j2.properties config/log4j2.file.properties config/
49-
<% if image_flavor == 'oss' -%>
50-
COPY config/logstash-oss.yml config/logstash.yml
51-
<% else -%><%# 'full', 'wolfi' -%>
52-
COPY config/logstash-full.yml config/logstash.yml
53-
<% end -%>
54-
COPY pipeline/default.conf pipeline/logstash.conf
55-
COPY bin/docker-entrypoint /usr/local/bin/
56-
5745
# Install packages
5846
RUN for iter in {1..10}; do \
5947
<% if image_flavor == 'full' || image_flavor == 'oss' -%>
6048
<%= package_manager %> update -y && \
61-
<%= package_manager %> upgrade -y && \
6249
<%= package_manager %> install -y procps findutils tar gzip && \
6350
<%= package_manager %> install -y openssl && \
6451
<%= package_manager %> install -y which shadow-utils && \
@@ -93,17 +80,23 @@ RUN addgroup -g 1000 logstash && \
9380
curl -Lo - <%= url_root %>/<%= tarball %> | \
9481
tar zxf - -C /usr/share && \
9582
mv /usr/share/logstash-<%= elastic_version %> /usr/share/logstash && \
96-
chown -R logstash:root /usr/share/logstash config/ pipeline/ && \
83+
chown -R logstash:root /usr/share/logstash && \
9784
chmod -R g=u /usr/share/logstash && \
98-
mv config/* /usr/share/logstash/config && \
99-
mv pipeline /usr/share/logstash/pipeline && \
10085
mkdir /licenses && \
10186
mv /usr/share/logstash/NOTICE.TXT /licenses/NOTICE.TXT && \
10287
mv /usr/share/logstash/LICENSE.txt /licenses/LICENSE.txt && \
10388
find /usr/share/logstash -type d -exec chmod g+s {} \; && \
104-
ln -s /usr/share/logstash /opt/logstash && \
105-
chmod 0755 /usr/local/bin/docker-entrypoint && \
106-
rmdir config
89+
ln -s /usr/share/logstash /opt/logstash
90+
91+
COPY --from=builder-env2yaml /tmp/go/src/env2yaml/env2yaml /usr/local/bin/env2yaml
92+
COPY --chown=logstash:root config/pipelines.yml config/log4j2.properties config/log4j2.file.properties /usr/share/logstash/config/
93+
<% if image_flavor == 'oss' -%>
94+
COPY --chown=logstash:root config/logstash-oss.yml /usr/share/logstash/config/logstash.yml
95+
<% else -%><%# 'full', 'wolfi' -%>
96+
COPY --chown=logstash:root config/logstash-full.yml /usr/share/logstash/config/logstash.yml
97+
<% end -%>
98+
COPY --chown=logstash:root pipeline/default.conf /usr/share/logstash/pipeline/logstash.conf
99+
COPY --chmod=0755 bin/docker-entrypoint /usr/local/bin/
107100

108101
WORKDIR /usr/share/logstash
109102

0 commit comments

Comments
 (0)