From b66251b7f1c2fa45e745432c5fdbbdc66192fe7c Mon Sep 17 00:00:00 2001 From: MaxymVlasov Date: Thu, 9 Sep 2021 11:43:15 +0300 Subject: [PATCH] feat: Add posibility to specify custom versions via build-arg I.e. docker build -t pre-commit --build-arg PRE_COMMIT_VERSION=2.14.0 . --- Dockerfile | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index f089b1640..4c1fb6ee1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,12 @@ FROM ubuntu:20.04 -ARG PRE_COMMIT_VERSION="2.11.1" -ARG TERRAFORM_VERSION="0.15.0" -ARG TFSEC_VERSION="v0.58.6" -ARG TERRAFORM_DOCS_VERSION="v0.12.0" -ARG TFLINT_VERSION="v0.27.0" -ARG CHECKOV_VERSION="1.0.838" -ARG TERRASCAN_VERSION="1.10.0" +ARG PRE_COMMIT_VERSION=${PRE_COMMIT_VERSION:-2.11.1} +ARG TERRAFORM_VERSION=${TERRAFORM_VERSION:-0.15.0} +ARG TFSEC_VERSION=${TFSEC_VERSION:-0.58.6} +ARG TERRAFORM_DOCS_VERSION=${TERRAFORM_DOCS_VERSION:-0.12.0} +ARG TFLINT_VERSION=${TFLINT_VERSION:-0.27.0} +ARG CHECKOV_VERSION=${CHECKOV_VERSION:-1.0.838} +ARG TERRASCAN_VERSION=${TERRASCAN_VERSION:-1.10.0} # Install general dependencies RUN apt update && \ @@ -27,9 +27,9 @@ RUN pip3 install --no-cache-dir pre-commit==${PRE_COMMIT_VERSION} # Install tools RUN \ - curl -L "$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases | grep -o -E "https://.+?${TERRAFORM_DOCS_VERSION}-linux-amd64.tar.gz")" > terraform-docs.tgz && tar -xzf terraform-docs.tgz terraform-docs && chmod +x terraform-docs && mv terraform-docs /usr/bin/ && \ - curl -L "$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases | grep -o -E "https://.+?/${TFLINT_VERSION}/tflint_linux_amd64.zip")" > tflint.zip && unzip tflint.zip && rm tflint.zip && mv tflint /usr/bin/ && \ - curl -L "$(curl -s https://api.github.com/repos/aquasecurity/tfsec/releases | grep -o -E "https://.+?${TFSEC_VERSION}/tfsec-linux-amd64" | head -n 1)" > tfsec && chmod +x tfsec && mv tfsec /usr/bin/ && \ + curl -L "$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases | grep -o -E "https://.+?v${TERRAFORM_DOCS_VERSION}-linux-amd64.tar.gz")" > terraform-docs.tgz && tar -xzf terraform-docs.tgz terraform-docs && chmod +x terraform-docs && mv terraform-docs /usr/bin/ && \ + curl -L "$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases | grep -o -E "https://.+?/v${TFLINT_VERSION}/tflint_linux_amd64.zip")" > tflint.zip && unzip tflint.zip && rm tflint.zip && mv tflint /usr/bin/ && \ + curl -L "$(curl -s https://api.github.com/repos/aquasecurity/tfsec/releases | grep -o -E "https://.+?v${TFSEC_VERSION}/tfsec-linux-amd64" | head -n 1)" > tfsec && chmod +x tfsec && mv tfsec /usr/bin/ && \ curl -L "$(curl -s https://api.github.com/repos/accurics/terrascan/releases | grep -o -E "https://.+?${TERRASCAN_VERSION}_Linux_x86_64.tar.gz")" > terrascan.tar.gz && tar -xzf terrascan.tar.gz terrascan && rm terrascan.tar.gz && mv terrascan /usr/bin/ && \ pip3 install --no-cache-dir checkov==${CHECKOV_VERSION} @@ -41,13 +41,15 @@ RUN curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - && \ # Cleanup rm -rf /var/lib/apt/lists/* -# Checking all binaries are in the PATH -RUN terraform --help >/dev/null -RUN pre-commit --help >/dev/null -RUN terraform-docs --help >/dev/null -RUN tflint --help >/dev/null -RUN tfsec --help >/dev/null -RUN checkov --help >/dev/null -RUN terrascan --help >/dev/null +# Checking that all binaries are in the PATH and show their versions +RUN echo "\n\n" && \ + pre-commit --version && \ + terraform --version | head -n 1 && \ + terraform-docs --version && \ + tflint --version && \ + echo -n "tfsec " && tfsec --version && \ + echo -n "checkov " && checkov --version && \ + echo -n "terrascan " && terrascan version && \ + echo "\n\n" ENTRYPOINT [ "pre-commit" ]