Skip to content

Commit

Permalink
feat: Add posibility to specify custom versions via build-arg
Browse files Browse the repository at this point in the history
I.e.
docker build -t pre-commit --build-arg PRE_COMMIT_VERSION=2.14.0  .
  • Loading branch information
MaxymVlasov committed Sep 9, 2021
1 parent ed42a86 commit b66251b
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 && \
Expand All @@ -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}

Expand All @@ -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" ]

0 comments on commit b66251b

Please sign in to comment.