Skip to content

Commit a45e75d

Browse files
authored
Check downloaded beats archives (#81222) (#81229)
Part of #81150. Sometimes, building the Cloud Docker images fails due to some issue with the `.tar.gz` files. Add extra checks and error messages so that we have a better idea what the precise problem is.
1 parent 50ae1f3 commit a45e75d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

distribution/docker/src/docker/Dockerfile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,20 @@ RUN echo "plugins:" > config/elasticsearch-plugins.example.yml && \\
126126
echo " - id: repository-gcs" >> config/elasticsearch-plugins.example.yml && \\
127127
echo " - id: repository-s3" >> config/elasticsearch-plugins.example.yml
128128

129-
<% /* I tried to use `ADD` here, but I couldn't force it to do what I wanted */ %>
130129
COPY filebeat-${version}.tar.gz metricbeat-${version}.tar.gz /tmp/
131-
RUN mkdir -p /opt/filebeat /opt/metricbeat && \\
132-
tar xf /tmp/filebeat-${version}.tar.gz -C /opt/filebeat --strip-components=1 && \\
133-
tar xf /tmp/metricbeat-${version}.tar.gz -C /opt/metricbeat --strip-components=1
130+
RUN set -eux ; \\
131+
for beat in filebeat metricbeat ; do \\
132+
if [ ! -s /tmp/\$beat-${version}.tar.gz ]; then \\
133+
echo "/tmp/\$beat-${version}.tar.gz is empty - cannot uncompress" 2>&1 ; \\
134+
exit 1 ; \\
135+
fi ; \\
136+
if ! tar tf /tmp/\$beat-${version}.tar.gz >/dev/null; then \\
137+
echo "/tmp/\$beat-${version}.tar.gz is corrupt - cannot uncompress" 2>&1 ; \\
138+
exit 1 ; \\
139+
fi ; \\
140+
mkdir -p /opt/\$beat ; \\
141+
tar xf /tmp/\$beat-${version}.tar.gz -C /opt/\$beat --strip-components=1 ; \\
142+
done
134143

135144
# Add plugins infrastructure
136145
RUN mkdir -p /opt/plugins/archive

0 commit comments

Comments
 (0)