Coder Social home page Coder Social logo

montana / alpine-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from insightfulsystems/alpine-python

0.0 2.0 0.0 53 KB

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

Home Page: https://hub.docker.com/r/insightful/alpine-python/

License: MIT License

Makefile 53.93% Dockerfile 46.07%

alpine-python's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.