diff --git a/Dockerfile b/Dockerfile index b7d06b7..e2b3305 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,19 @@ FROM python:3.7-alpine3.8 -RUN pip3 install pipenv +WORKDIR / -COPY Pipfile / COPY Pipfile.lock / +COPY pipenv-install.py / + +RUN /pipenv-install.py && \ + rm -fr /usr/local/lib/python3.7/site-packages/pip && \ + rm -fr /usr/local/lib/python3.7/site-packages/setuptools + +FROM python:3.7-alpine3.8 WORKDIR / -RUN pipenv install --system --deploy --ignore-pipfile + +COPY --from=0 /usr/local/lib/python3.7/site-packages /usr/local/lib/python3.7/site-packages COPY kube_resource_report /kube_resource_report diff --git a/pipenv-install.py b/pipenv-install.py new file mode 100755 index 0000000..d790d61 --- /dev/null +++ b/pipenv-install.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 +""" +Helper script for Docker build to install packages from Pipfile.lock without installing Pipenv +""" +import json +import subprocess + +with open("Pipfile.lock") as fd: + data = json.load(fd) + +packages = [] +for k, v in data["default"].items(): + packages.append(k + v["version"]) + +subprocess.run(["pip3", "install"] + packages, check=True)