Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
#24 reduce Docker image size
Browse files Browse the repository at this point in the history
  • Loading branch information
hjacobs committed Jul 22, 2018
1 parent 3f1646c commit 2acec5c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
13 changes: 10 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
15 changes: 15 additions & 0 deletions pipenv-install.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 2acec5c

Please sign in to comment.