Closed denismakogon closed 6 years ago
@zootalures I need to check if can push an image manually.
@zootalures i don't have an access to fnproject dockerhub namespace, but had a month or so ago.
this is good btw - works for me with the following Dockerfile:
FROM fnproject/python:3
WORKDIR /function
ADD . /function/
RUN pip3 install --no-cache --no-cache-dir -r requirements.txt &&\
rm -fr ~/.cache/pip /tmp* requirements.txt func.yaml Dockerfile .venv
ENTRYPOINT ["python3", "func.py"]
I know you looked at this before but the fn image are still ~300MB net because of the GCC deps mostly by the looks of things - any chance we could get closer to doing 2-stage python builds?
@zootalures, as far as I know, it's not a quite trivial to copy python compiled dependencies and it might end up having a broken build. By saying "might" I mean python dependencies can go wherever on the file system not only site-, dist-packages. So, bringing python multistage builds can be an unstable experimental thing, but not something recommended and ready for use.
we still need to remove build packages as it was introduced in recent CLI PR to shrink an image.
I got python build images working as follows:
FROM fnproject/python:3 as build # sub for build image
WORKDIR /function
ADD . /function/
RUN pip3 install --target /python/ --no-cache --no-cache-dir -r requirements.txt &&\
rm -fr ~/.cache/pip /tmp* requirements.txt func.yaml Dockerfile .venv
FROM python:3.6-slim-stretch # Sub for runtime image
COPY --from=build /function /function
COPY --from=build /python /python
ENV PYTHONPATH=/python
WORKDIR /function
ENTRYPOINT ["python3", "func.py"]
The resulting image is 200MB smaller net that currently
Do you know how to rebuild/release these? Not sure that I do