{"id":231,"date":"2019-02-24T20:37:55","date_gmt":"2019-02-24T20:37:55","guid":{"rendered":"https:\/\/chkr.at\/wordpress\/?p=231"},"modified":"2019-02-24T20:37:56","modified_gmt":"2019-02-24T20:37:56","slug":"container-size-matters-optimize-the-size-of-your-python-django-containers","status":"publish","type":"post","link":"https:\/\/chkr.at\/wordpress\/?p=231","title":{"rendered":"Container size matters &#8211; Optimize the size of your Python\/Django Containers"},"content":{"rendered":"\n<p>In one of my recent videos I've disussed the size of the Django\/Python Docker Containers and how to decrease it:<\/p>\n\n\n\n<figure class=\"wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"video-wrapper\"><figure class=\"video-container\"><iframe loading=\"lazy\" width=\"625\" height=\"352\" src=\"https:\/\/www.youtube.com\/embed\/Ex3B8FU6uxc?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe><\/figure><\/div>\n<\/div><\/figure>\n\n\n\n<p>I failed to successfully create an image based on alpine, which is known to be very slim. With the help of Aaron Goodrich, who posted a comment with a Dockerfile for alpine, I was able to finally create such an image \ud83d\ude42 Thanks for the help!<\/p>\n\n\n\n<p>Without further ado, here are the results (and the respective Dockerfiles).<\/p>\n\n\n\n<p>Please note that I have slightly changed the Dockerfile compared to the video above.<\/p>\n\n\n\n<p>Based on Python 3.5 Jessie: 740 MB<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FROM python:3.5-jessie\n\nCOPY .\/app \/app\nWORKDIR \/app\n\nRUN pip install --no-cache-dir -r requirements\/dev.txt<\/code><\/pre>\n\n\n\n<p>Based on Python 3.5 Slim: 188 MB<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FROM python:3.5-slim\n\nCOPY .\/app \/app\nWORKDIR \/app\n\nRUN pip install --no-cache-dir -r requirements\/dev.txt\n<\/code><\/pre>\n\n\n\n<p>Based on Python 3.5 with Alpine: 248 MB<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FROM python:3.5-alpine\n\nCOPY .\/app \/app\nWORKDIR \/app\n\nRUN apk add --update --no-cache postgresql-client &amp;&amp; \\\n    apk add --update --no-cache --virtual .temp-build-deps gcc libc-dev linux-headers postgresql-dev\n\nRUN pip install --no-cache-dir -r requirements\/dev.txt\n\nRUN apk del .temp-build-deps gcc libc-dev linux-headers postgresql-dev<\/code><\/pre>\n\n\n\n<p> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>In one of my recent videos I've disussed the size of the Django\/Python Docker Containers and how to decrease it: I failed to successfully create an image based on alpine, which is known to be very slim. With the help of Aaron Goodrich, who posted a comment with a Dockerfile for alpine, I was able <a class=\"read-more\" href=\"https:\/\/chkr.at\/wordpress\/?p=231\">...continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/chkr.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/231"}],"collection":[{"href":"https:\/\/chkr.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chkr.at\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chkr.at\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chkr.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=231"}],"version-history":[{"count":1,"href":"https:\/\/chkr.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/231\/revisions"}],"predecessor-version":[{"id":232,"href":"https:\/\/chkr.at\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/231\/revisions\/232"}],"wp:attachment":[{"href":"https:\/\/chkr.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chkr.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chkr.at\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}