Skip to content

insightfulsystems/alpine-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alpine-python (now in amd64, arm32v6 and arm32v7 flavors)

Docker Stars Docker Pulls Build Status

A small Python Docker image based on Alpine Linux, inspired by jfloff's original work but updated for Python 3.6/2.7 and 2019 builds of Alpine. The Python 3 image is only 285 MB and includes python3-dev, and all images include support for manylinux wheels (where possible)

Supported tags

The images are now multi-architecture, so:

  • insighful/python and insightful/python:onbuild should "just work" (and default to providing Python 3.6)

However, there are specific tags for runtime version, architecture and build step, like so:

  • 3.6-amd64

  • 3.6-amd64-onbuild

  • 3.6-arm32v6

  • 3.6-arm32v6-onbuild

  • 3.6-arm32v7

  • 3.6-arm32v7-onbuild

  • 2.7-amd64

  • 2.7-amd64-onbuild

  • 2.7-arm32v6

  • 2.7-arm32v6-onbuild

  • 2.7-arm32v7

  • 2.7-arm32v7-onbuild

NOTE: onbuild images install the requirements.txt of your project from the get go. This allows you to cache your requirements right in the build. Make sure you are in the same directory of your requirements.txt file.

Why?

Well, first off, because I needed an easy way to run and deploy a Linux build of Python 3.5, which, given the current state of affairs in Python land, is not yet my go to version and hence only occasionally useful for me. The original builds by jfloff had everything needed for the most common Python projects - including python3-dev (which is not common in most minimal alpine Python packages), plus the great -onbuild variants, which made it a lot easier to build ready-to-deploy apps, so it was perfect for getting 3.6+ going without disrupting my existing environments.

The default docker Python images are too big, much larger than they need to be. Alpine-based images are just way smaller and faster to deploy:

REPOSITORY                TAG           VIRTUAL SIZE
insightful/alpine-python   3.6-onbuild   285 MB
insightful/alpine-python   3.6           285 MB
insightful/alpine-python   2.7-onbuild   280 MB
insightful/alpine-python   2.7           280 MB
jfloff/alpine-python       3.4           225.7 MB
python                     3.4           685.5 MB
python                     3.4-slim      215.1 MB

We actually get around the same size as python:3.4-slim but with python3-dev installed (that's around 55MB).

Usage

This image runs python command on docker run. You can either specify your own command, e.g:

docker run --rm -ti insightful/alpine-python python hello.py

Or extend this image using your custom Dockerfile, e.g:

FROM insightful/alpine-python:onbuild

# for a flask server
EXPOSE 5000
CMD python manage.py runserver

Dont' forget to build your image:

docker build --rm=true -t insightful/app .

You can also access bash inside the container:

docker run --rm -ti insightful/alpine-python /bin/bash

Another option is to build an extended Dockerfile version (like shown above), and mount your application inside the container:

docker run --rm -v "$(pwd)":/home/app -w /home/app -p 5000:5000 -ti insightful/app

Details

  • Installs python-dev allowing the use of more advanced packages such as gevent
  • Installs bash allowing interaction with the container
  • Just like the main python docker image, it creates useful symlinks that are expected to exist, e.g. python3.6 > python, pip2.7 > pip, etc.)
  • Added testing repository to Alpine's /etc/apk/repositories file
  • pip is upgraded in all cases.

License

The code in this repository, unless otherwise noted, is MIT licensed. See the LICENSE file in this repository.

Credits

Again, as outlined above, this is based on jfloff's work, with minor tweaks and updates.

About

Python images for amd64, arm32v6 and arm32v7 based on Alpine Linux (3.6, 2.7)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published