{"id":13649043,"url":"https://github.com/revsys/optimized-python-docker","last_synced_at":"2025-04-08T00:32:10.209Z","repository":{"id":27203324,"uuid":"112884717","full_name":"revsys/optimized-python-docker","owner":"revsys","description":"Optimized Python 3.x images for Docker","archived":false,"fork":false,"pushed_at":"2022-12-19T18:20:27.000Z","size":9781,"stargazers_count":113,"open_issues_count":0,"forks_count":9,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-17T11:05:10.556Z","etag":null,"topics":["docker","docker-image","dockerfile","optimized","python","python3"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/revolutionsystems/python/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/revsys.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-02T23:18:51.000Z","updated_at":"2025-02-14T09:24:36.000Z","dependencies_parsed_at":"2023-01-14T09:15:19.390Z","dependency_job_id":null,"html_url":"https://github.com/revsys/optimized-python-docker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revsys%2Foptimized-python-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revsys%2Foptimized-python-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revsys%2Foptimized-python-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/revsys%2Foptimized-python-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/revsys","download_url":"https://codeload.github.com/revsys/optimized-python-docker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247755440,"owners_count":20990617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-image","dockerfile","optimized","python","python3"],"created_at":"2024-08-02T01:04:43.590Z","updated_at":"2025-04-08T00:32:05.198Z","avatar_url":"https://github.com/revsys.png","language":"Shell","readme":"\n# RevSys Python Builds\n\n## What’s wrong with stock Python images? \n\nThe main image variety is too big when the user is operating in a context\nthat involves multiple private registries.\n\nIt’s base layer is an Ubuntu image (with a few exceptions, this\nprovides an as-installed-by-Ubuntu environment) which is, essentially, what\none gets with a base minimal install of Ubuntu 16.04.\n\nThe [alpine](https://alpinelinux.org/) images are delightfully wee. But, alas,\n[musl](https://www.musl-libc.org/). It is awesome. I mean, it *exists*. If you\ndon’t have build problems with your modules that have a C or C++ component,\nuse it. It is small, fast and well vetted.\n\n**Note**: There are workarounds for *some* of the more common non-pure-python\nmodule build failures but usually involve much shenaniganry that I have neither the time\nnor inclination to pursue.\n\nThe **slim** images are similar to the ubuntu images. Rather than an Ubuntu base\nimage, they use a Debian 8 base.\n\n| REPOSITORY                                      | TAG                     | SIZE  |\n| -----------                                     | ----------------------  | ----- |\n| python                                          | 3.6.3                   | 690MB |\n| python                                          | 3.6-slim                | 201MB |\n| python                                          | 3.6.3-alpine            | 89MB  |\n| registry.gitlab.com/revsys/docker-builds/python | 3.6.3-wee               | 153MB |\n\nWe settled on a Debian 8 image provided by google’s GCE service. It is smaller\nby way of excluding systemd-related bits while building the initial bootstrap\nchroot.\n\nThe resulting images are smaller than -slim but larger than alpine.\n\n## Optimized Python images\n\nThree builds are available per Python version:\n\n * :wee - stock build without compile or link-time optimizations enabled\n * :wee-optimized - build with profile-guided optimization flag\n * :wee-optimized-lto - build with PGO + Link-Time-Optimization flags\n\n\n| REPOSITORY                                      | TAG                     | SIZE  |\n| -----------                                     | ----------------------  | ----- |\n| revolutionsystems/python | 3.5.3-wee-optimized-lto | 164MB |\n| revolutionsystems/python | 3.5.3-wee-optimized | 164MB |\n| revolutionsystems/python | 3.5.3-wee | 158MB |\n\n## Building\n\nThe registry is included from \u003cgitroot\u003e/.versions\n\nmake targets:\n\n * build-image: docker build...\n * push-image: docker push ...\n * image: runs build-image then push-image\n\n### stock build\n\n```\n\n:# LTO= OPTIMAL= PYTHON_VERSION=3.5.3 make image\n\n```\n\n### PGO optimizations\n\n```\n\n:# LTO= OPTIMAL=1 PYTHON_VERSION=3.5.1 make image\n\n```\n\n### LTO Optimizations\n\n```\n\n:# LTO=1 OPTIMAL=1 PYTHON_VERSION=3.6.3 make image\n\n```\n\n### Python 2 builds\n\nThe build arguments have stayed fairly consistent at least since Python 2.6.\nThe build will not fail if the Python 3-specific environment variables remain\nset; however, the image will get a misleading tag.  For Python 2 builds, use:\n\n```\n\n:# LTO= OPTIMAL= PYTHON_VERSION=2.7.13 make image\n\n```\n\n## Build Optimization\n\nBuild times are radically reduced by using a local proxy. You can find an \nexample squid 3/4 configuration in ./examples.\n\nAfter setting the `cache_dir` path the command, `squid -f /path/to/config -N -z`\nto initialize the cache filesystem storage.\n\nTo kick off the cache service: `squid -f /path/to/config -N -a 3128`.\n\nOnce the proxy is running, set the environment variable `export PKG_PROXY=http://10.129.1.1:3128`.\nDocker transparently passes the `HTTP_PROXY` and `HTTPS_PROXY` environment variables\ninto each build container if they are configured with the `--build-args` flag.\n\nThe transparency is significant in that whether or not your build is leveraging\na proxy will not affect the validity of the build host’s cache.\n\n\n## Origin Notes\n\nBased in large part on the contents of [the Docker Library Python repository](https://github.com/docker-library/python).\n\n---\n\n 1. uses [GNU make](https://www.gnu.org/software/make/) and environment variables to set options\n    1. `LTO`: if present and not empty, activate link-time-optimization functionality\n    1. `OPTIMAL`: if present and not empty, activate profiler-guided-optimization functionality\n    1. `PYTHON_VERSION’: e.g.: 3.6.3, 3.5.1\n 1. Does not include [TCL/TK](https://www.tcl.tk/about/uses.html). This is on purpose. If you neeed IDLE or\n    pexpect you’ll need to customize the Dockerfile and rebuild.\n 1. Uses multi-layer Dockerfile syntax\n\n---\n\nKeep in touch!\n--------------\n\nIf you have a question about this project, please open a GitHub issue. If you love us and want to keep track of our goings-on, here's where you can find us online:\n\n\u003ca href=\"https://revsys.com?utm_medium=github\u0026utm_source=optimized-python-docker\"\u003e\u003cimg src=\"https://pbs.twimg.com/profile_images/915928618840285185/sUdRGIn1_400x400.jpg\" height=\"50\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://twitter.com/revsys\"\u003e\u003cimg src=\"https://cdn1.iconfinder.com/data/icons/new_twitter_icon/256/bird_twitter_new_simple.png\" height=\"43\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.facebook.com/revsysllc/\"\u003e\u003cimg src=\"https://cdn3.iconfinder.com/data/icons/picons-social/57/06-facebook-512.png\" height=\"50\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/revsys/\"\u003e\u003cimg src=\"https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png\" height=\"53\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://gitlab.com/revsys\"\u003e\u003cimg src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/1/18/GitLab_Logo.svg/2000px-GitLab_Logo.svg.png\" height=\"44\" /\u003e\u003c/a\u003e\n\n","funding_links":[],"categories":["Shell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevsys%2Foptimized-python-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frevsys%2Foptimized-python-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frevsys%2Foptimized-python-docker/lists"}