Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed docker build #288

Merged
merged 2 commits into from
Dec 6, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ WORKDIR /bin_dir
RUN apk add --no-cache \
# Builder deps
curl \
gcc \
musl-dev \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gcc is required to build pycares which is what checkov depends on, so we only need it when checkov (or INSTALL_ALL) is enabled and we definitely not need it to be dangling in the image once pycares is installed (while here I also added PYTHONUNBUFFERED to make python output to be not buffered which is what seems to be a recommended thing for Docker images — since it's not the scope of this PR, please feel free to drop it):

diff --git a/Dockerfile b/Dockerfile
index d9141d1..d643404 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,6 +1,8 @@
 ARG TAG=3.9.7-alpine3.14
 FROM python:${TAG} as builder

+ENV PYTHONUNBUFFERED 1
+
 WORKDIR /bin_dir

 RUN apk add --no-cache \
@@ -57,8 +59,10 @@ RUN if [ "$INSTALL_ALL" != "false" ]; then \
 RUN . /.env && \
     if [ "$CHECKOV_VERSION" != "false" ]; then \
     ( \
+        apk add --no-cache gcc libffi-dev musl-dev; \
         [ "$CHECKOV_VERSION" = "latest" ] && pip3 install --no-cache-dir checkov \
-        || pip3 install --no-cache-dir checkov==${CHECKOV_VERSION} \
+        || pip3 install --no-cache-dir checkov==${CHECKOV_VERSION}; \
+        apk del gcc libffi-dev musl-dev \
     ) \
     ; fi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your suggestions make sense. I updated the PR.

unzip && \
# Upgrade pip for be able get latest Checkov
python3 -m pip install --upgrade pip
Expand Down