From da007eb207365483b18f2be723c6c45acfbfbb85 Mon Sep 17 00:00:00 2001 From: Gautham Banasandra Date: Sat, 27 Aug 2022 14:08:29 +0530 Subject: [PATCH] HADOOP-18449. Upgrade hadolint to 2.10.0 * The current version of hadolint (1.11.1) is only suitable for linting Linux commands in Dockerfile. It fails to recognize Windows command syntax. * HADOOP-18133 adds Dockerfile for Windows. Thus, it's essential to upgrade hadolint to 2.10.0 which has the ability to recognize Windows command syntax. --- .hadolint.yaml | 17 ++++++++++++ dev-support/docker/Dockerfile | 2 +- dev-support/docker/Dockerfile_centos_7 | 6 +++-- dev-support/docker/Dockerfile_centos_8 | 21 ++++++++------- dev-support/docker/Dockerfile_debian_10 | 2 +- .../docker/pkg-resolver/install-hadolint.sh | 27 ++++++++++++++----- 6 files changed, 56 insertions(+), 19 deletions(-) create mode 100644 .hadolint.yaml diff --git a/.hadolint.yaml b/.hadolint.yaml new file mode 100644 index 0000000000000..1832932da43f6 --- /dev/null +++ b/.hadolint.yaml @@ -0,0 +1,17 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ignored: + - DL3059 diff --git a/dev-support/docker/Dockerfile b/dev-support/docker/Dockerfile index fac364bbd4363..2e787d274f4de 100644 --- a/dev-support/docker/Dockerfile +++ b/dev-support/docker/Dockerfile @@ -86,7 +86,7 @@ RUN pkg-resolver/install-common-pkgs.sh RUN pkg-resolver/install-spotbugs.sh ubuntu:focal RUN pkg-resolver/install-boost.sh ubuntu:focal RUN pkg-resolver/install-protobuf.sh ubuntu:focal -RUN pkg-resolver/install-hadolint.sh ubuntu:focal +RUN pkg-resolver/install-hadolint.sh ubuntu:focal 2.10.0 RUN pkg-resolver/install-intel-isa-l.sh ubuntu:focal ### diff --git a/dev-support/docker/Dockerfile_centos_7 b/dev-support/docker/Dockerfile_centos_7 index ccb445be269fe..9c3afe6eaf747 100644 --- a/dev-support/docker/Dockerfile_centos_7 +++ b/dev-support/docker/Dockerfile_centos_7 @@ -33,13 +33,14 @@ RUN chmod a+x pkg-resolver/*.sh pkg-resolver/*.py \ ###### # Install packages from yum ###### -# hadolint ignore=DL3008,SC2046 +# hadolint ignore=DL3008,SC2046,DL3033 RUN yum update -y \ && yum groupinstall -y "Development Tools" \ && yum install -y \ centos-release-scl \ python3 \ - && yum install -y $(pkg-resolver/resolve.py centos:7) + && yum install -y $(pkg-resolver/resolve.py centos:7) \ + && yum clean all # Set GCC 9 as the default C/C++ compiler RUN echo "source /opt/rh/devtoolset-9/enable" >> /etc/bashrc @@ -93,4 +94,5 @@ RUN pkg-resolver/install-boost.sh centos:7 RUN pkg-resolver/install-spotbugs.sh centos:7 RUN pkg-resolver/install-nodejs.sh centos:7 RUN pkg-resolver/install-git.sh centos:7 +RUN pkg-resolver/install-hadolint.sh centos:7 2.10.0 RUN pkg-resolver/install-common-pkgs.sh diff --git a/dev-support/docker/Dockerfile_centos_8 b/dev-support/docker/Dockerfile_centos_8 index 8f3b008f7ba03..31890dcc68b4d 100644 --- a/dev-support/docker/Dockerfile_centos_8 +++ b/dev-support/docker/Dockerfile_centos_8 @@ -40,26 +40,28 @@ RUN pkg-resolver/set-vault-as-baseurl-centos.sh centos:8 ###### # Install packages from yum ###### -# hadolint ignore=DL3008,SC2046 +# hadolint ignore=DL3008,SC2046,DL3033 RUN yum update -y \ && yum install -y python3 \ - && yum install -y $(pkg-resolver/resolve.py centos:8) + && yum install -y $(pkg-resolver/resolve.py centos:8) \ + && yum clean all #### # Install EPEL #### RUN pkg-resolver/install-epel.sh centos:8 +# hadolint ignore=DL3033,DL3041 RUN dnf --enablerepo=powertools install -y \ doxygen \ snappy-devel \ - yasm - -RUN dnf install -y \ - bouncycastle \ - gcc-toolset-9-gcc \ - gcc-toolset-9-gcc-c++ \ - libpmem-devel + yasm \ + && dnf install -y \ + bouncycastle \ + gcc-toolset-9-gcc \ + gcc-toolset-9-gcc-c++ \ + libpmem-devel \ + && dnf clean all # Set GCC 9 as the default C/C++ compiler RUN echo "source /opt/rh/gcc-toolset-9/enable" >> /etc/bashrc @@ -115,4 +117,5 @@ RUN pkg-resolver/install-boost.sh centos:8 RUN pkg-resolver/install-spotbugs.sh centos:8 RUN pkg-resolver/install-protobuf.sh centos:8 RUN pkg-resolver/install-zstandard.sh centos:8 +RUN pkg-resolver/install-hadolint.sh centos:8 2.10.0 RUN pkg-resolver/install-common-pkgs.sh diff --git a/dev-support/docker/Dockerfile_debian_10 b/dev-support/docker/Dockerfile_debian_10 index ec3de11035cee..33b328966092e 100644 --- a/dev-support/docker/Dockerfile_debian_10 +++ b/dev-support/docker/Dockerfile_debian_10 @@ -86,7 +86,7 @@ RUN pkg-resolver/install-cmake.sh debian:10 RUN pkg-resolver/install-spotbugs.sh debian:10 RUN pkg-resolver/install-boost.sh debian:10 RUN pkg-resolver/install-protobuf.sh debian:10 -RUN pkg-resolver/install-hadolint.sh debian:10 +RUN pkg-resolver/install-hadolint.sh debian:10 2.10.0 RUN pkg-resolver/install-intel-isa-l.sh debian:10 ### diff --git a/dev-support/docker/pkg-resolver/install-hadolint.sh b/dev-support/docker/pkg-resolver/install-hadolint.sh index 1e2081f38c403..4ef22c3f622e6 100644 --- a/dev-support/docker/pkg-resolver/install-hadolint.sh +++ b/dev-support/docker/pkg-resolver/install-hadolint.sh @@ -27,9 +27,24 @@ if [ $? -eq 1 ]; then exit 1 fi -curl -L -s -S \ - https://github.com/hadolint/hadolint/releases/download/v1.11.1/hadolint-Linux-x86_64 \ - -o /bin/hadolint && - chmod a+rx /bin/hadolint && - shasum -a 512 /bin/hadolint | - awk '$1!="734e37c1f6619cbbd86b9b249e69c9af8ee1ea87a2b1ff71dccda412e9dac35e63425225a95d71572091a3f0a11e9a04c2fc25d9e91b840530c26af32b9891ca" {exit(1)}' +default_version="1.11.1" +version_to_install=$default_version +if [ -n "$2" ]; then + version_to_install="$2" +fi + +if [ "$version_to_install" == "1.11.1" ]; then + curl -L -s -S \ + https://github.com/hadolint/hadolint/releases/download/v1.11.1/hadolint-Linux-x86_64 \ + -o /bin/hadolint && + chmod a+rx /bin/hadolint && + shasum -a 512 /bin/hadolint | + awk '$1!="734e37c1f6619cbbd86b9b249e69c9af8ee1ea87a2b1ff71dccda412e9dac35e63425225a95d71572091a3f0a11e9a04c2fc25d9e91b840530c26af32b9891ca" {exit(1)}' +elif [ "$version_to_install" == "2.10.0" ]; then + curl -L -s -S \ + https://github.com/hadolint/hadolint/releases/download/v2.10.0/hadolint-Linux-x86_64 \ + -o /bin/hadolint && + chmod a+rx /bin/hadolint && + shasum -a 512 /bin/hadolint | + awk '$1!="4816c95243bedf15476d2225f487fc17465495fb2031e1a4797d82a26db83a1edb63e4fed084b80cef17d5eb67eb45508caadaf7cd0252fb061187113991a338" {exit(1)}' +fi