Skip to content

Commit f255b05

Browse files
antm-ppyermulnikMaxymVlasov
authored
fix(docker): Checkov installation silently fails on docker build in arm64. Workaround till issue will be fixed in checkov itself (#635)
--------- Co-authored-by: George L. Yermulnik <yz@yz.kiev.ua> Co-authored-by: MaxymVlasov <MaxymVlasov@users.noreply.github.com>
1 parent cfe4477 commit f255b05

File tree

2 files changed

+55
-24
lines changed

2 files changed

+55
-24
lines changed

.github/.container-structure-test-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ commandTests:
1515
args: ["-version"]
1616
expectedOutput: ["^Terraform v([0-9]+\\.){2}[0-9]+\\non linux_amd64\\n$"]
1717

18+
- name: "gcc"
19+
command: "gcc"
20+
args: ["--version"]
21+
expectedOutput: ["^gcc \\(Alpine 12\\."]
22+
1823
- name: "checkov"
1924
command: "checkov"
2025
args: ["--version"]

Dockerfile

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ ARG PRE_COMMIT_VERSION=${PRE_COMMIT_VERSION:-latest}
1717
ARG TERRAFORM_VERSION=${TERRAFORM_VERSION:-latest}
1818

1919
# Install pre-commit
20-
RUN [ ${PRE_COMMIT_VERSION} = "latest" ] && pip3 install --no-cache-dir pre-commit \
21-
|| pip3 install --no-cache-dir pre-commit==${PRE_COMMIT_VERSION}
20+
RUN if [ ${PRE_COMMIT_VERSION} = "latest" ]; \
21+
then pip3 install --no-cache-dir pre-commit; \
22+
else pip3 install --no-cache-dir pre-commit==${PRE_COMMIT_VERSION}; \
23+
fi
2224

2325
# Install terraform because pre-commit needs it
2426
RUN if [ "${TERRAFORM_VERSION}" = "latest" ]; then \
@@ -66,10 +68,16 @@ RUN if [ "$INSTALL_ALL" != "false" ]; then \
6668
RUN . /.env && \
6769
if [ "$CHECKOV_VERSION" != "false" ]; then \
6870
( \
69-
apk add --no-cache gcc=~12 libffi-dev=~3 musl-dev=~1; \
70-
[ "$CHECKOV_VERSION" = "latest" ] && pip3 install --no-cache-dir checkov \
71-
|| pip3 install --no-cache-dir checkov==${CHECKOV_VERSION}; \
72-
apk del gcc libffi-dev musl-dev \
71+
# cargo, gcc, git, musl-dev, rust and CARGO envvar required for compilation of rustworkx@0.13.2, no longer required once checkov version depends on rustworkx >0.14.0
72+
# https://github.com/bridgecrewio/checkov/pull/6045
73+
# gcc libffi-dev musl-dev required for compilation of cffi, until it contains musl aarch64
74+
export CARGO_NET_GIT_FETCH_WITH_CLI=true && \
75+
apk add --no-cache cargo=~1 gcc=~12 git=~2 libffi-dev=~3 libgcc=~12 musl-dev=~1 rust=~1 ; \
76+
if [ "$CHECKOV_VERSION" = "latest" ]; \
77+
then pip3 install --no-cache-dir checkov || exit 1; \
78+
else pip3 install --no-cache-dir checkov==${CHECKOV_VERSION} || exit 1; \
79+
fi; \
80+
apk del cargo gcc git libffi-dev musl-dev rust \
7381
) \
7482
; fi
7583

@@ -78,8 +86,10 @@ RUN . /.env && \
7886
if [ "$INFRACOST_VERSION" != "false" ]; then \
7987
( \
8088
INFRACOST_RELEASES="https://api.github.com/repos/infracost/infracost/releases" && \
81-
[ "$INFRACOST_VERSION" = "latest" ] && curl -L "$(curl -s ${INFRACOST_RELEASES}/latest | grep -o -E -m 1 "https://.+?-${TARGETOS}-${TARGETARCH}.tar.gz")" > infracost.tgz \
82-
|| curl -L "$(curl -s ${INFRACOST_RELEASES} | grep -o -E "https://.+?v${INFRACOST_VERSION}/infracost-${TARGETOS}-${TARGETARCH}.tar.gz")" > infracost.tgz \
89+
if [ "$INFRACOST_VERSION" = "latest" ]; \
90+
then curl -L "$(curl -s ${INFRACOST_RELEASES}/latest | grep -o -E -m 1 "https://.+?-${TARGETOS}-${TARGETARCH}.tar.gz")" > infracost.tgz; \
91+
else curl -L "$(curl -s ${INFRACOST_RELEASES} | grep -o -E "https://.+?v${INFRACOST_VERSION}/infracost-${TARGETOS}-${TARGETARCH}.tar.gz")" > infracost.tgz; \
92+
fi; \
8393
) && tar -xzf infracost.tgz && rm infracost.tgz && mv infracost-${TARGETOS}-${TARGETARCH} infracost \
8494
; fi
8595

@@ -88,8 +98,10 @@ RUN . /.env && \
8898
if [ "$TERRAFORM_DOCS_VERSION" != "false" ]; then \
8999
( \
90100
TERRAFORM_DOCS_RELEASES="https://api.github.com/repos/terraform-docs/terraform-docs/releases" && \
91-
[ "$TERRAFORM_DOCS_VERSION" = "latest" ] && curl -L "$(curl -s ${TERRAFORM_DOCS_RELEASES}/latest | grep -o -E -m 1 "https://.+?-${TARGETOS}-${TARGETARCH}.tar.gz")" > terraform-docs.tgz \
92-
|| curl -L "$(curl -s ${TERRAFORM_DOCS_RELEASES} | grep -o -E "https://.+?v${TERRAFORM_DOCS_VERSION}-${TARGETOS}-${TARGETARCH}.tar.gz")" > terraform-docs.tgz \
101+
if [ "$TERRAFORM_DOCS_VERSION" = "latest" ]; \
102+
then curl -L "$(curl -s ${TERRAFORM_DOCS_RELEASES}/latest | grep -o -E -m 1 "https://.+?-${TARGETOS}-${TARGETARCH}.tar.gz")" > terraform-docs.tgz; \
103+
else curl -L "$(curl -s ${TERRAFORM_DOCS_RELEASES} | grep -o -E "https://.+?v${TERRAFORM_DOCS_VERSION}-${TARGETOS}-${TARGETARCH}.tar.gz")" > terraform-docs.tgz; \
104+
fi; \
93105
) && tar -xzf terraform-docs.tgz terraform-docs && rm terraform-docs.tgz && chmod +x terraform-docs \
94106
; fi
95107

@@ -98,8 +110,10 @@ RUN . /.env \
98110
&& if [ "$TERRAGRUNT_VERSION" != "false" ]; then \
99111
( \
100112
TERRAGRUNT_RELEASES="https://api.github.com/repos/gruntwork-io/terragrunt/releases" && \
101-
[ "$TERRAGRUNT_VERSION" = "latest" ] && curl -L "$(curl -s ${TERRAGRUNT_RELEASES}/latest | grep -o -E -m 1 "https://.+?/terragrunt_${TARGETOS}_${TARGETARCH}")" > terragrunt \
102-
|| curl -L "$(curl -s ${TERRAGRUNT_RELEASES} | grep -o -E -m 1 "https://.+?v${TERRAGRUNT_VERSION}/terragrunt_${TARGETOS}_${TARGETARCH}")" > terragrunt \
113+
if [ "$TERRAGRUNT_VERSION" = "latest" ]; \
114+
then curl -L "$(curl -s ${TERRAGRUNT_RELEASES}/latest | grep -o -E -m 1 "https://.+?/terragrunt_${TARGETOS}_${TARGETARCH}")" > terragrunt; \
115+
else curl -L "$(curl -s ${TERRAGRUNT_RELEASES} | grep -o -E -m 1 "https://.+?v${TERRAGRUNT_VERSION}/terragrunt_${TARGETOS}_${TARGETARCH}")" > terragrunt; \
116+
fi; \
103117
) && chmod +x terragrunt \
104118
; fi
105119

@@ -112,8 +126,10 @@ RUN . /.env && \
112126
OS="$(echo ${TARGETOS} | cut -c1 | tr '[:lower:]' '[:upper:]' | xargs echo -n; echo ${TARGETOS} | cut -c2-)"; \
113127
( \
114128
TERRASCAN_RELEASES="https://api.github.com/repos/tenable/terrascan/releases" && \
115-
[ "$TERRASCAN_VERSION" = "latest" ] && curl -L "$(curl -s ${TERRASCAN_RELEASES}/latest | grep -o -E -m 1 "https://.+?_${OS}_${ARCH}.tar.gz")" > terrascan.tar.gz \
116-
|| curl -L "$(curl -s ${TERRASCAN_RELEASES} | grep -o -E "https://.+?${TERRASCAN_VERSION}_${OS}_${ARCH}.tar.gz")" > terrascan.tar.gz \
129+
if [ "$TERRASCAN_VERSION" = "latest" ]; \
130+
then curl -L "$(curl -s ${TERRASCAN_RELEASES}/latest | grep -o -E -m 1 "https://.+?_${OS}_${ARCH}.tar.gz")" > terrascan.tar.gz; \
131+
else curl -L "$(curl -s ${TERRASCAN_RELEASES} | grep -o -E "https://.+?${TERRASCAN_VERSION}_${OS}_${ARCH}.tar.gz")" > terrascan.tar.gz; \
132+
fi; \
117133
) && tar -xzf terrascan.tar.gz terrascan && rm terrascan.tar.gz && \
118134
./terrascan init \
119135
; fi
@@ -123,8 +139,10 @@ RUN . /.env && \
123139
if [ "$TFLINT_VERSION" != "false" ]; then \
124140
( \
125141
TFLINT_RELEASES="https://api.github.com/repos/terraform-linters/tflint/releases" && \
126-
[ "$TFLINT_VERSION" = "latest" ] && curl -L "$(curl -s ${TFLINT_RELEASES}/latest | grep -o -E -m 1 "https://.+?_${TARGETOS}_${TARGETARCH}.zip")" > tflint.zip \
127-
|| curl -L "$(curl -s ${TFLINT_RELEASES} | grep -o -E "https://.+?/v${TFLINT_VERSION}/tflint_${TARGETOS}_${TARGETARCH}.zip")" > tflint.zip \
142+
if [ "$TFLINT_VERSION" = "latest" ]; \
143+
then curl -L "$(curl -s ${TFLINT_RELEASES}/latest | grep -o -E -m 1 "https://.+?_${TARGETOS}_${TARGETARCH}.zip")" > tflint.zip; \
144+
else curl -L "$(curl -s ${TFLINT_RELEASES} | grep -o -E "https://.+?/v${TFLINT_VERSION}/tflint_${TARGETOS}_${TARGETARCH}.zip")" > tflint.zip; \
145+
fi; \
128146
) && unzip tflint.zip && rm tflint.zip \
129147
; fi
130148

@@ -133,8 +151,10 @@ RUN . /.env && \
133151
if [ "$TFSEC_VERSION" != "false" ]; then \
134152
( \
135153
TFSEC_RELEASES="https://api.github.com/repos/aquasecurity/tfsec/releases" && \
136-
[ "$TFSEC_VERSION" = "latest" ] && curl -L "$(curl -s ${TFSEC_RELEASES}/latest | grep -o -E -m 1 "https://.+?/tfsec-${TARGETOS}-${TARGETARCH}")" > tfsec \
137-
|| curl -L "$(curl -s ${TFSEC_RELEASES} | grep -o -E -m 1 "https://.+?v${TFSEC_VERSION}/tfsec-${TARGETOS}-${TARGETARCH}")" > tfsec \
154+
if [ "$TFSEC_VERSION" = "latest" ]; then \
155+
curl -L "$(curl -s ${TFSEC_RELEASES}/latest | grep -o -E -m 1 "https://.+?/tfsec-${TARGETOS}-${TARGETARCH}")" > tfsec; \
156+
else curl -L "$(curl -s ${TFSEC_RELEASES} | grep -o -E -m 1 "https://.+?v${TFSEC_VERSION}/tfsec-${TARGETOS}-${TARGETARCH}")" > tfsec; \
157+
fi; \
138158
) && chmod +x tfsec \
139159
; fi
140160

@@ -144,8 +164,10 @@ RUN . /.env && \
144164
if [ "$TARGETARCH" != "amd64" ]; then ARCH="$TARGETARCH"; else ARCH="64bit"; fi; \
145165
( \
146166
TRIVY_RELEASES="https://api.github.com/repos/aquasecurity/trivy/releases" && \
147-
[ "$TRIVY_VERSION" = "latest" ] && curl -L "$(curl -s ${TRIVY_RELEASES}/latest | grep -o -E -i -m 1 "https://.+?/trivy_.+?_${TARGETOS}-${ARCH}.tar.gz")" > trivy.tar.gz \
148-
|| curl -L "$(curl -s ${TRIVY_RELEASES} | grep -o -E -i -m 1 "https://.+?/v${TRIVY_VERSION}/trivy_.+?_${TARGETOS}-${ARCH}.tar.gz")" > trivy.tar.gz \
167+
if [ "$TRIVY_VERSION" = "latest" ]; \
168+
then curl -L "$(curl -s ${TRIVY_RELEASES}/latest | grep -o -E -i -m 1 "https://.+?/trivy_.+?_${TARGETOS}-${ARCH}.tar.gz")" > trivy.tar.gz; \
169+
else curl -L "$(curl -s ${TRIVY_RELEASES} | grep -o -E -i -m 1 "https://.+?/v${TRIVY_VERSION}/trivy_.+?_${TARGETOS}-${ARCH}.tar.gz")" > trivy.tar.gz; \
170+
fi; \
149171
) && tar -xzf trivy.tar.gz trivy && rm trivy.tar.gz \
150172
; fi
151173

@@ -154,8 +176,10 @@ RUN . /.env && \
154176
if [ "$TFUPDATE_VERSION" != "false" ]; then \
155177
( \
156178
TFUPDATE_RELEASES="https://api.github.com/repos/minamijoyo/tfupdate/releases" && \
157-
[ "$TFUPDATE_VERSION" = "latest" ] && curl -L "$(curl -s ${TFUPDATE_RELEASES}/latest | grep -o -E -m 1 "https://.+?_${TARGETOS}_${TARGETARCH}.tar.gz")" > tfupdate.tgz \
158-
|| curl -L "$(curl -s ${TFUPDATE_RELEASES} | grep -o -E -m 1 "https://.+?${TFUPDATE_VERSION}_${TARGETOS}_${TARGETARCH}.tar.gz")" > tfupdate.tgz \
179+
if [ "$TFUPDATE_VERSION" = "latest" ]; \
180+
then curl -L "$(curl -s ${TFUPDATE_RELEASES}/latest | grep -o -E -m 1 "https://.+?_${TARGETOS}_${TARGETARCH}.tar.gz")" > tfupdate.tgz; \
181+
else curl -L "$(curl -s ${TFUPDATE_RELEASES} | grep -o -E -m 1 "https://.+?${TFUPDATE_VERSION}_${TARGETOS}_${TARGETARCH}.tar.gz")" > tfupdate.tgz; \
182+
fi; \
159183
) && tar -xzf tfupdate.tgz tfupdate && rm tfupdate.tgz \
160184
; fi
161185

@@ -164,8 +188,10 @@ RUN . /.env && \
164188
if [ "$HCLEDIT_VERSION" != "false" ]; then \
165189
( \
166190
HCLEDIT_RELEASES="https://api.github.com/repos/minamijoyo/hcledit/releases" && \
167-
[ "$HCLEDIT_VERSION" = "latest" ] && curl -L "$(curl -s ${HCLEDIT_RELEASES}/latest | grep -o -E -m 1 "https://.+?_${TARGETOS}_${TARGETARCH}.tar.gz")" > hcledit.tgz \
168-
|| curl -L "$(curl -s ${HCLEDIT_RELEASES} | grep -o -E -m 1 "https://.+?${HCLEDIT_VERSION}_${TARGETOS}_${TARGETARCH}.tar.gz")" > hcledit.tgz \
191+
if [ "$HCLEDIT_VERSION" = "latest" ]; \
192+
then curl -L "$(curl -s ${HCLEDIT_RELEASES}/latest | grep -o -E -m 1 "https://.+?_${TARGETOS}_${TARGETARCH}.tar.gz")" > hcledit.tgz; \
193+
else curl -L "$(curl -s ${HCLEDIT_RELEASES} | grep -o -E -m 1 "https://.+?${HCLEDIT_VERSION}_${TARGETOS}_${TARGETARCH}.tar.gz")" > hcledit.tgz; \
194+
fi; \
169195
) && tar -xzf hcledit.tgz hcledit && rm hcledit.tgz \
170196
; fi
171197

0 commit comments

Comments
 (0)