You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd recommend cleaning up the cache files from apt and pip. tox testing can be performed without additional final image padding by using multistage build mechanisms.
Current Behaviour
Package cache files from apt and pip are creating larger container images. tox also significantly increase in the final container image size as it creates a virtual environment and installs several packages.
Possible Solution
Remove the apt cache files by chaining install and cache remove commands (this is the command found in the docker best practices documentation)
Remove the pip cache by using --no-cache-dir flag when installing with pip.
RUN pip install --no-cache-dir -r requirements.txt
Implement three build stages in the Dockerfile, (e.g. builder, testing, final), label the initial python base image FROM python:<tag> AS builder starting the testing stage using FROM builder AS testing, and starting the final stage using FROM builder AS final, this will still run tests but avoids the unnecessary .tox directory left behind from testing.
FROM openfaas/of-watchdog:0.9.6 AS watchdog
FROM python:3.7-slim-buster AS builder
<snippet>
FROM builder AS tester
ARG TEST_COMMAND=tox
ARG TEST_ENABLED=true
RUN [ "$TEST_ENABLED" = "false" ] && echo "skipping tests" || eval "$TEST_COMMAND"FROM builder AS final
<snippet>
Doing the above reduced the deployed container image size by 28% for the python3-flask-debian template (results will likely vary a depending on additional packages installed). Build time didn't appear to be affected by modifications.
Use faas-cli to build a container image from above Dockerfile.
Use faas-cli to build a container image with an unmodified Dockerfile.
Compare container image sizes.
Context
I'm a graduate student working on a masters capstone comparing performance and cost of cloud native applications running with open sourced software to proprietary solutions from cloud vendors. I'm also working with a company (BioDepot LLC) that uses Docker for packaging their software. I'd like to pass along some helpful tips that I've learned from maintaining container images.
Your Environment
FaaS-CLI version ( Full output from: faas-cli version ):
Uh oh!
There was an error while loading. Please reload this page.
My actions before raising this issue
Expected Behaviour
I'd recommend cleaning up the cache files from apt and pip. tox testing can be performed without additional final image padding by using multistage build mechanisms.
Current Behaviour
Package cache files from apt and pip are creating larger container images. tox also significantly increase in the final container image size as it creates a virtual environment and installs several packages.
Possible Solution
RUN apt-get -qy update && \ apt-get -qy install ${ADDITIONAL_PACKAGE} && \ rm -rf /var/lib/apt/lists/*
--no-cache-dir
flag when installing with pip.RUN pip install --no-cache-dir -r requirements.txt
FROM python:<tag> AS builder
starting the testing stage usingFROM builder AS testing
, and starting the final stage usingFROM builder AS final
, this will still run tests but avoids the unnecessary .tox directory left behind from testing.Doing the above reduced the deployed container image size by 28% for the python3-flask-debian template (results will likely vary a depending on additional packages installed). Build time didn't appear to be affected by modifications.
Steps to Reproduce (for bugs)
Context
I'm a graduate student working on a masters capstone comparing performance and cost of cloud native applications running with open sourced software to proprietary solutions from cloud vendors. I'm also working with a company (BioDepot LLC) that uses Docker for packaging their software. I'd like to pass along some helpful tips that I've learned from maintaining container images.
Your Environment
faas-cli version
):docker version
(e.g. Docker 17.0.05 ):Are you using Docker Swarm or Kubernetes (FaaS-netes)?
Kubernetes
Operating System and version (e.g. Linux, Windows, MacOS):
Code example or link to GitHub repo or gist to reproduce problem:
https://gist.github.com/rgschmitz1/3c1536b455da3703fb75d9672d556d02
Other diagnostic information / logs from troubleshooting guide
The text was updated successfully, but these errors were encountered: