From 53a4c463a52cbe5b78f387f995f066fab7b98996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Loff?= Date: Fri, 18 Nov 2016 11:56:14 +0000 Subject: [PATCH 01/55] Fix #6. Add missing execution priveleges to entrypoint.sh --- latest/onbuild/entrypoint.sh | 0 latest/slim/entrypoint.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 latest/onbuild/entrypoint.sh mode change 100644 => 100755 latest/slim/entrypoint.sh diff --git a/latest/onbuild/entrypoint.sh b/latest/onbuild/entrypoint.sh old mode 100644 new mode 100755 diff --git a/latest/slim/entrypoint.sh b/latest/slim/entrypoint.sh old mode 100644 new mode 100755 From 596cd48aebd64035dd41e64c04155cd3d3e1da25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Loff?= Date: Fri, 18 Nov 2016 14:31:50 +0000 Subject: [PATCH 02/55] Temporarily remove edge repositories from images. #7 --- 2.7/Dockerfile | 6 +++--- 2.7/slim/Dockerfile | 6 +++--- 3.4/Dockerfile | 6 +++--- 3.4/slim/Dockerfile | 6 +++--- latest/Dockerfile | 6 +++--- latest/slim/Dockerfile | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 30efe5c..1c5c72c 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -36,9 +36,9 @@ RUN echo \ # turn back the clock -- so hacky! && echo "http://dl-cdn.alpinelinux.org/alpine/v3.4/main/" > /etc/apk/repositories \ - && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ - && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ + # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ # make some useful symlinks that are expected to exist && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python2.7 /usr/bin/python; fi \ diff --git a/2.7/slim/Dockerfile b/2.7/slim/Dockerfile index 6d8f27f..35d8be8 100644 --- a/2.7/slim/Dockerfile +++ b/2.7/slim/Dockerfile @@ -26,9 +26,9 @@ RUN echo \ # turn back the clock -- so hacky! && echo "http://dl-cdn.alpinelinux.org/alpine/v3.4/main/" > /etc/apk/repositories \ - && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ - && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ + # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ # make some useful symlinks that are expected to exist && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python2.7 /usr/bin/python; fi \ diff --git a/3.4/Dockerfile b/3.4/Dockerfile index 2cee94f..1165c8e 100644 --- a/3.4/Dockerfile +++ b/3.4/Dockerfile @@ -34,9 +34,9 @@ RUN echo \ # turn back the clock -- so hacky! && echo "http://dl-cdn.alpinelinux.org/alpine/v3.4/main/" > /etc/apk/repositories \ - && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ - && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ + # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ # make some useful symlinks that are expected to exist && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3.4 /usr/bin/python; fi \ diff --git a/3.4/slim/Dockerfile b/3.4/slim/Dockerfile index 17410d3..062d1e6 100644 --- a/3.4/slim/Dockerfile +++ b/3.4/slim/Dockerfile @@ -24,9 +24,9 @@ RUN echo \ # turn back the clock -- so hacky! && echo "http://dl-cdn.alpinelinux.org/alpine/v3.4/main/" > /etc/apk/repositories \ - && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ - && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ + # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ # make some useful symlinks that are expected to exist && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3.4 /usr/bin/python; fi \ diff --git a/latest/Dockerfile b/latest/Dockerfile index 11771ea..6deb234 100644 --- a/latest/Dockerfile +++ b/latest/Dockerfile @@ -34,9 +34,9 @@ RUN echo \ # turn back the clock -- so hacky! && echo "http://dl-cdn.alpinelinux.org/alpine/v3.4/main/" > /etc/apk/repositories \ - && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ - && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ + # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ # make some useful symlinks that are expected to exist && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi \ diff --git a/latest/slim/Dockerfile b/latest/slim/Dockerfile index 52bc1d3..24088af 100644 --- a/latest/slim/Dockerfile +++ b/latest/slim/Dockerfile @@ -24,9 +24,9 @@ RUN echo \ # turn back the clock -- so hacky! && echo "http://dl-cdn.alpinelinux.org/alpine/v3.4/main/" > /etc/apk/repositories \ - && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ - && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ + # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ # make some useful symlinks that are expected to exist && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi \ From 455fc5b1e3efc8805d8740e279e4c3bcb5362926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gottlieb?= Date: Thu, 5 Jan 2017 11:04:59 -0300 Subject: [PATCH 03/55] Update README.md Grammar fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dee2c1a..488963d 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ jfloff/alpine-python latest-slim 79.11 MB python 3.5-slim 197.8 MB ``` -Perhaps this could be even more smaller, but I'm not an Alpine guru. **Feel free to post a PR.** +Perhaps this could be even smaller, but I'm not an Alpine guru. **Feel free to post a PR.** ## Details * Installs `build-base` and `python-dev`, allowing the use of more advanced packages such as `gevent` From 62d465b9610d965e959b5510550cda901685c01c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Loff?= Date: Sun, 26 Mar 2017 19:04:33 +0100 Subject: [PATCH 04/55] Update alpine to 3.5 --- 2.7/Dockerfile | 6 ++++-- 2.7/slim/Dockerfile | 6 ++++-- 3.4/Dockerfile | 6 ++++-- 3.4/slim/Dockerfile | 6 ++++-- latest/Dockerfile | 6 ++++-- latest/slim/Dockerfile | 6 ++++-- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 1c5c72c..c2ad458 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -1,4 +1,6 @@ -FROM alpine:3.4 +FROM alpine:3.5 + +ENV ALPINE_VERSION=3.5 # Install needed packages. Notes: # * dumb-init: a proper init system for containers, to reap zombie children @@ -35,7 +37,7 @@ RUN echo \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ # turn back the clock -- so hacky! - && echo "http://dl-cdn.alpinelinux.org/alpine/v3.4/main/" > /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ diff --git a/2.7/slim/Dockerfile b/2.7/slim/Dockerfile index 35d8be8..f930018 100644 --- a/2.7/slim/Dockerfile +++ b/2.7/slim/Dockerfile @@ -1,4 +1,6 @@ -FROM alpine:3.4 +FROM alpine:3.5 + +ENV ALPINE_VERSION=3.5 # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children @@ -25,7 +27,7 @@ RUN echo \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ # turn back the clock -- so hacky! - && echo "http://dl-cdn.alpinelinux.org/alpine/v3.4/main/" > /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ diff --git a/3.4/Dockerfile b/3.4/Dockerfile index 1165c8e..71be89f 100644 --- a/3.4/Dockerfile +++ b/3.4/Dockerfile @@ -1,4 +1,6 @@ -FROM alpine:3.4 +FROM alpine:3.5 + +ENV ALPINE_VERSION=3.5 # Install needed packages. Notes: # * dumb-init: a proper init system for containers, to reap zombie children @@ -33,7 +35,7 @@ RUN echo \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ # turn back the clock -- so hacky! - && echo "http://dl-cdn.alpinelinux.org/alpine/v3.4/main/" > /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ diff --git a/3.4/slim/Dockerfile b/3.4/slim/Dockerfile index 062d1e6..c6936d3 100644 --- a/3.4/slim/Dockerfile +++ b/3.4/slim/Dockerfile @@ -1,4 +1,6 @@ -FROM alpine:3.4 +FROM alpine:3.5 + +ENV ALPINE_VERSION=3.5 # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children @@ -23,7 +25,7 @@ RUN echo \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ # turn back the clock -- so hacky! - && echo "http://dl-cdn.alpinelinux.org/alpine/v3.4/main/" > /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ diff --git a/latest/Dockerfile b/latest/Dockerfile index 6deb234..a3a349a 100644 --- a/latest/Dockerfile +++ b/latest/Dockerfile @@ -1,4 +1,6 @@ -FROM alpine:3.4 +FROM alpine:3.5 + +ENV ALPINE_VERSION=3.5 # Install needed packages. Notes: # * dumb-init: a proper init system for containers, to reap zombie children @@ -33,7 +35,7 @@ RUN echo \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ # turn back the clock -- so hacky! - && echo "http://dl-cdn.alpinelinux.org/alpine/v3.4/main/" > /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ diff --git a/latest/slim/Dockerfile b/latest/slim/Dockerfile index 24088af..c5b0f24 100644 --- a/latest/slim/Dockerfile +++ b/latest/slim/Dockerfile @@ -1,4 +1,6 @@ -FROM alpine:3.4 +FROM alpine:3.5 + +ENV ALPINE_VERSION=3.5 # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children @@ -23,7 +25,7 @@ RUN echo \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ # turn back the clock -- so hacky! - && echo "http://dl-cdn.alpinelinux.org/alpine/v3.4/main/" > /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ From cc7166b66168cd3306660d566100a0200f184643 Mon Sep 17 00:00:00 2001 From: Bruno Galindro da Costa Date: Tue, 30 May 2017 18:45:10 -0300 Subject: [PATCH 05/55] Update do Alpine v3.6 --- 2.7/Dockerfile | 4 ++-- 2.7/slim/Dockerfile | 4 ++-- 3.4/Dockerfile | 4 ++-- 3.4/slim/Dockerfile | 4 ++-- latest/Dockerfile | 4 ++-- latest/slim/Dockerfile | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/2.7/Dockerfile b/2.7/Dockerfile index c2ad458..1cd9559 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -1,6 +1,6 @@ -FROM alpine:3.5 +FROM alpine:3.6 -ENV ALPINE_VERSION=3.5 +ENV ALPINE_VERSION=3.6 # Install needed packages. Notes: # * dumb-init: a proper init system for containers, to reap zombie children diff --git a/2.7/slim/Dockerfile b/2.7/slim/Dockerfile index f930018..ba6060c 100644 --- a/2.7/slim/Dockerfile +++ b/2.7/slim/Dockerfile @@ -1,6 +1,6 @@ -FROM alpine:3.5 +FROM alpine:3.6 -ENV ALPINE_VERSION=3.5 +ENV ALPINE_VERSION=3.6 # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children diff --git a/3.4/Dockerfile b/3.4/Dockerfile index 71be89f..944cccd 100644 --- a/3.4/Dockerfile +++ b/3.4/Dockerfile @@ -1,6 +1,6 @@ -FROM alpine:3.5 +FROM alpine:3.6 -ENV ALPINE_VERSION=3.5 +ENV ALPINE_VERSION=3.6 # Install needed packages. Notes: # * dumb-init: a proper init system for containers, to reap zombie children diff --git a/3.4/slim/Dockerfile b/3.4/slim/Dockerfile index c6936d3..b6d090d 100644 --- a/3.4/slim/Dockerfile +++ b/3.4/slim/Dockerfile @@ -1,6 +1,6 @@ -FROM alpine:3.5 +FROM alpine:3.6 -ENV ALPINE_VERSION=3.5 +ENV ALPINE_VERSION=3.6 # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children diff --git a/latest/Dockerfile b/latest/Dockerfile index a3a349a..a96d3ab 100644 --- a/latest/Dockerfile +++ b/latest/Dockerfile @@ -1,6 +1,6 @@ -FROM alpine:3.5 +FROM alpine:3.6 -ENV ALPINE_VERSION=3.5 +ENV ALPINE_VERSION=3.6 # Install needed packages. Notes: # * dumb-init: a proper init system for containers, to reap zombie children diff --git a/latest/slim/Dockerfile b/latest/slim/Dockerfile index c5b0f24..f1fd6a7 100644 --- a/latest/slim/Dockerfile +++ b/latest/slim/Dockerfile @@ -1,6 +1,6 @@ -FROM alpine:3.5 +FROM alpine:3.6 -ENV ALPINE_VERSION=3.5 +ENV ALPINE_VERSION=3.6 # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children From 2b781d6dcf21c21c4bb77eba2416754e85e3567e Mon Sep 17 00:00:00 2001 From: Trevor Robinson Date: Wed, 20 Dec 2017 14:11:59 -0800 Subject: [PATCH 06/55] Update Alpine. Include Travis. Rework build proc. This commit is slightly confused because of the absence of the latest tag. It thinks I deleted some files I didn't, and renamed some files I didn't, because of their identical content. Alpine was updated to 3.7 to help fix some inconsistencies in the repositories. Also, README updated with newer sizes. --- .travis.yml | 32 +++++++ .travis/main.sh | 61 ++++++++++++ .travis/push.sh | 33 +++++++ {2.7/onbuild => 2.7-onbuild}/Dockerfile | 0 {2.7/onbuild => 2.7-onbuild}/entrypoint.sh | 0 {2.7/slim => 2.7-slim}/Dockerfile | 4 +- {2.7/slim => 2.7-slim}/entrypoint.sh | 0 2.7/Dockerfile | 4 +- {3.4/onbuild => 3.4-onbuild}/Dockerfile | 0 {3.4/onbuild => 3.4-onbuild}/entrypoint.sh | 0 {3.4/slim => 3.4-slim}/Dockerfile | 4 +- {3.4/slim => 3.4-slim}/entrypoint.sh | 0 3.4/Dockerfile | 4 +- README.md | 73 +++++++-------- build-all.sh | 26 +++--- latest/Dockerfile | 57 ------------ latest/onbuild/Dockerfile | 13 --- latest/onbuild/entrypoint.sh | 103 --------------------- latest/slim/Dockerfile | 65 ------------- latest/slim/entrypoint.sh | 103 --------------------- 20 files changed, 180 insertions(+), 402 deletions(-) create mode 100644 .travis.yml create mode 100755 .travis/main.sh create mode 100755 .travis/push.sh rename {2.7/onbuild => 2.7-onbuild}/Dockerfile (100%) rename {2.7/onbuild => 2.7-onbuild}/entrypoint.sh (100%) rename {2.7/slim => 2.7-slim}/Dockerfile (98%) rename {2.7/slim => 2.7-slim}/entrypoint.sh (100%) rename {3.4/onbuild => 3.4-onbuild}/Dockerfile (100%) rename {3.4/onbuild => 3.4-onbuild}/entrypoint.sh (100%) rename {3.4/slim => 3.4-slim}/Dockerfile (98%) rename {3.4/slim => 3.4-slim}/entrypoint.sh (100%) delete mode 100644 latest/Dockerfile delete mode 100644 latest/onbuild/Dockerfile delete mode 100755 latest/onbuild/entrypoint.sh delete mode 100644 latest/slim/Dockerfile delete mode 100755 latest/slim/entrypoint.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..43ab2ad --- /dev/null +++ b/.travis.yml @@ -0,0 +1,32 @@ +sudo: required +services: + - docker + +matrix: + fast_finish: true + +before_install: + - bash ./.travis/main.sh + +env: + global: + - alpine_image='alpine:3.6' + - latest='3.4' + - repo='jfloff/alpine-python' + matrix: + - version='2.7' type='' + - version='2.7' type='-onbuild' + - version='2.7' type='-slim' + - version='3.4' type='' + - version='3.4' type='-onbuild' + - version='3.4' type='-slim' + +before_script: + - sudo docker pull $alpine_image + +script: + - sudo docker build -t $repo:$version$type $version$type + - echo 'print("Success")' | sudo docker run -i --rm $repo:$version$type + +after_success: + - bash ./.travis/push.sh diff --git a/.travis/main.sh b/.travis/main.sh new file mode 100755 index 0000000..afb52e0 --- /dev/null +++ b/.travis/main.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +# Set an option to exit immediately if any error appears +set -o errexit + +# Main function that describes the behavior of the +# script. +# By making it a function we can place our methods +# below and have the main execution described in a +# concise way via function invocations. +main() { + setup_dependencies + update_docker_configuration + + echo "SUCCESS: + Done! Finished setting up Travis machine. + " +} + +# Prepare the dependencies that the machine need. +# Here I'm just updating the apt references and then +# installing both python and python-pip. This allows +# us to make use of `pip` to fetch the latest `docker-compose` +# later. +# We also upgrade `docker-ce` so that we can get the +# latest docker version which allows us to perform +# image squashing as well as multi-stage builds. +setup_dependencies() { + echo "INFO: + Setting up dependencies. + " + + sudo apt update -y --allow-unauthenticated + # sudo apt install realpath python python-pip -y + sudo apt install --only-upgrade docker-ce -y + + # sudo pip install docker-compose || true + + docker info + # docker-compose --version +} + +# Tweak the daemon configuration so that we +# can make use of experimental features (like image +# squashing) as well as have a bigger amount of +# concurrent downloads and uploads. +update_docker_configuration() { + echo "INFO: + Updating docker configuration + " + + echo '{ + "experimental": true, + "storage-driver": "overlay2", + "max-concurrent-downloads": 50, + "max-concurrent-uploads": 50 +}' | sudo tee /etc/docker/daemon.json + sudo service docker restart +} + +main diff --git a/.travis/push.sh b/.travis/push.sh new file mode 100755 index 0000000..d9de0e8 --- /dev/null +++ b/.travis/push.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -o errexit + +PUSH=1 + + +if [[ "$TRAVIS_BRANCH" == "master" ]]; then + if [[ -z "$DOCKER_USERNAME" || -z "$DOCKER_PASSWORD" ]]; then + echo "Skipping Docker push, no credentials specified." + PUSH=0 + else + sudo docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD ; + fi + + if [[ "$PUSH" -eq 1 ]]; then + echo "Pushing $repo:$version$type" + sudo docker push $repo:$version$type + else + echo "Would have pushed as $repo:$version$type" + fi + + if [[ "$latest" == "$version" ]]; then + if [[ "$PUSH" -eq 1 ]]; then + echo "Pushing this one as latest$type!" + sudo docker tag $repo:$version$type $repo:latest$type + sudo docker push $repo:latest$type + else + echo "Would have pushed as $repo:latest$type" + fi + fi + + fi +fi diff --git a/2.7/onbuild/Dockerfile b/2.7-onbuild/Dockerfile similarity index 100% rename from 2.7/onbuild/Dockerfile rename to 2.7-onbuild/Dockerfile diff --git a/2.7/onbuild/entrypoint.sh b/2.7-onbuild/entrypoint.sh similarity index 100% rename from 2.7/onbuild/entrypoint.sh rename to 2.7-onbuild/entrypoint.sh diff --git a/2.7/slim/Dockerfile b/2.7-slim/Dockerfile similarity index 98% rename from 2.7/slim/Dockerfile rename to 2.7-slim/Dockerfile index ba6060c..391a1e8 100644 --- a/2.7/slim/Dockerfile +++ b/2.7-slim/Dockerfile @@ -1,6 +1,6 @@ -FROM alpine:3.6 +FROM alpine:3.7 -ENV ALPINE_VERSION=3.6 +ENV ALPINE_VERSION=3.7 # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children diff --git a/2.7/slim/entrypoint.sh b/2.7-slim/entrypoint.sh similarity index 100% rename from 2.7/slim/entrypoint.sh rename to 2.7-slim/entrypoint.sh diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 1cd9559..a6b71ea 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -1,6 +1,6 @@ -FROM alpine:3.6 +FROM alpine:3.7 -ENV ALPINE_VERSION=3.6 +ENV ALPINE_VERSION=3.7 # Install needed packages. Notes: # * dumb-init: a proper init system for containers, to reap zombie children diff --git a/3.4/onbuild/Dockerfile b/3.4-onbuild/Dockerfile similarity index 100% rename from 3.4/onbuild/Dockerfile rename to 3.4-onbuild/Dockerfile diff --git a/3.4/onbuild/entrypoint.sh b/3.4-onbuild/entrypoint.sh similarity index 100% rename from 3.4/onbuild/entrypoint.sh rename to 3.4-onbuild/entrypoint.sh diff --git a/3.4/slim/Dockerfile b/3.4-slim/Dockerfile similarity index 98% rename from 3.4/slim/Dockerfile rename to 3.4-slim/Dockerfile index b6d090d..2d784fb 100644 --- a/3.4/slim/Dockerfile +++ b/3.4-slim/Dockerfile @@ -1,6 +1,6 @@ -FROM alpine:3.6 +FROM alpine:3.7 -ENV ALPINE_VERSION=3.6 +ENV ALPINE_VERSION=3.7 # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children diff --git a/3.4/slim/entrypoint.sh b/3.4-slim/entrypoint.sh similarity index 100% rename from 3.4/slim/entrypoint.sh rename to 3.4-slim/entrypoint.sh diff --git a/3.4/Dockerfile b/3.4/Dockerfile index 944cccd..16cb205 100644 --- a/3.4/Dockerfile +++ b/3.4/Dockerfile @@ -1,6 +1,6 @@ -FROM alpine:3.6 +FROM alpine:3.7 -ENV ALPINE_VERSION=3.6 +ENV ALPINE_VERSION=3.7 # Install needed packages. Notes: # * dumb-init: a proper init system for containers, to reap zombie children diff --git a/README.md b/README.md index 488963d..56c2729 100644 --- a/README.md +++ b/README.md @@ -9,18 +9,18 @@ A small Python Docker image based on [Alpine Linux](http://alpinelinux.org/). -- [Supported tags](#supported-tags) -- [Why?](#why) -- [Details](#details) -- [Usage](#usage) -- [Usage of onbuild images](#usage-of-onbuild-images) -- [Usage of slim images](#usage-of-slim-images) - - [Via `docker run`](#via-docker-run) - - [Pip Dependencies](#pip-dependencies) - - [Run-Time Dependencies](#run-time-dependencies) - - [Build-Time Dependencies](#build-time-dependencies) - - [Creating Images](#creating-images) - - [Debugging](#debugging) +- [Supported tags](#supported-tags) +- [Why?](#why) +- [Details](#details) +- [Usage](#usage) +- [Usage of onbuild images](#usage-of-onbuild-images) +- [Usage of slim images](#usage-of-slim-images) + - [Via `docker run`](#via-docker-run) + - [Pip Dependencies](#pip-dependencies) + - [Run-Time Dependencies](#run-time-dependencies) + - [Build-Time Dependencies](#build-time-dependencies) + - [Creating Images](#creating-images) + - [Debugging](#debugging) - [License](#license) - [TODO](#todo) @@ -28,40 +28,37 @@ A small Python Docker image based on [Alpine Linux](http://alpinelinux.org/). ## Supported tags * **`2.7` ([2.7/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/2.7/Dockerfile))** -* **`2.7-onbuild` ([2.7/onbuild/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/2.7/onbuild/Dockerfile))** -* **`2.7-slim` ([2.7/slim/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/2.7/slim/Dockerfile))** +* **`2.7-onbuild` ([2.7-onbuild/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/2.7-onbuild/Dockerfile))** +* **`2.7-slim` ([2.7-slim/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/2.7-slim/Dockerfile))** * **`3.4` ([3.4/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4/Dockerfile))** -* **`3.4-onbuild` ([3.4/onbuild/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4/onbuild/Dockerfile))** -* **`3.4-slim` ([3.4/slim/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4/slim/Dockerfile))** +* **`3.4-onbuild` ([3.4-onbuild/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-onbuild/Dockerfile))** +* **`3.4-slim` ([3.4-slim/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-slim/Dockerfile))** * **`latest` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4/Dockerfile))** -* **`latest-onbuild` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4/onbuild/Dockerfile))** -* **`latest-slim` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4/slim/Dockerfile))** +* **`latest-onbuild` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-onbuild/Dockerfile))** +* **`latest-slim` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-slim/Dockerfile))** **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? The default docker python images are too [big](https://github.com/docker-library/python/issues/45), much larger than they need to be. Hence I built this simple image based on [docker-alpine](https://github.com/gliderlabs/docker-alpine), that has everything needed for the most common python projects - including `python3-dev` (which is not common in most minimal alpine python packages). -``` -REPOSITORY TAG SIZE -jfloff/alpine-python 2.7-slim 52.86 MB -python 2.7-slim 180.8 MB - -jfloff/alpine-python 2.7 234.2 MB -python 2.7 676.2 MB - -jfloff/alpine-python 3.4-slim 110.4 MB -python 3.4-slim 193.9 MB - -jfloff/alpine-python 3.4 280 MB -python 3.4 681.5 MB - -jfloff/alpine-python latest 248.8 MB -python 3.5 685.4 MB - -jfloff/alpine-python latest-slim 79.11 MB -python 3.5-slim 197.8 MB -``` +|REPOSITORY|TAG|SIZE| +|-|-|-| +|jfloff/alpine-python|3.4-slim|69.8MB| +|jfloff/alpine-python|3.4-onbuild|234MB| +|jfloff/alpine-python|3.4|234MB| +|jfloff/alpine-python|2.7-slim|56.7MB| +|jfloff/alpine-python|2.7-onbuild|229MB| +|jfloff/alpine-python|2.7|230MB| +|||| +|python|3.4-slim|151MB| +|python|3.4-onbuild|687MB| +|python|3.4-alpine|85.5MB| +|python|3.4|687MB| +|python|2.7-slim|138MB| +|python|2.7-onbuild|681MB| +|python|2.7-alpine|75.3MB| +|python|2.7|681MB| Perhaps this could be even smaller, but I'm not an Alpine guru. **Feel free to post a PR.** diff --git a/build-all.sh b/build-all.sh index aacc582..bccb042 100755 --- a/build-all.sh +++ b/build-all.sh @@ -10,11 +10,17 @@ build_with_status () { echo -n "Building $tag:" docker build . -t $tag &> /dev/null - if [[ $? -eq 0 ]]; then - echo "$bold$green GOOD$reset" - else - echo "$bold$red BAD$reset" + if [[ $? -ne 0 ]]; then + echo "$bold$red BUILD FAILED$reset" + exit 1 + fi + + echo 'print("something")' | docker run --rm -i $tag &> /dev/null + if [[ $? -ne 0 ]]; then + echo "$bold$red TEST FAILED$reset" exit 1 + else + echo "$bold$green SUCCESS$reset" fi } @@ -27,18 +33,8 @@ HERE="$(dirname $(readlink -f $0 || realpath $0))" cd $HERE # Find all the top-level dirs -for version in $(find -maxdepth 1 -not -name '.*' -type d -printf '%P\n'); do +for version in $(find -maxdepth 1 -not -name '.*' -type d -printf '%P\n' | sort); do pushd $version - - # Build the flat version build_with_status $repo:$version - - # Build any sub-versions - for subtype in $(find -maxdepth 1 -not -name '.*' -type d -printf '%P\n'); do - pushd $subtype - build_with_status $repo:$version-$subtype - popd - done - popd done diff --git a/latest/Dockerfile b/latest/Dockerfile deleted file mode 100644 index a96d3ab..0000000 --- a/latest/Dockerfile +++ /dev/null @@ -1,57 +0,0 @@ -FROM alpine:3.6 - -ENV ALPINE_VERSION=3.6 - -# Install needed packages. Notes: -# * dumb-init: a proper init system for containers, to reap zombie children -# * musl: standard C library -# * linux-headers: commonly needed, and an unusual package name from Alpine. -# * build-base: used so we include the basic development packages (gcc) -# * git: to ease up clones of repos -# * bash: so we can access /bin/bash -# * ca-certificates: for SSL verification during Pip and easy_install -# * python: the binaries themselves -# * python-dev: are used for gevent e.g. -ENV PACKAGES="\ - dumb-init \ - musl \ - linux-headers \ - build-base \ - bash \ - git \ - ca-certificates \ - python3 \ - python3-dev \ -" - -RUN echo \ - # replacing default repositories with edge ones - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ - - # Add the packages, with a CDN-breakage fallback if needed - && apk add --no-cache $PACKAGES || \ - (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ - - # turn back the clock -- so hacky! - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ - # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ - # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ - - # make some useful symlinks that are expected to exist - && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi \ - && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python3-config /usr/bin/python-config; fi \ - && if [[ ! -e /usr/bin/idle ]]; then ln -sf /usr/bin/idle3 /usr/bin/idle; fi \ - && if [[ ! -e /usr/bin/pydoc ]]; then ln -sf /usr/bin/pydoc3 /usr/bin/pydoc; fi \ - && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf /usr/bin/easy_install-3* /usr/bin/easy_install; fi \ - - # Install and upgrade Pip - && easy_install pip \ - && pip install --upgrade pip \ - && if [[ ! -e /usr/bin/pip ]]; then ln -sf /usr/bin/pip3 /usr/bin/pip; fi - -# since we will be "always" mounting the volume, we can set this up -ENTRYPOINT ["/usr/bin/dumb-init"] -CMD ["python"] diff --git a/latest/onbuild/Dockerfile b/latest/onbuild/Dockerfile deleted file mode 100644 index a4ada9a..0000000 --- a/latest/onbuild/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM jfloff/alpine-python:3.4 - -# Copy in the entrypoint script -- this installs prerequisites on container start. -COPY entrypoint.sh /entrypoint.sh - -# install requirements -# this way when you build you won't need to install again -# and since COPY is cached we don't need to wait -ONBUILD COPY requirements.txt /tmp/requirements.txt - -# Run the dependencies installer and then allow it to be run again if needed. -ONBUILD RUN /entrypoint.sh -r /tmp/requirements.txt -ONBUILD RUN rm -f /requirements.installed diff --git a/latest/onbuild/entrypoint.sh b/latest/onbuild/entrypoint.sh deleted file mode 100755 index c8c419c..0000000 --- a/latest/onbuild/entrypoint.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/dumb-init /bin/bash -set -e - -APK_REQUIREMENTS=() -BUILD_REQUIREMENTS=() -PIP_REQUIREMENTS=() -APKFILE='/apk-requirements.txt' -BUILDFILE='/build-requirements.txt' -REQFILE='/requirements.txt' - -function usage () { - echo <<"EOF" -Usage: $0 [-a -b -p -A -B -P -r] [--] - -a : APK requirement. Can be specified multiple times. - -b : APK build requirement. These will be removed at the end to save space. - -p : Pip requirement. Can be specified multiple times. - - -A : apk-requirements.txt file location, default: /apk-requirements.txt - -B : build-requirements.txt file location, default: /build-requirements.txt - -P : requirements.txt file location, default: /requirements.txt - -r : same as above, just to match Pip's -r flag. - - -- : Separator for flags and your command - - Whatever you provide after your arguments is run at the end. -EOF - exit 1 -} - -# Get and process arguments -while getopts ":a:b:p:A:B:P:r:" opt; do - case $opt in - a) APK_REQUIREMENTS+=("$OPTARG") ;; - b) BUILD_REQUIREMENTS+=("$OPTARG") ;; - p) PIP_REQUIREMENTS+=("$OPTARG") ;; - A) APKFILE="$OPTARG" ;; - B) BUILDFILE="$OPTARG" ;; - P) REQFILE="$OPTARG" ;; - r) REQFILE="$OPTARG" ;; - \?) - echo "Invalid option: -$OPTARG" >&2 - usage - ;; - :) - echo "Option -$OPTARG requires an argument." >&2 - usage - ;; - esac -done - -# Bad arguments -if [ $? -ne 0 ]; -then - usage -fi - -# Strip out all the arguments that have been processed -shift $((OPTIND-1)) - -# If there's a double dash at the end, get that off -[[ $1 = "--" ]] && shift - -# Don't do anything if we've already done this. -if [[ ! -f /requirements.installed ]]; then - - # Install any APK requirements - if [[ -f "$APKFILE" ]]; then - APK_REQUIREMENTS+=($( cat "$APKFILE" )) - fi - - if [[ -f "$BUILDFILE" ]]; then - BUILD_REQUIREMENTS+=($( cat "$BUILDFILE" )) - fi - - # Unfortunately the Alpine repositories are in a slightly inconsistent state for now-- python2 only exists in 'edge', not main. - # if [[ "$PYTHON_VERSION" == '2' ]]; then BUILD_PACKAGES="$(echo $BUILD_PACKAGES | sed -e 's/python2/python/g')"; fi \ - - apk add --no-cache $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" - - # Install any Pip requirements - if [[ -f "$REQFILE" ]]; then - PIP_REQUIREMENTS+=($( cat "$REQFILE" )) - fi - - if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then - pip install --upgrade pip - pip install "${PIP_REQUIREMENTS[@]}" - fi - - # Remove packages that were only required for build. - apk del $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" - - touch /requirements.installed -fi - - -if [[ ! -z "$@" ]]; then - # If the user has given us a command, run it. - $@ -else - # Otherwise, default to running 'python'. - python -fi diff --git a/latest/slim/Dockerfile b/latest/slim/Dockerfile deleted file mode 100644 index f1fd6a7..0000000 --- a/latest/slim/Dockerfile +++ /dev/null @@ -1,65 +0,0 @@ -FROM alpine:3.6 - -ENV ALPINE_VERSION=3.6 - -# These are always installed. Notes: -# * dumb-init: a proper init system for containers, to reap zombie children -# * bash: For entrypoint, and debugging -# * ca-certificates: for SSL verification during Pip and easy_install -# * python: the binaries themselves -ENV PACKAGES="\ - dumb-init \ - bash \ - ca-certificates \ - python3 \ -" - -RUN echo \ - # replacing default repositories with edge ones - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ - - # Add the packages, with a CDN-breakage fallback if needed - && apk add --no-cache $PACKAGES || \ - (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ - - # turn back the clock -- so hacky! - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ - # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ - # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ - - # make some useful symlinks that are expected to exist - && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi \ - && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python-config3 /usr/bin/python-config; fi \ - && if [[ ! -e /usr/bin/idle ]]; then ln -sf /usr/bin/idle3 /usr/bin/idle; fi \ - && if [[ ! -e /usr/bin/pydoc ]]; then ln -sf /usr/bin/pydoc3 /usr/bin/pydoc; fi \ - && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf /usr/bin/easy_install-3* /usr/bin/easy_install; fi \ - - # Install and upgrade Pip - && easy_install pip \ - && pip install --upgrade pip \ - && if [[ ! -e /usr/bin/pip ]]; then ln -sf /usr/bin/pip3 /usr/bin/pip; fi \ - && echo - -# Copy in the entrypoint script -- this installs prerequisites on container start. -COPY entrypoint.sh /entrypoint.sh - -# These packages are not installed immediately, but are added at runtime or ONBUILD to shrink the image as much as possible. Notes: -# * build-base: used so we include the basic development packages (gcc) -# * linux-headers: commonly needed, and an unusual package name from Alpine. -# * python-dev: are used for gevent e.g. -# * py-pip: provides pip, not needed once the software is built -ENV BUILD_PACKAGES="\ - build-base \ - linux-headers \ - python3-dev \ -" - -# This script installs APK and Pip prerequisites on container start, or ONBUILD. Notes: -# * Reads the -a flags and /apk-requirements.txt for install requests -# * Reads the -b flags and /build-requirements.txt for build packages -- removed when build is complete -# * Reads the -p flags and /requirements.txt for Pip packages -# * Reads the -r flag to specify a different file path for /requirements.txt -ENTRYPOINT ["/usr/bin/dumb-init", "bash", "/entrypoint.sh"] diff --git a/latest/slim/entrypoint.sh b/latest/slim/entrypoint.sh deleted file mode 100755 index c8c419c..0000000 --- a/latest/slim/entrypoint.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/dumb-init /bin/bash -set -e - -APK_REQUIREMENTS=() -BUILD_REQUIREMENTS=() -PIP_REQUIREMENTS=() -APKFILE='/apk-requirements.txt' -BUILDFILE='/build-requirements.txt' -REQFILE='/requirements.txt' - -function usage () { - echo <<"EOF" -Usage: $0 [-a -b -p -A -B -P -r] [--] - -a : APK requirement. Can be specified multiple times. - -b : APK build requirement. These will be removed at the end to save space. - -p : Pip requirement. Can be specified multiple times. - - -A : apk-requirements.txt file location, default: /apk-requirements.txt - -B : build-requirements.txt file location, default: /build-requirements.txt - -P : requirements.txt file location, default: /requirements.txt - -r : same as above, just to match Pip's -r flag. - - -- : Separator for flags and your command - - Whatever you provide after your arguments is run at the end. -EOF - exit 1 -} - -# Get and process arguments -while getopts ":a:b:p:A:B:P:r:" opt; do - case $opt in - a) APK_REQUIREMENTS+=("$OPTARG") ;; - b) BUILD_REQUIREMENTS+=("$OPTARG") ;; - p) PIP_REQUIREMENTS+=("$OPTARG") ;; - A) APKFILE="$OPTARG" ;; - B) BUILDFILE="$OPTARG" ;; - P) REQFILE="$OPTARG" ;; - r) REQFILE="$OPTARG" ;; - \?) - echo "Invalid option: -$OPTARG" >&2 - usage - ;; - :) - echo "Option -$OPTARG requires an argument." >&2 - usage - ;; - esac -done - -# Bad arguments -if [ $? -ne 0 ]; -then - usage -fi - -# Strip out all the arguments that have been processed -shift $((OPTIND-1)) - -# If there's a double dash at the end, get that off -[[ $1 = "--" ]] && shift - -# Don't do anything if we've already done this. -if [[ ! -f /requirements.installed ]]; then - - # Install any APK requirements - if [[ -f "$APKFILE" ]]; then - APK_REQUIREMENTS+=($( cat "$APKFILE" )) - fi - - if [[ -f "$BUILDFILE" ]]; then - BUILD_REQUIREMENTS+=($( cat "$BUILDFILE" )) - fi - - # Unfortunately the Alpine repositories are in a slightly inconsistent state for now-- python2 only exists in 'edge', not main. - # if [[ "$PYTHON_VERSION" == '2' ]]; then BUILD_PACKAGES="$(echo $BUILD_PACKAGES | sed -e 's/python2/python/g')"; fi \ - - apk add --no-cache $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" - - # Install any Pip requirements - if [[ -f "$REQFILE" ]]; then - PIP_REQUIREMENTS+=($( cat "$REQFILE" )) - fi - - if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then - pip install --upgrade pip - pip install "${PIP_REQUIREMENTS[@]}" - fi - - # Remove packages that were only required for build. - apk del $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" - - touch /requirements.installed -fi - - -if [[ ! -z "$@" ]]; then - # If the user has given us a command, run it. - $@ -else - # Otherwise, default to running 'python'. - python -fi From 79b231fc569e6633b44dfcd542a387624972ba3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Loff?= Date: Sat, 30 Dec 2017 18:45:07 +0000 Subject: [PATCH 07/55] Add recent tag, wich replaces old latest that was temporarly removed --- .travis.yml | 7 ++- build-all.sh | 2 +- recent-onbuild/Dockerfile | 13 +++++ recent-onbuild/entrypoint.sh | 103 +++++++++++++++++++++++++++++++++++ recent-slim/Dockerfile | 65 ++++++++++++++++++++++ recent-slim/entrypoint.sh | 103 +++++++++++++++++++++++++++++++++++ recent/Dockerfile | 56 +++++++++++++++++++ 7 files changed, 346 insertions(+), 3 deletions(-) create mode 100644 recent-onbuild/Dockerfile create mode 100755 recent-onbuild/entrypoint.sh create mode 100644 recent-slim/Dockerfile create mode 100755 recent-slim/entrypoint.sh create mode 100644 recent/Dockerfile diff --git a/.travis.yml b/.travis.yml index 43ab2ad..284cee2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,8 @@ before_install: env: global: - - alpine_image='alpine:3.6' - - latest='3.4' + - alpine_image='alpine:3.7' + - latest='recent' - repo='jfloff/alpine-python' matrix: - version='2.7' type='' @@ -20,6 +20,9 @@ env: - version='3.4' type='' - version='3.4' type='-onbuild' - version='3.4' type='-slim' + - version='recent' type='' + - version='recent' type='-onbuild' + - version='recent' type='-slim' before_script: - sudo docker pull $alpine_image diff --git a/build-all.sh b/build-all.sh index bccb042..a9256d5 100755 --- a/build-all.sh +++ b/build-all.sh @@ -8,7 +8,7 @@ reset="$(tput sgr0)" build_with_status () { tag="$1" - echo -n "Building $tag:" + echo -n "Building $tag" docker build . -t $tag &> /dev/null if [[ $? -ne 0 ]]; then echo "$bold$red BUILD FAILED$reset" diff --git a/recent-onbuild/Dockerfile b/recent-onbuild/Dockerfile new file mode 100644 index 0000000..ecd2413 --- /dev/null +++ b/recent-onbuild/Dockerfile @@ -0,0 +1,13 @@ +FROM jfloff/alpine-python:recent + +# Copy in the entrypoint script -- this installs prerequisites on container start. +COPY entrypoint.sh /entrypoint.sh + +# install requirements +# this way when you build you won't need to install again +# and since COPY is cached we don't need to wait +ONBUILD COPY requirements.txt /tmp/requirements.txt + +# Run the dependencies installer and then allow it to be run again if needed. +ONBUILD RUN /entrypoint.sh -r /tmp/requirements.txt +ONBUILD RUN rm -f /requirements.installed diff --git a/recent-onbuild/entrypoint.sh b/recent-onbuild/entrypoint.sh new file mode 100755 index 0000000..c8c419c --- /dev/null +++ b/recent-onbuild/entrypoint.sh @@ -0,0 +1,103 @@ +#!/usr/bin/dumb-init /bin/bash +set -e + +APK_REQUIREMENTS=() +BUILD_REQUIREMENTS=() +PIP_REQUIREMENTS=() +APKFILE='/apk-requirements.txt' +BUILDFILE='/build-requirements.txt' +REQFILE='/requirements.txt' + +function usage () { + echo <<"EOF" +Usage: $0 [-a -b -p -A -B -P -r] [--] + -a : APK requirement. Can be specified multiple times. + -b : APK build requirement. These will be removed at the end to save space. + -p : Pip requirement. Can be specified multiple times. + + -A : apk-requirements.txt file location, default: /apk-requirements.txt + -B : build-requirements.txt file location, default: /build-requirements.txt + -P : requirements.txt file location, default: /requirements.txt + -r : same as above, just to match Pip's -r flag. + + -- : Separator for flags and your command + + Whatever you provide after your arguments is run at the end. +EOF + exit 1 +} + +# Get and process arguments +while getopts ":a:b:p:A:B:P:r:" opt; do + case $opt in + a) APK_REQUIREMENTS+=("$OPTARG") ;; + b) BUILD_REQUIREMENTS+=("$OPTARG") ;; + p) PIP_REQUIREMENTS+=("$OPTARG") ;; + A) APKFILE="$OPTARG" ;; + B) BUILDFILE="$OPTARG" ;; + P) REQFILE="$OPTARG" ;; + r) REQFILE="$OPTARG" ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + usage + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + usage + ;; + esac +done + +# Bad arguments +if [ $? -ne 0 ]; +then + usage +fi + +# Strip out all the arguments that have been processed +shift $((OPTIND-1)) + +# If there's a double dash at the end, get that off +[[ $1 = "--" ]] && shift + +# Don't do anything if we've already done this. +if [[ ! -f /requirements.installed ]]; then + + # Install any APK requirements + if [[ -f "$APKFILE" ]]; then + APK_REQUIREMENTS+=($( cat "$APKFILE" )) + fi + + if [[ -f "$BUILDFILE" ]]; then + BUILD_REQUIREMENTS+=($( cat "$BUILDFILE" )) + fi + + # Unfortunately the Alpine repositories are in a slightly inconsistent state for now-- python2 only exists in 'edge', not main. + # if [[ "$PYTHON_VERSION" == '2' ]]; then BUILD_PACKAGES="$(echo $BUILD_PACKAGES | sed -e 's/python2/python/g')"; fi \ + + apk add --no-cache $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" + + # Install any Pip requirements + if [[ -f "$REQFILE" ]]; then + PIP_REQUIREMENTS+=($( cat "$REQFILE" )) + fi + + if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then + pip install --upgrade pip + pip install "${PIP_REQUIREMENTS[@]}" + fi + + # Remove packages that were only required for build. + apk del $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" + + touch /requirements.installed +fi + + +if [[ ! -z "$@" ]]; then + # If the user has given us a command, run it. + $@ +else + # Otherwise, default to running 'python'. + python +fi diff --git a/recent-slim/Dockerfile b/recent-slim/Dockerfile new file mode 100644 index 0000000..f9bc55d --- /dev/null +++ b/recent-slim/Dockerfile @@ -0,0 +1,65 @@ +FROM alpine:3.7 + +ENV ALPINE_VERSION=3.7 + +# These are always installed. Notes: +# * dumb-init: a proper init system for containers, to reap zombie children +# * bash: For entrypoint, and debugging +# * ca-certificates: for SSL verification during Pip and easy_install +# * python: the binaries themselves +ENV PACKAGES="\ + dumb-init \ + bash \ + ca-certificates \ + python3 \ +" + +RUN echo \ + # replacing default repositories with edge ones + && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + + # Add the packages, with a CDN-breakage fallback if needed + && apk add --no-cache $PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ + + # turn back the clock -- so hacky! + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ + # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ + # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + + # make some useful symlinks that are expected to exist + && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi \ + && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python-config3 /usr/bin/python-config; fi \ + && if [[ ! -e /usr/bin/idle ]]; then ln -sf /usr/bin/idle3 /usr/bin/idle; fi \ + && if [[ ! -e /usr/bin/pydoc ]]; then ln -sf /usr/bin/pydoc3 /usr/bin/pydoc; fi \ + && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf $(ls /usr/bin/easy_install*) /usr/bin/easy_install; fi \ + + # Install and upgrade Pip + && easy_install pip \ + && pip install --upgrade pip \ + && if [[ ! -e /usr/bin/pip ]]; then ln -sf /usr/bin/pip3 /usr/bin/pip; fi \ + && echo + +# Copy in the entrypoint script -- this installs prerequisites on container start. +COPY entrypoint.sh /entrypoint.sh + +# These packages are not installed immediately, but are added at runtime or ONBUILD to shrink the image as much as possible. Notes: +# * build-base: used so we include the basic development packages (gcc) +# * linux-headers: commonly needed, and an unusual package name from Alpine. +# * python-dev: are used for gevent e.g. +# * py-pip: provides pip, not needed once the software is built +ENV BUILD_PACKAGES="\ + build-base \ + linux-headers \ + python3-dev \ +" + +# This script installs APK and Pip prerequisites on container start, or ONBUILD. Notes: +# * Reads the -a flags and /apk-requirements.txt for install requests +# * Reads the -b flags and /build-requirements.txt for build packages -- removed when build is complete +# * Reads the -p flags and /requirements.txt for Pip packages +# * Reads the -r flag to specify a different file path for /requirements.txt +ENTRYPOINT ["/usr/bin/dumb-init", "bash", "/entrypoint.sh"] diff --git a/recent-slim/entrypoint.sh b/recent-slim/entrypoint.sh new file mode 100755 index 0000000..c8c419c --- /dev/null +++ b/recent-slim/entrypoint.sh @@ -0,0 +1,103 @@ +#!/usr/bin/dumb-init /bin/bash +set -e + +APK_REQUIREMENTS=() +BUILD_REQUIREMENTS=() +PIP_REQUIREMENTS=() +APKFILE='/apk-requirements.txt' +BUILDFILE='/build-requirements.txt' +REQFILE='/requirements.txt' + +function usage () { + echo <<"EOF" +Usage: $0 [-a -b -p -A -B -P -r] [--] + -a : APK requirement. Can be specified multiple times. + -b : APK build requirement. These will be removed at the end to save space. + -p : Pip requirement. Can be specified multiple times. + + -A : apk-requirements.txt file location, default: /apk-requirements.txt + -B : build-requirements.txt file location, default: /build-requirements.txt + -P : requirements.txt file location, default: /requirements.txt + -r : same as above, just to match Pip's -r flag. + + -- : Separator for flags and your command + + Whatever you provide after your arguments is run at the end. +EOF + exit 1 +} + +# Get and process arguments +while getopts ":a:b:p:A:B:P:r:" opt; do + case $opt in + a) APK_REQUIREMENTS+=("$OPTARG") ;; + b) BUILD_REQUIREMENTS+=("$OPTARG") ;; + p) PIP_REQUIREMENTS+=("$OPTARG") ;; + A) APKFILE="$OPTARG" ;; + B) BUILDFILE="$OPTARG" ;; + P) REQFILE="$OPTARG" ;; + r) REQFILE="$OPTARG" ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + usage + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + usage + ;; + esac +done + +# Bad arguments +if [ $? -ne 0 ]; +then + usage +fi + +# Strip out all the arguments that have been processed +shift $((OPTIND-1)) + +# If there's a double dash at the end, get that off +[[ $1 = "--" ]] && shift + +# Don't do anything if we've already done this. +if [[ ! -f /requirements.installed ]]; then + + # Install any APK requirements + if [[ -f "$APKFILE" ]]; then + APK_REQUIREMENTS+=($( cat "$APKFILE" )) + fi + + if [[ -f "$BUILDFILE" ]]; then + BUILD_REQUIREMENTS+=($( cat "$BUILDFILE" )) + fi + + # Unfortunately the Alpine repositories are in a slightly inconsistent state for now-- python2 only exists in 'edge', not main. + # if [[ "$PYTHON_VERSION" == '2' ]]; then BUILD_PACKAGES="$(echo $BUILD_PACKAGES | sed -e 's/python2/python/g')"; fi \ + + apk add --no-cache $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" + + # Install any Pip requirements + if [[ -f "$REQFILE" ]]; then + PIP_REQUIREMENTS+=($( cat "$REQFILE" )) + fi + + if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then + pip install --upgrade pip + pip install "${PIP_REQUIREMENTS[@]}" + fi + + # Remove packages that were only required for build. + apk del $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" + + touch /requirements.installed +fi + + +if [[ ! -z "$@" ]]; then + # If the user has given us a command, run it. + $@ +else + # Otherwise, default to running 'python'. + python +fi diff --git a/recent/Dockerfile b/recent/Dockerfile new file mode 100644 index 0000000..aeab885 --- /dev/null +++ b/recent/Dockerfile @@ -0,0 +1,56 @@ +FROM alpine:3.7 + +ENV ALPINE_VERSION=3.7 + +# Install needed packages. Notes: +# * dumb-init: a proper init system for containers, to reap zombie children +# * musl: standard C library +# * linux-headers: commonly needed, and an unusual package name from Alpine. +# * build-base: used so we include the basic development packages (gcc) +# * bash: so we can access /bin/bash +# * git: to ease up clones of repos +# * ca-certificates: for SSL verification during Pip and easy_install +# * python: the binaries themselves +# * python-dev: are used for gevent e.g. +ENV PACKAGES="\ + dumb-init \ + musl \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ + python3 \ + python3-dev \ +" + +RUN echo \ + # replacing default repositories with edge ones + && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + + # Add the packages, with a CDN-breakage fallback if needed + && apk add --no-cache $PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ + + # turn back the clock -- so hacky! + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ + # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ + # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + + # make some useful symlinks that are expected to exist + && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi \ + && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python3-config /usr/bin/python-config; fi \ + && if [[ ! -e /usr/bin/pydoc ]]; then ln -sf /usr/bin/pydoc3 /usr/bin/pydoc; fi \ + && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf $(ls /usr/bin/easy_install*) /usr/bin/easy_install; fi \ + + # Install and upgrade Pip + && easy_install pip \ + && pip install --upgrade pip \ + && if [[ ! -e /usr/bin/pip ]]; then ln -sf /usr/bin/pip3 /usr/bin/pip; fi + +# since we will be "always" mounting the volume, we can set this up +ENTRYPOINT ["/usr/bin/dumb-init"] +CMD ["python"] From 200e75918bea1c45ef29af79621f48fa804cbcd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Loff?= Date: Sat, 30 Dec 2017 19:06:59 +0000 Subject: [PATCH 08/55] Remove dependency on onbuild images --- 2.7-onbuild/Dockerfile | 59 ++++++++++++++++++++++++++++++++++++++- 3.4-onbuild/Dockerfile | 58 +++++++++++++++++++++++++++++++++++++- README.md | 6 ++-- recent-onbuild/Dockerfile | 57 ++++++++++++++++++++++++++++++++++++- 4 files changed, 174 insertions(+), 6 deletions(-) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index ac09e2a..f6ab5c3 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -1,4 +1,57 @@ -FROM jfloff/alpine-python:2.7 +FROM alpine:3.7 + +ENV ALPINE_VERSION=3.7 + +# Install needed packages. Notes: +# * dumb-init: a proper init system for containers, to reap zombie children +# * musl: standard C library +# * linux-headers: commonly needed, and an unusual package name from Alpine. +# * build-base: used so we include the basic development packages (gcc) +# * bash: so we can access /bin/bash +# * git: to ease up clones of repos +# * ca-certificates: for SSL verification during Pip and easy_install +# * python: the binaries themselves +# * python-dev: are used for gevent e.g. +# * py-setuptools: required only in major version 2, installs easy_install so we can install Pip. +ENV PACKAGES="\ + dumb-init \ + musl \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ + python2 \ + python2-dev \ + py-setuptools \ +" + +RUN echo \ + # replacing default repositories with edge ones + && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + + # Add the packages, with a CDN-breakage fallback if needed + && apk add --no-cache $PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ + + # turn back the clock -- so hacky! + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ + # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ + # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + + # make some useful symlinks that are expected to exist + && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python2.7 /usr/bin/python; fi \ + && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python2.7-config /usr/bin/python-config; fi \ + && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf /usr/bin/easy_install-2.7 /usr/bin/easy_install; fi \ + + # Install and upgrade Pip + && easy_install pip \ + && pip install --upgrade pip \ + && if [[ ! -e /usr/bin/pip ]]; then ln -sf /usr/bin/pip2.7 /usr/bin/pip; fi \ + && echo # Copy in the entrypoint script -- this installs prerequisites on container start. COPY entrypoint.sh /entrypoint.sh @@ -11,3 +64,7 @@ ONBUILD COPY requirements.txt /tmp/requirements.txt # Run the dependencies installer and then allow it to be run again if needed. ONBUILD RUN /entrypoint.sh -r /tmp/requirements.txt ONBUILD RUN rm -f /requirements.installed + +# since we will be "always" mounting the volume, we can set this up +ENTRYPOINT ["/usr/bin/dumb-init"] +CMD ["python"] \ No newline at end of file diff --git a/3.4-onbuild/Dockerfile b/3.4-onbuild/Dockerfile index a4ada9a..bce9f77 100644 --- a/3.4-onbuild/Dockerfile +++ b/3.4-onbuild/Dockerfile @@ -1,4 +1,56 @@ -FROM jfloff/alpine-python:3.4 +FROM alpine:3.7 + +ENV ALPINE_VERSION=3.7 + +# Install needed packages. Notes: +# * dumb-init: a proper init system for containers, to reap zombie children +# * musl: standard C library +# * linux-headers: commonly needed, and an unusual package name from Alpine. +# * build-base: used so we include the basic development packages (gcc) +# * bash: so we can access /bin/bash +# * git: to ease up clones of repos +# * ca-certificates: for SSL verification during Pip and easy_install +# * python: the binaries themselves +# * python-dev: are used for gevent e.g. +ENV PACKAGES="\ + dumb-init \ + musl \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ + python3.4 \ + python3.4-dev \ +" + +RUN echo \ + # replacing default repositories with edge ones + && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + + # Add the packages, with a CDN-breakage fallback if needed + && apk add --no-cache $PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ + + # turn back the clock -- so hacky! + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ + # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ + # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + + # make some useful symlinks that are expected to exist + && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3.4 /usr/bin/python; fi \ + && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python3.4-config /usr/bin/python-config; fi \ + && if [[ ! -e /usr/bin/idle ]]; then ln -sf /usr/bin/idle3.4 /usr/bin/idle; fi \ + && if [[ ! -e /usr/bin/pydoc ]]; then ln -sf /usr/bin/pydoc3.4 /usr/bin/pydoc; fi \ + && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf /usr/bin/easy_install-3.4 /usr/bin/easy_install; fi \ + + # Install and upgrade Pip + && easy_install pip \ + && pip install --upgrade pip \ + && if [[ ! -e /usr/bin/pip ]]; then ln -sf /usr/bin/pip3.4 /usr/bin/pip; fi # Copy in the entrypoint script -- this installs prerequisites on container start. COPY entrypoint.sh /entrypoint.sh @@ -11,3 +63,7 @@ ONBUILD COPY requirements.txt /tmp/requirements.txt # Run the dependencies installer and then allow it to be run again if needed. ONBUILD RUN /entrypoint.sh -r /tmp/requirements.txt ONBUILD RUN rm -f /requirements.installed + +# since we will be "always" mounting the volume, we can set this up +ENTRYPOINT ["/usr/bin/dumb-init"] +CMD ["python"] diff --git a/README.md b/README.md index 56c2729..9835252 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,9 @@ A small Python Docker image based on [Alpine Linux](http://alpinelinux.org/). * **`3.4` ([3.4/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4/Dockerfile))** * **`3.4-onbuild` ([3.4-onbuild/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-onbuild/Dockerfile))** * **`3.4-slim` ([3.4-slim/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-slim/Dockerfile))** -* **`latest` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4/Dockerfile))** -* **`latest-onbuild` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-onbuild/Dockerfile))** -* **`latest-slim` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-slim/Dockerfile))** +* **`recent` `latest` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4/Dockerfile))** +* **`recent-onbuild` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-onbuild/Dockerfile))** +* **`recent-slim` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-slim/Dockerfile))** **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_. diff --git a/recent-onbuild/Dockerfile b/recent-onbuild/Dockerfile index ecd2413..fc4d0fb 100644 --- a/recent-onbuild/Dockerfile +++ b/recent-onbuild/Dockerfile @@ -1,4 +1,55 @@ -FROM jfloff/alpine-python:recent +FROM alpine:3.7 + +ENV ALPINE_VERSION=3.7 + +# Install needed packages. Notes: +# * dumb-init: a proper init system for containers, to reap zombie children +# * musl: standard C library +# * linux-headers: commonly needed, and an unusual package name from Alpine. +# * build-base: used so we include the basic development packages (gcc) +# * bash: so we can access /bin/bash +# * git: to ease up clones of repos +# * ca-certificates: for SSL verification during Pip and easy_install +# * python: the binaries themselves +# * python-dev: are used for gevent e.g. +ENV PACKAGES="\ + dumb-init \ + musl \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ + python3 \ + python3-dev \ +" + +RUN echo \ + # replacing default repositories with edge ones + && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + + # Add the packages, with a CDN-breakage fallback if needed + && apk add --no-cache $PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ + + # turn back the clock -- so hacky! + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ + # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ + # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + + # make some useful symlinks that are expected to exist + && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi \ + && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python3-config /usr/bin/python-config; fi \ + && if [[ ! -e /usr/bin/pydoc ]]; then ln -sf /usr/bin/pydoc3 /usr/bin/pydoc; fi \ + && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf $(ls /usr/bin/easy_install*) /usr/bin/easy_install; fi \ + + # Install and upgrade Pip + && easy_install pip \ + && pip install --upgrade pip \ + && if [[ ! -e /usr/bin/pip ]]; then ln -sf /usr/bin/pip3 /usr/bin/pip; fi # Copy in the entrypoint script -- this installs prerequisites on container start. COPY entrypoint.sh /entrypoint.sh @@ -11,3 +62,7 @@ ONBUILD COPY requirements.txt /tmp/requirements.txt # Run the dependencies installer and then allow it to be run again if needed. ONBUILD RUN /entrypoint.sh -r /tmp/requirements.txt ONBUILD RUN rm -f /requirements.installed + +# since we will be "always" mounting the volume, we can set this up +ENTRYPOINT ["/usr/bin/dumb-init"] +CMD ["python"] \ No newline at end of file From c283ec18286611a826492b25b9a04e8c8ac102d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Loff?= Date: Sat, 30 Dec 2017 19:43:06 +0000 Subject: [PATCH 09/55] Update image sizes --- README.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 9835252..d5ccc50 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,10 @@ [![Docker Stars](https://img.shields.io/docker/stars/jfloff/alpine-python.svg)][hub] [![Docker Pulls](https://img.shields.io/docker/pulls/jfloff/alpine-python.svg)][hub] +[![Build Status](https://travis-ci.org/jfloff/alpine-python.svg?branch=master)][travis] [hub]: https://hub.docker.com/r/jfloff/alpine-python/ +[travis]: https://travis-ci.org/jfloff/alpine-python A small Python Docker image based on [Alpine Linux](http://alpinelinux.org/). @@ -37,28 +39,31 @@ A small Python Docker image based on [Alpine Linux](http://alpinelinux.org/). * **`recent-onbuild` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-onbuild/Dockerfile))** * **`recent-slim` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-slim/Dockerfile))** -**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_. +**NOTES:** +- `recent` tags are the default `python3` version that Alpine current offers. **_Current recent is `3.6`_**. +- `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? The default docker python images are too [big](https://github.com/docker-library/python/issues/45), much larger than they need to be. Hence I built this simple image based on [docker-alpine](https://github.com/gliderlabs/docker-alpine), that has everything needed for the most common python projects - including `python3-dev` (which is not common in most minimal alpine python packages). |REPOSITORY|TAG|SIZE| |-|-|-| -|jfloff/alpine-python|3.4-slim|69.8MB| -|jfloff/alpine-python|3.4-onbuild|234MB| -|jfloff/alpine-python|3.4|234MB| -|jfloff/alpine-python|2.7-slim|56.7MB| -|jfloff/alpine-python|2.7-onbuild|229MB| -|jfloff/alpine-python|2.7|230MB| +|jfloff/alpine-python|3.4-slim|66.9MB| +|jfloff/alpine-python|3.4|232MB| +|jfloff/alpine-python|2.7-slim|52.8MB| +|jfloff/alpine-python|2.7|226MB| +|jfloff/alpine-python|recent-slim|55.7MB| +|jfloff/alpine-python|recent|233MB| |||| |python|3.4-slim|151MB| -|python|3.4-onbuild|687MB| |python|3.4-alpine|85.5MB| |python|3.4|687MB| |python|2.7-slim|138MB| -|python|2.7-onbuild|681MB| |python|2.7-alpine|75.3MB| |python|2.7|681MB| +|python|3.6-slim|156MB| +|python|3.6-alpine|92.1MB| +|python|3.6|692MB| Perhaps this could be even smaller, but I'm not an Alpine guru. **Feel free to post a PR.** From 02f724fa905a2f512b811d5224fe46a4fe0fcf98 Mon Sep 17 00:00:00 2001 From: Marc Date: Wed, 17 Jan 2018 08:11:25 +0200 Subject: [PATCH 10/55] Update tag links Update "recent" tag links to point to actual "recent" files. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d5ccc50..24dabe5 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,9 @@ A small Python Docker image based on [Alpine Linux](http://alpinelinux.org/). * **`3.4` ([3.4/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4/Dockerfile))** * **`3.4-onbuild` ([3.4-onbuild/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-onbuild/Dockerfile))** * **`3.4-slim` ([3.4-slim/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-slim/Dockerfile))** -* **`recent` `latest` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4/Dockerfile))** -* **`recent-onbuild` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-onbuild/Dockerfile))** -* **`recent-slim` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-slim/Dockerfile))** +* **`recent` `latest` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/recent/Dockerfile))** +* **`recent-onbuild` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/recent-onbuild/Dockerfile))** +* **`recent-slim` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/recent-slim/Dockerfile))** **NOTES:** - `recent` tags are the default `python3` version that Alpine current offers. **_Current recent is `3.6`_**. From 8ee26de3c6d6d513d4240e0cc1e091420284b6d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Loff?= Date: Wed, 17 Jan 2018 12:13:34 +0000 Subject: [PATCH 11/55] Remove 3.4 tag image, package no longer available from Alpine --- .travis.yml | 3 -- 3.4-onbuild/Dockerfile | 69 ------------------------- 3.4-onbuild/entrypoint.sh | 103 -------------------------------------- 3.4-slim/Dockerfile | 65 ------------------------ 3.4-slim/entrypoint.sh | 103 -------------------------------------- 3.4/Dockerfile | 57 --------------------- README.md | 26 ++++------ 7 files changed, 10 insertions(+), 416 deletions(-) delete mode 100644 3.4-onbuild/Dockerfile delete mode 100755 3.4-onbuild/entrypoint.sh delete mode 100644 3.4-slim/Dockerfile delete mode 100755 3.4-slim/entrypoint.sh delete mode 100644 3.4/Dockerfile diff --git a/.travis.yml b/.travis.yml index 284cee2..fc6aa87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,9 +17,6 @@ env: - version='2.7' type='' - version='2.7' type='-onbuild' - version='2.7' type='-slim' - - version='3.4' type='' - - version='3.4' type='-onbuild' - - version='3.4' type='-slim' - version='recent' type='' - version='recent' type='-onbuild' - version='recent' type='-slim' diff --git a/3.4-onbuild/Dockerfile b/3.4-onbuild/Dockerfile deleted file mode 100644 index bce9f77..0000000 --- a/3.4-onbuild/Dockerfile +++ /dev/null @@ -1,69 +0,0 @@ -FROM alpine:3.7 - -ENV ALPINE_VERSION=3.7 - -# Install needed packages. Notes: -# * dumb-init: a proper init system for containers, to reap zombie children -# * musl: standard C library -# * linux-headers: commonly needed, and an unusual package name from Alpine. -# * build-base: used so we include the basic development packages (gcc) -# * bash: so we can access /bin/bash -# * git: to ease up clones of repos -# * ca-certificates: for SSL verification during Pip and easy_install -# * python: the binaries themselves -# * python-dev: are used for gevent e.g. -ENV PACKAGES="\ - dumb-init \ - musl \ - linux-headers \ - build-base \ - bash \ - git \ - ca-certificates \ - python3.4 \ - python3.4-dev \ -" - -RUN echo \ - # replacing default repositories with edge ones - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ - - # Add the packages, with a CDN-breakage fallback if needed - && apk add --no-cache $PACKAGES || \ - (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ - - # turn back the clock -- so hacky! - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ - # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ - # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ - - # make some useful symlinks that are expected to exist - && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3.4 /usr/bin/python; fi \ - && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python3.4-config /usr/bin/python-config; fi \ - && if [[ ! -e /usr/bin/idle ]]; then ln -sf /usr/bin/idle3.4 /usr/bin/idle; fi \ - && if [[ ! -e /usr/bin/pydoc ]]; then ln -sf /usr/bin/pydoc3.4 /usr/bin/pydoc; fi \ - && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf /usr/bin/easy_install-3.4 /usr/bin/easy_install; fi \ - - # Install and upgrade Pip - && easy_install pip \ - && pip install --upgrade pip \ - && if [[ ! -e /usr/bin/pip ]]; then ln -sf /usr/bin/pip3.4 /usr/bin/pip; fi - -# Copy in the entrypoint script -- this installs prerequisites on container start. -COPY entrypoint.sh /entrypoint.sh - -# install requirements -# this way when you build you won't need to install again -# and since COPY is cached we don't need to wait -ONBUILD COPY requirements.txt /tmp/requirements.txt - -# Run the dependencies installer and then allow it to be run again if needed. -ONBUILD RUN /entrypoint.sh -r /tmp/requirements.txt -ONBUILD RUN rm -f /requirements.installed - -# since we will be "always" mounting the volume, we can set this up -ENTRYPOINT ["/usr/bin/dumb-init"] -CMD ["python"] diff --git a/3.4-onbuild/entrypoint.sh b/3.4-onbuild/entrypoint.sh deleted file mode 100755 index c8c419c..0000000 --- a/3.4-onbuild/entrypoint.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/dumb-init /bin/bash -set -e - -APK_REQUIREMENTS=() -BUILD_REQUIREMENTS=() -PIP_REQUIREMENTS=() -APKFILE='/apk-requirements.txt' -BUILDFILE='/build-requirements.txt' -REQFILE='/requirements.txt' - -function usage () { - echo <<"EOF" -Usage: $0 [-a -b -p -A -B -P -r] [--] - -a : APK requirement. Can be specified multiple times. - -b : APK build requirement. These will be removed at the end to save space. - -p : Pip requirement. Can be specified multiple times. - - -A : apk-requirements.txt file location, default: /apk-requirements.txt - -B : build-requirements.txt file location, default: /build-requirements.txt - -P : requirements.txt file location, default: /requirements.txt - -r : same as above, just to match Pip's -r flag. - - -- : Separator for flags and your command - - Whatever you provide after your arguments is run at the end. -EOF - exit 1 -} - -# Get and process arguments -while getopts ":a:b:p:A:B:P:r:" opt; do - case $opt in - a) APK_REQUIREMENTS+=("$OPTARG") ;; - b) BUILD_REQUIREMENTS+=("$OPTARG") ;; - p) PIP_REQUIREMENTS+=("$OPTARG") ;; - A) APKFILE="$OPTARG" ;; - B) BUILDFILE="$OPTARG" ;; - P) REQFILE="$OPTARG" ;; - r) REQFILE="$OPTARG" ;; - \?) - echo "Invalid option: -$OPTARG" >&2 - usage - ;; - :) - echo "Option -$OPTARG requires an argument." >&2 - usage - ;; - esac -done - -# Bad arguments -if [ $? -ne 0 ]; -then - usage -fi - -# Strip out all the arguments that have been processed -shift $((OPTIND-1)) - -# If there's a double dash at the end, get that off -[[ $1 = "--" ]] && shift - -# Don't do anything if we've already done this. -if [[ ! -f /requirements.installed ]]; then - - # Install any APK requirements - if [[ -f "$APKFILE" ]]; then - APK_REQUIREMENTS+=($( cat "$APKFILE" )) - fi - - if [[ -f "$BUILDFILE" ]]; then - BUILD_REQUIREMENTS+=($( cat "$BUILDFILE" )) - fi - - # Unfortunately the Alpine repositories are in a slightly inconsistent state for now-- python2 only exists in 'edge', not main. - # if [[ "$PYTHON_VERSION" == '2' ]]; then BUILD_PACKAGES="$(echo $BUILD_PACKAGES | sed -e 's/python2/python/g')"; fi \ - - apk add --no-cache $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" - - # Install any Pip requirements - if [[ -f "$REQFILE" ]]; then - PIP_REQUIREMENTS+=($( cat "$REQFILE" )) - fi - - if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then - pip install --upgrade pip - pip install "${PIP_REQUIREMENTS[@]}" - fi - - # Remove packages that were only required for build. - apk del $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" - - touch /requirements.installed -fi - - -if [[ ! -z "$@" ]]; then - # If the user has given us a command, run it. - $@ -else - # Otherwise, default to running 'python'. - python -fi diff --git a/3.4-slim/Dockerfile b/3.4-slim/Dockerfile deleted file mode 100644 index 2d784fb..0000000 --- a/3.4-slim/Dockerfile +++ /dev/null @@ -1,65 +0,0 @@ -FROM alpine:3.7 - -ENV ALPINE_VERSION=3.7 - -# These are always installed. Notes: -# * dumb-init: a proper init system for containers, to reap zombie children -# * bash: For entrypoint, and debugging -# * ca-certificates: for SSL verification during Pip and easy_install -# * python: the binaries themselves -ENV PACKAGES="\ - dumb-init \ - bash \ - ca-certificates \ - python3.4 \ -" - -RUN echo \ - # replacing default repositories with edge ones - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ - - # Add the packages, with a CDN-breakage fallback if needed - && apk add --no-cache $PACKAGES || \ - (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ - - # turn back the clock -- so hacky! - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ - # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ - # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ - - # make some useful symlinks that are expected to exist - && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3.4 /usr/bin/python; fi \ - && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python-config3.4 /usr/bin/python-config; fi \ - && if [[ ! -e /usr/bin/idle ]]; then ln -sf /usr/bin/idle3.4 /usr/bin/idle; fi \ - && if [[ ! -e /usr/bin/pydoc ]]; then ln -sf /usr/bin/pydoc3.4 /usr/bin/pydoc; fi \ - && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf /usr/bin/easy_install-3.4 /usr/bin/easy_install; fi \ - - # Install and upgrade Pip - && easy_install pip \ - && pip install --upgrade pip \ - && if [[ ! -e /usr/bin/pip ]]; then ln -sf /usr/bin/pip3.4 /usr/bin/pip; fi \ - && echo - -# Copy in the entrypoint script -- this installs prerequisites on container start. -COPY entrypoint.sh /entrypoint.sh - -# These packages are not installed immediately, but are added at runtime or ONBUILD to shrink the image as much as possible. Notes: -# * build-base: used so we include the basic development packages (gcc) -# * linux-headers: commonly needed, and an unusual package name from Alpine. -# * python-dev: are used for gevent e.g. -# * py-pip: provides pip, not needed once the software is built -ENV BUILD_PACKAGES="\ - build-base \ - linux-headers \ - python3.4-dev \ -" - -# This script installs APK and Pip prerequisites on container start, or ONBUILD. Notes: -# * Reads the -a flags and /apk-requirements.txt for install requests -# * Reads the -b flags and /build-requirements.txt for build packages -- removed when build is complete -# * Reads the -p flags and /requirements.txt for Pip packages -# * Reads the -r flag to specify a different file path for /requirements.txt -ENTRYPOINT ["/usr/bin/dumb-init", "bash", "/entrypoint.sh"] diff --git a/3.4-slim/entrypoint.sh b/3.4-slim/entrypoint.sh deleted file mode 100755 index c8c419c..0000000 --- a/3.4-slim/entrypoint.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/dumb-init /bin/bash -set -e - -APK_REQUIREMENTS=() -BUILD_REQUIREMENTS=() -PIP_REQUIREMENTS=() -APKFILE='/apk-requirements.txt' -BUILDFILE='/build-requirements.txt' -REQFILE='/requirements.txt' - -function usage () { - echo <<"EOF" -Usage: $0 [-a -b -p -A -B -P -r] [--] - -a : APK requirement. Can be specified multiple times. - -b : APK build requirement. These will be removed at the end to save space. - -p : Pip requirement. Can be specified multiple times. - - -A : apk-requirements.txt file location, default: /apk-requirements.txt - -B : build-requirements.txt file location, default: /build-requirements.txt - -P : requirements.txt file location, default: /requirements.txt - -r : same as above, just to match Pip's -r flag. - - -- : Separator for flags and your command - - Whatever you provide after your arguments is run at the end. -EOF - exit 1 -} - -# Get and process arguments -while getopts ":a:b:p:A:B:P:r:" opt; do - case $opt in - a) APK_REQUIREMENTS+=("$OPTARG") ;; - b) BUILD_REQUIREMENTS+=("$OPTARG") ;; - p) PIP_REQUIREMENTS+=("$OPTARG") ;; - A) APKFILE="$OPTARG" ;; - B) BUILDFILE="$OPTARG" ;; - P) REQFILE="$OPTARG" ;; - r) REQFILE="$OPTARG" ;; - \?) - echo "Invalid option: -$OPTARG" >&2 - usage - ;; - :) - echo "Option -$OPTARG requires an argument." >&2 - usage - ;; - esac -done - -# Bad arguments -if [ $? -ne 0 ]; -then - usage -fi - -# Strip out all the arguments that have been processed -shift $((OPTIND-1)) - -# If there's a double dash at the end, get that off -[[ $1 = "--" ]] && shift - -# Don't do anything if we've already done this. -if [[ ! -f /requirements.installed ]]; then - - # Install any APK requirements - if [[ -f "$APKFILE" ]]; then - APK_REQUIREMENTS+=($( cat "$APKFILE" )) - fi - - if [[ -f "$BUILDFILE" ]]; then - BUILD_REQUIREMENTS+=($( cat "$BUILDFILE" )) - fi - - # Unfortunately the Alpine repositories are in a slightly inconsistent state for now-- python2 only exists in 'edge', not main. - # if [[ "$PYTHON_VERSION" == '2' ]]; then BUILD_PACKAGES="$(echo $BUILD_PACKAGES | sed -e 's/python2/python/g')"; fi \ - - apk add --no-cache $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" - - # Install any Pip requirements - if [[ -f "$REQFILE" ]]; then - PIP_REQUIREMENTS+=($( cat "$REQFILE" )) - fi - - if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then - pip install --upgrade pip - pip install "${PIP_REQUIREMENTS[@]}" - fi - - # Remove packages that were only required for build. - apk del $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" - - touch /requirements.installed -fi - - -if [[ ! -z "$@" ]]; then - # If the user has given us a command, run it. - $@ -else - # Otherwise, default to running 'python'. - python -fi diff --git a/3.4/Dockerfile b/3.4/Dockerfile deleted file mode 100644 index 16cb205..0000000 --- a/3.4/Dockerfile +++ /dev/null @@ -1,57 +0,0 @@ -FROM alpine:3.7 - -ENV ALPINE_VERSION=3.7 - -# Install needed packages. Notes: -# * dumb-init: a proper init system for containers, to reap zombie children -# * musl: standard C library -# * linux-headers: commonly needed, and an unusual package name from Alpine. -# * build-base: used so we include the basic development packages (gcc) -# * bash: so we can access /bin/bash -# * git: to ease up clones of repos -# * ca-certificates: for SSL verification during Pip and easy_install -# * python: the binaries themselves -# * python-dev: are used for gevent e.g. -ENV PACKAGES="\ - dumb-init \ - musl \ - linux-headers \ - build-base \ - bash \ - git \ - ca-certificates \ - python3.4 \ - python3.4-dev \ -" - -RUN echo \ - # replacing default repositories with edge ones - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ - - # Add the packages, with a CDN-breakage fallback if needed - && apk add --no-cache $PACKAGES || \ - (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ - - # turn back the clock -- so hacky! - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ - # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ - # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ - - # make some useful symlinks that are expected to exist - && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3.4 /usr/bin/python; fi \ - && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python3.4-config /usr/bin/python-config; fi \ - && if [[ ! -e /usr/bin/idle ]]; then ln -sf /usr/bin/idle3.4 /usr/bin/idle; fi \ - && if [[ ! -e /usr/bin/pydoc ]]; then ln -sf /usr/bin/pydoc3.4 /usr/bin/pydoc; fi \ - && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf /usr/bin/easy_install-3.4 /usr/bin/easy_install; fi \ - - # Install and upgrade Pip - && easy_install pip \ - && pip install --upgrade pip \ - && if [[ ! -e /usr/bin/pip ]]; then ln -sf /usr/bin/pip3.4 /usr/bin/pip; fi - -# since we will be "always" mounting the volume, we can set this up -ENTRYPOINT ["/usr/bin/dumb-init"] -CMD ["python"] diff --git a/README.md b/README.md index 24dabe5..b6c3cd6 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,6 @@ A small Python Docker image based on [Alpine Linux](http://alpinelinux.org/). * **`2.7` ([2.7/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/2.7/Dockerfile))** * **`2.7-onbuild` ([2.7-onbuild/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/2.7-onbuild/Dockerfile))** * **`2.7-slim` ([2.7-slim/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/2.7-slim/Dockerfile))** -* **`3.4` ([3.4/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4/Dockerfile))** -* **`3.4-onbuild` ([3.4-onbuild/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-onbuild/Dockerfile))** -* **`3.4-slim` ([3.4-slim/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.4-slim/Dockerfile))** * **`recent` `latest` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/recent/Dockerfile))** * **`recent-onbuild` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/recent-onbuild/Dockerfile))** * **`recent-slim` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/recent-slim/Dockerfile))** @@ -48,29 +45,26 @@ The default docker python images are too [big](https://github.com/docker-library |REPOSITORY|TAG|SIZE| |-|-|-| -|jfloff/alpine-python|3.4-slim|66.9MB| -|jfloff/alpine-python|3.4|232MB| |jfloff/alpine-python|2.7-slim|52.8MB| -|jfloff/alpine-python|2.7|226MB| -|jfloff/alpine-python|recent-slim|55.7MB| -|jfloff/alpine-python|recent|233MB| -|||| -|python|3.4-slim|151MB| -|python|3.4-alpine|85.5MB| -|python|3.4|687MB| |python|2.7-slim|138MB| +|||| +|jfloff/alpine-python|2.7|226MB| |python|2.7-alpine|75.3MB| |python|2.7|681MB| +|||| +|jfloff/alpine-python|recent-slim|55.7MB| |python|3.6-slim|156MB| -|python|3.6-alpine|92.1MB| +|||| +|jfloff/alpine-python|recent|233MB| |python|3.6|692MB| +|python|3.6-alpine|92.1MB| Perhaps this could be even smaller, but I'm not an Alpine guru. **Feel free to post a PR.** ## Details * Installs `build-base` and `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.4` > `python`, `pip2.7` > `pip`, etc.) +* Just like the main `python` docker image, it creates useful symlinks that are expected to exist, e.g. `python3` > `python`, `pip2.7` > `pip`, etc.) * Added `testing` and `community` repositories to Alpine's `/etc/apk/repositories` file ## Usage @@ -89,7 +83,7 @@ docker run --rm -ti jfloff/alpine-python bash These images can be used to bake your dependencies into an image by extending the plain python images. To do so, create a custom `Dockerfile` like this: ```dockerfile -FROM jfloff/alpine-python:3.4-onbuild +FROM jfloff/alpine-python:recent-onbuild # for a flask server EXPOSE 5000 @@ -211,4 +205,4 @@ The code in this repository, unless otherwise noted, is MIT licensed. See the `L ## TODO At this moment with Alpine APK we are not able to install previous packages versions, i.e., its virtually impossible to provide multiple versions of Python. This is limits us to only provide the latest `python3` package that's available in Alpine APK. -While I was able to provide a 3.4 tag (due to existence of `python3.4` packages), this is a temporary fix. Ideally we would support a solution like the official `python` images does (see example [here](https://github.com/docker-library/python/blob/master/3.4/alpine/Dockerfile)), where the specific Python version is downloaded and compiled. Yet, I don't want to follow the pitfall of copy-pasting that solution, otherwise we end up with almost the same image. ***I'm requesting PRs on this issue, either by optimizing official solution, or other.*** +Ideally we would support a solution like the official `python` images does (see example [here](https://github.com/docker-library/python/blob/master/3.4/alpine/Dockerfile)), where the specific Python version is downloaded and compiled. Yet, I don't want to follow the pitfall of copy-pasting that solution, otherwise we end up with almost the same image. ***I'm requesting PRs on this issue, either by optimizing official solution, or other.*** From 76c2abe472a0f3952a65c7ae9ad5f7686c00e575 Mon Sep 17 00:00:00 2001 From: Trevor Robinson Date: Mon, 19 Feb 2018 16:46:00 -0800 Subject: [PATCH 12/55] Fixes #21 - requirements.txt via file rather than catting. --- 2.7-onbuild/entrypoint.sh | 21 ++++++++++++++++----- 2.7-slim/entrypoint.sh | 21 ++++++++++++++++----- recent-onbuild/entrypoint.sh | 21 ++++++++++++++++----- recent-slim/entrypoint.sh | 21 ++++++++++++++++----- 4 files changed, 64 insertions(+), 20 deletions(-) diff --git a/2.7-onbuild/entrypoint.sh b/2.7-onbuild/entrypoint.sh index c8c419c..7ab3f95 100755 --- a/2.7-onbuild/entrypoint.sh +++ b/2.7-onbuild/entrypoint.sh @@ -8,6 +8,8 @@ APKFILE='/apk-requirements.txt' BUILDFILE='/build-requirements.txt' REQFILE='/requirements.txt' +TMP_REQFILE='/tmp/requirements.txt' + function usage () { echo <<"EOF" Usage: $0 [-a -b -p -A -B -P -r] [--] @@ -78,13 +80,22 @@ if [[ ! -f /requirements.installed ]]; then apk add --no-cache $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" # Install any Pip requirements - if [[ -f "$REQFILE" ]]; then - PIP_REQUIREMENTS+=($( cat "$REQFILE" )) - fi + TARGET_REQFILE="$REQFILE" + + if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then + # Put all Pip requirements into the same file. + printf "%s\n" "${PIP_REQUIREMENTS[@]}" >> "$TMP_REQFILE" + + if [[ -f "$REQFILE" && "$(cat $REQFILE | wc -l)" -gt 0 ]]; then + cat "$REQFILE" >> "$TMP_REQFILE" + fi + + TARGET_REQFILE="$TMP_REQFILE" + fi - if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then + if [[ -f $TARGET_REQFILE && "$(cat $TARGET_REQFILE | wc -l)" -gt 0 ]]; then pip install --upgrade pip - pip install "${PIP_REQUIREMENTS[@]}" + pip install -r "$TARGET_REQFILE" fi # Remove packages that were only required for build. diff --git a/2.7-slim/entrypoint.sh b/2.7-slim/entrypoint.sh index c8c419c..7ab3f95 100755 --- a/2.7-slim/entrypoint.sh +++ b/2.7-slim/entrypoint.sh @@ -8,6 +8,8 @@ APKFILE='/apk-requirements.txt' BUILDFILE='/build-requirements.txt' REQFILE='/requirements.txt' +TMP_REQFILE='/tmp/requirements.txt' + function usage () { echo <<"EOF" Usage: $0 [-a -b -p -A -B -P -r] [--] @@ -78,13 +80,22 @@ if [[ ! -f /requirements.installed ]]; then apk add --no-cache $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" # Install any Pip requirements - if [[ -f "$REQFILE" ]]; then - PIP_REQUIREMENTS+=($( cat "$REQFILE" )) - fi + TARGET_REQFILE="$REQFILE" + + if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then + # Put all Pip requirements into the same file. + printf "%s\n" "${PIP_REQUIREMENTS[@]}" >> "$TMP_REQFILE" + + if [[ -f "$REQFILE" && "$(cat $REQFILE | wc -l)" -gt 0 ]]; then + cat "$REQFILE" >> "$TMP_REQFILE" + fi + + TARGET_REQFILE="$TMP_REQFILE" + fi - if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then + if [[ -f $TARGET_REQFILE && "$(cat $TARGET_REQFILE | wc -l)" -gt 0 ]]; then pip install --upgrade pip - pip install "${PIP_REQUIREMENTS[@]}" + pip install -r "$TARGET_REQFILE" fi # Remove packages that were only required for build. diff --git a/recent-onbuild/entrypoint.sh b/recent-onbuild/entrypoint.sh index c8c419c..7ab3f95 100755 --- a/recent-onbuild/entrypoint.sh +++ b/recent-onbuild/entrypoint.sh @@ -8,6 +8,8 @@ APKFILE='/apk-requirements.txt' BUILDFILE='/build-requirements.txt' REQFILE='/requirements.txt' +TMP_REQFILE='/tmp/requirements.txt' + function usage () { echo <<"EOF" Usage: $0 [-a -b -p -A -B -P -r] [--] @@ -78,13 +80,22 @@ if [[ ! -f /requirements.installed ]]; then apk add --no-cache $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" # Install any Pip requirements - if [[ -f "$REQFILE" ]]; then - PIP_REQUIREMENTS+=($( cat "$REQFILE" )) - fi + TARGET_REQFILE="$REQFILE" + + if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then + # Put all Pip requirements into the same file. + printf "%s\n" "${PIP_REQUIREMENTS[@]}" >> "$TMP_REQFILE" + + if [[ -f "$REQFILE" && "$(cat $REQFILE | wc -l)" -gt 0 ]]; then + cat "$REQFILE" >> "$TMP_REQFILE" + fi + + TARGET_REQFILE="$TMP_REQFILE" + fi - if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then + if [[ -f $TARGET_REQFILE && "$(cat $TARGET_REQFILE | wc -l)" -gt 0 ]]; then pip install --upgrade pip - pip install "${PIP_REQUIREMENTS[@]}" + pip install -r "$TARGET_REQFILE" fi # Remove packages that were only required for build. diff --git a/recent-slim/entrypoint.sh b/recent-slim/entrypoint.sh index c8c419c..7ab3f95 100755 --- a/recent-slim/entrypoint.sh +++ b/recent-slim/entrypoint.sh @@ -8,6 +8,8 @@ APKFILE='/apk-requirements.txt' BUILDFILE='/build-requirements.txt' REQFILE='/requirements.txt' +TMP_REQFILE='/tmp/requirements.txt' + function usage () { echo <<"EOF" Usage: $0 [-a -b -p -A -B -P -r] [--] @@ -78,13 +80,22 @@ if [[ ! -f /requirements.installed ]]; then apk add --no-cache $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" # Install any Pip requirements - if [[ -f "$REQFILE" ]]; then - PIP_REQUIREMENTS+=($( cat "$REQFILE" )) - fi + TARGET_REQFILE="$REQFILE" + + if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then + # Put all Pip requirements into the same file. + printf "%s\n" "${PIP_REQUIREMENTS[@]}" >> "$TMP_REQFILE" + + if [[ -f "$REQFILE" && "$(cat $REQFILE | wc -l)" -gt 0 ]]; then + cat "$REQFILE" >> "$TMP_REQFILE" + fi + + TARGET_REQFILE="$TMP_REQFILE" + fi - if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then + if [[ -f $TARGET_REQFILE && "$(cat $TARGET_REQFILE | wc -l)" -gt 0 ]]; then pip install --upgrade pip - pip install "${PIP_REQUIREMENTS[@]}" + pip install -r "$TARGET_REQFILE" fi # Remove packages that were only required for build. From c2c93dd98f549a43826b3049b0f5088a56fbfd86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Loff?= Date: Fri, 2 Mar 2018 18:41:39 +0000 Subject: [PATCH 13/55] Add lib6-compat to packages: adds compatibility libraries for glibc --- 2.7-onbuild/Dockerfile | 2 ++ 2.7-slim/Dockerfile | 9 +++++++-- 2.7/Dockerfile | 2 ++ recent-onbuild/Dockerfile | 2 ++ recent-slim/Dockerfile | 9 +++++++-- recent/Dockerfile | 2 ++ 6 files changed, 22 insertions(+), 4 deletions(-) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index f6ab5c3..2ed8451 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -5,6 +5,7 @@ ENV ALPINE_VERSION=3.7 # Install needed packages. Notes: # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library +# * lib6-compat: compatibility libraries for glibc # * linux-headers: commonly needed, and an unusual package name from Alpine. # * build-base: used so we include the basic development packages (gcc) # * bash: so we can access /bin/bash @@ -16,6 +17,7 @@ ENV ALPINE_VERSION=3.7 ENV PACKAGES="\ dumb-init \ musl \ + libc6-compat \ linux-headers \ build-base \ bash \ diff --git a/2.7-slim/Dockerfile b/2.7-slim/Dockerfile index 391a1e8..4919d60 100644 --- a/2.7-slim/Dockerfile +++ b/2.7-slim/Dockerfile @@ -49,12 +49,17 @@ COPY entrypoint.sh /entrypoint.sh # These packages are not installed immediately, but are added at runtime or ONBUILD to shrink the image as much as possible. Notes: # * build-base: used so we include the basic development packages (gcc) # * linux-headers: commonly needed, and an unusual package name from Alpine. -# * python-dev: are used for gevent e.g. -# * py-pip: provides pip, not needed once the software is built +# * musl: standard C library +# * lib6-compat: compatibility libraries for glibc +# * python2-dev: are used for gevent e.g. +# * git: to ease up clones of repos ENV BUILD_PACKAGES="\ build-base \ linux-headers \ + musl \ + libc6-compat \ python2-dev \ + git \ " # This script installs APK and Pip prerequisites on container start, or ONBUILD. Notes: diff --git a/2.7/Dockerfile b/2.7/Dockerfile index a6b71ea..3c98ad1 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -5,6 +5,7 @@ ENV ALPINE_VERSION=3.7 # Install needed packages. Notes: # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library +# * lib6-compat: compatibility libraries for glibc # * linux-headers: commonly needed, and an unusual package name from Alpine. # * build-base: used so we include the basic development packages (gcc) # * bash: so we can access /bin/bash @@ -16,6 +17,7 @@ ENV ALPINE_VERSION=3.7 ENV PACKAGES="\ dumb-init \ musl \ + libc6-compat \ linux-headers \ build-base \ bash \ diff --git a/recent-onbuild/Dockerfile b/recent-onbuild/Dockerfile index fc4d0fb..8449fd9 100644 --- a/recent-onbuild/Dockerfile +++ b/recent-onbuild/Dockerfile @@ -5,6 +5,7 @@ ENV ALPINE_VERSION=3.7 # Install needed packages. Notes: # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library +# * lib6-compat: compatibility libraries for glibc # * linux-headers: commonly needed, and an unusual package name from Alpine. # * build-base: used so we include the basic development packages (gcc) # * bash: so we can access /bin/bash @@ -15,6 +16,7 @@ ENV ALPINE_VERSION=3.7 ENV PACKAGES="\ dumb-init \ musl \ + libc6-compat \ linux-headers \ build-base \ bash \ diff --git a/recent-slim/Dockerfile b/recent-slim/Dockerfile index f9bc55d..7738183 100644 --- a/recent-slim/Dockerfile +++ b/recent-slim/Dockerfile @@ -49,12 +49,17 @@ COPY entrypoint.sh /entrypoint.sh # These packages are not installed immediately, but are added at runtime or ONBUILD to shrink the image as much as possible. Notes: # * build-base: used so we include the basic development packages (gcc) # * linux-headers: commonly needed, and an unusual package name from Alpine. -# * python-dev: are used for gevent e.g. -# * py-pip: provides pip, not needed once the software is built +# * musl: standard C library +# * lib6-compat: compatibility libraries for glibc +# * python3-dev: are used for gevent e.g. +# * git: to ease up clones of repos ENV BUILD_PACKAGES="\ build-base \ linux-headers \ + musl \ + libc6-compat \ python3-dev \ + git \ " # This script installs APK and Pip prerequisites on container start, or ONBUILD. Notes: diff --git a/recent/Dockerfile b/recent/Dockerfile index aeab885..ce9f2b2 100644 --- a/recent/Dockerfile +++ b/recent/Dockerfile @@ -5,6 +5,7 @@ ENV ALPINE_VERSION=3.7 # Install needed packages. Notes: # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library +# * lib6-compat: compatibility libraries for glibc # * linux-headers: commonly needed, and an unusual package name from Alpine. # * build-base: used so we include the basic development packages (gcc) # * bash: so we can access /bin/bash @@ -15,6 +16,7 @@ ENV ALPINE_VERSION=3.7 ENV PACKAGES="\ dumb-init \ musl \ + libc6-compat \ linux-headers \ build-base \ bash \ From ed8bcd73b5e2d8037b2f397a2753cbdef18860c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Loff?= Date: Fri, 2 Mar 2018 18:55:36 +0000 Subject: [PATCH 14/55] Update size of containers in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b6c3cd6..a26b29e 100644 --- a/README.md +++ b/README.md @@ -48,14 +48,14 @@ The default docker python images are too [big](https://github.com/docker-library |jfloff/alpine-python|2.7-slim|52.8MB| |python|2.7-slim|138MB| |||| -|jfloff/alpine-python|2.7|226MB| +|jfloff/alpine-python|2.7|232MB| |python|2.7-alpine|75.3MB| |python|2.7|681MB| |||| |jfloff/alpine-python|recent-slim|55.7MB| |python|3.6-slim|156MB| |||| -|jfloff/alpine-python|recent|233MB| +|jfloff/alpine-python|recent|239MB| |python|3.6|692MB| |python|3.6-alpine|92.1MB| From 93c5c3729f8df132106e6c3a45118f50e5e4bfc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Loff?= Date: Fri, 6 Apr 2018 16:30:15 +0100 Subject: [PATCH 15/55] Change repository to ALPINE_VERSION one instead of edge --- 2.7-onbuild/Dockerfile | 10 +++++----- 2.7-slim/Dockerfile | 10 +++++----- 2.7/Dockerfile | 10 +++++----- recent-onbuild/Dockerfile | 10 +++++----- recent-slim/Dockerfile | 10 +++++----- recent/Dockerfile | 10 +++++----- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 2ed8451..5fe5860 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -30,9 +30,9 @@ ENV PACKAGES="\ RUN echo \ # replacing default repositories with edge ones - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" > /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories \ # Add the packages, with a CDN-breakage fallback if needed && apk add --no-cache $PACKAGES || \ @@ -40,8 +40,8 @@ RUN echo \ # turn back the clock -- so hacky! && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ - # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ - # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + # && echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ + # && echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories \ # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ # make some useful symlinks that are expected to exist diff --git a/2.7-slim/Dockerfile b/2.7-slim/Dockerfile index 4919d60..e5244d4 100644 --- a/2.7-slim/Dockerfile +++ b/2.7-slim/Dockerfile @@ -18,9 +18,9 @@ ENV PACKAGES="\ RUN echo \ # replacing default repositories with edge ones - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" > /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories \ # Add the packages, with a CDN-breakage fallback if needed && apk add --no-cache $PACKAGES || \ @@ -28,8 +28,8 @@ RUN echo \ # turn back the clock -- so hacky! && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ - # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ - # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + # && echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ + # && echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories \ # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ # make some useful symlinks that are expected to exist diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 3c98ad1..71e4c96 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -30,9 +30,9 @@ ENV PACKAGES="\ RUN echo \ # replacing default repositories with edge ones - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" > /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories \ # Add the packages, with a CDN-breakage fallback if needed && apk add --no-cache $PACKAGES || \ @@ -40,8 +40,8 @@ RUN echo \ # turn back the clock -- so hacky! && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ - # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ - # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + # && echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ + # && echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories \ # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ # make some useful symlinks that are expected to exist diff --git a/recent-onbuild/Dockerfile b/recent-onbuild/Dockerfile index 8449fd9..404783c 100644 --- a/recent-onbuild/Dockerfile +++ b/recent-onbuild/Dockerfile @@ -28,9 +28,9 @@ ENV PACKAGES="\ RUN echo \ # replacing default repositories with edge ones - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" > /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories \ # Add the packages, with a CDN-breakage fallback if needed && apk add --no-cache $PACKAGES || \ @@ -38,8 +38,8 @@ RUN echo \ # turn back the clock -- so hacky! && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ - # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ - # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + # && echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ + # && echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories \ # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ # make some useful symlinks that are expected to exist diff --git a/recent-slim/Dockerfile b/recent-slim/Dockerfile index 7738183..448d1fc 100644 --- a/recent-slim/Dockerfile +++ b/recent-slim/Dockerfile @@ -16,9 +16,9 @@ ENV PACKAGES="\ RUN echo \ # replacing default repositories with edge ones - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" > /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories \ # Add the packages, with a CDN-breakage fallback if needed && apk add --no-cache $PACKAGES || \ @@ -26,8 +26,8 @@ RUN echo \ # turn back the clock -- so hacky! && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ - # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ - # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + # && echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ + # && echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories \ # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ # make some useful symlinks that are expected to exist diff --git a/recent/Dockerfile b/recent/Dockerfile index ce9f2b2..395d041 100644 --- a/recent/Dockerfile +++ b/recent/Dockerfile @@ -28,9 +28,9 @@ ENV PACKAGES="\ RUN echo \ # replacing default repositories with edge ones - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" > /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" > /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ + && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories \ # Add the packages, with a CDN-breakage fallback if needed && apk add --no-cache $PACKAGES || \ @@ -38,8 +38,8 @@ RUN echo \ # turn back the clock -- so hacky! && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ - # && echo "@edge-testing http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \ - # && echo "@edge-community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + # && echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ + # && echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories \ # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ # make some useful symlinks that are expected to exist From cf5cb69832f679ebdc7532eb4a01fcf3c2e1b22a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Loff?= Date: Sun, 6 May 2018 21:59:30 +0100 Subject: [PATCH 16/55] Refactor images per #25 --- 2.7-onbuild/Dockerfile | 105 ++++++++++------ 2.7/Dockerfile | 113 +++++++++++------- 3.6-onbuild/Dockerfile | 101 ++++++++++++++++ {recent-onbuild => 3.6-onbuild}/entrypoint.sh | 0 {recent-slim => 3.6-slim}/Dockerfile | 0 {recent-slim => 3.6-slim}/entrypoint.sh | 0 3.6/Dockerfile | 89 ++++++++++++++ README.md | 16 ++- recent-onbuild/Dockerfile | 70 ----------- recent/Dockerfile | 58 --------- 10 files changed, 342 insertions(+), 210 deletions(-) create mode 100644 3.6-onbuild/Dockerfile rename {recent-onbuild => 3.6-onbuild}/entrypoint.sh (100%) rename {recent-slim => 3.6-slim}/Dockerfile (100%) rename {recent-slim => 3.6-slim}/entrypoint.sh (100%) create mode 100644 3.6/Dockerfile delete mode 100644 recent-onbuild/Dockerfile delete mode 100644 recent/Dockerfile diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 5fe5860..851d3b1 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -1,8 +1,14 @@ FROM alpine:3.7 -ENV ALPINE_VERSION=3.7 +# VERSIONS +ENV ALPINE_VERSION=3.7 \ + PYTHON_VERSION=2.7.14 -# Install needed packages. Notes: +# PATHS +ENV PYTHON_PATH=/usr/lib/python$PYTHON_VERSION \ + PATH="/usr/lib/python$PYTHON_VERSION/bin/:${PATH}" + +# PACKAGES # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library # * lib6-compat: compatibility libraries for glibc @@ -11,49 +17,72 @@ ENV ALPINE_VERSION=3.7 # * bash: so we can access /bin/bash # * git: to ease up clones of repos # * ca-certificates: for SSL verification during Pip and easy_install -# * python: the binaries themselves -# * python-dev: are used for gevent e.g. -# * py-setuptools: required only in major version 2, installs easy_install so we can install Pip. ENV PACKAGES="\ - dumb-init \ - musl \ - libc6-compat \ - linux-headers \ - build-base \ - bash \ - git \ - ca-certificates \ - python2 \ - python2-dev \ - py-setuptools \ + dumb-init \ + musl \ + libc6-compat \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ +" + +# PACKAGES needed to built python +ENV PYTHON_BUILD_PACKAGES="\ + readline-dev \ + zlib-dev \ + bzip2-dev \ + sqlite-dev \ + libressl-dev \ " -RUN echo \ - # replacing default repositories with edge ones - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" > /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories \ +RUN set -ex ;\ + # find MAJOR and MINOR python versions based on $PYTHON_VERSION + export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ + export PYTHON_MINOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f2- | rev) ;\ + # replacing default repositories with edge ones + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories ;\ - # Add the packages, with a CDN-breakage fallback if needed - && apk add --no-cache $PACKAGES || \ - (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ + # Add the packages, with a CDN-breakage fallback if needed + apk add --no-cache $PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) ;\ + # Add packages just for the python build process with a CDN-breakage fallback if needed + apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES) ;\ - # turn back the clock -- so hacky! - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ - # && echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ - # && echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories \ - # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ + # turn back the clock -- so hacky! + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories ;\ + # echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ + # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ - # make some useful symlinks that are expected to exist - && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python2.7 /usr/bin/python; fi \ - && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python2.7-config /usr/bin/python-config; fi \ - && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf /usr/bin/easy_install-2.7 /usr/bin/easy_install; fi \ + # use pyenv to download and compile specific python version + git clone --depth 1 https://github.com/pyenv/pyenv /usr/lib/pyenv ;\ + PYENV_ROOT=/usr/lib/pyenv /usr/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # move specific version to correct path delete pyenv, no longer needed + mv /usr/lib/pyenv/versions/$PYTHON_VERSION/ $PYTHON_PATH ;\ + rm -rfv /usr/lib/pyenv ;\ + # change the path on the header of every file from PYENV_ROOT to PYTHON_PATH + cd $PYTHON_PATH/bin/ && sed -i "s+/usr/lib/pyenv/versions/$PYTHON_VERSION/+$PYTHON_PATH/+g" * ;\ + # delete binary "duplicates" and replace them with symlinks + # this also optimizes space since they are actually the same binary + rm -f $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION \ + $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION \ + $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config \ + $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION ;\ + ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION ;\ + ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config ;\ + ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + # delete files to to reduce container size + # tips taken from main python docker repo + find /usr/lib/python$PYTHON_VERSION -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ - # Install and upgrade Pip - && easy_install pip \ - && pip install --upgrade pip \ - && if [[ ! -e /usr/bin/pip ]]; then ln -sf /usr/bin/pip2.7 /usr/bin/pip; fi \ - && echo + # remove build dependencies and any leftover apk cache + apk del --no-cache --purge .build-deps ;\ + rm -rf /var/cache/apk/* # Copy in the entrypoint script -- this installs prerequisites on container start. COPY entrypoint.sh /entrypoint.sh diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 71e4c96..83a6a6e 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -1,8 +1,14 @@ FROM alpine:3.7 -ENV ALPINE_VERSION=3.7 +# VERSIONS +ENV ALPINE_VERSION=3.7 \ + PYTHON_VERSION=2.7.14 -# Install needed packages. Notes: +# PATHS +ENV PYTHON_PATH=/usr/lib/python$PYTHON_VERSION \ + PATH="/usr/lib/python$PYTHON_VERSION/bin/:${PATH}" + +# PACKAGES # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library # * lib6-compat: compatibility libraries for glibc @@ -11,49 +17,72 @@ ENV ALPINE_VERSION=3.7 # * bash: so we can access /bin/bash # * git: to ease up clones of repos # * ca-certificates: for SSL verification during Pip and easy_install -# * python: the binaries themselves -# * python-dev: are used for gevent e.g. -# * py-setuptools: required only in major version 2, installs easy_install so we can install Pip. ENV PACKAGES="\ - dumb-init \ - musl \ - libc6-compat \ - linux-headers \ - build-base \ - bash \ - git \ - ca-certificates \ - python2 \ - python2-dev \ - py-setuptools \ + dumb-init \ + musl \ + libc6-compat \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ +" + +# PACKAGES needed to built python +ENV PYTHON_BUILD_PACKAGES="\ + readline-dev \ + zlib-dev \ + bzip2-dev \ + sqlite-dev \ + libressl-dev \ " -RUN echo \ - # replacing default repositories with edge ones - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" > /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories \ - - # Add the packages, with a CDN-breakage fallback if needed - && apk add --no-cache $PACKAGES || \ - (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ - - # turn back the clock -- so hacky! - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ - # && echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ - # && echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories \ - # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ - - # make some useful symlinks that are expected to exist - && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python2.7 /usr/bin/python; fi \ - && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python2.7-config /usr/bin/python-config; fi \ - && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf /usr/bin/easy_install-2.7 /usr/bin/easy_install; fi \ - - # Install and upgrade Pip - && easy_install pip \ - && pip install --upgrade pip \ - && if [[ ! -e /usr/bin/pip ]]; then ln -sf /usr/bin/pip2.7 /usr/bin/pip; fi \ - && echo +RUN set -ex ;\ + # find MAJOR and MINOR python versions based on $PYTHON_VERSION + export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ + export PYTHON_MINOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f2- | rev) ;\ + # replacing default repositories with edge ones + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories ;\ + + # Add the packages, with a CDN-breakage fallback if needed + apk add --no-cache $PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) ;\ + # Add packages just for the python build process with a CDN-breakage fallback if needed + apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES) ;\ + + # turn back the clock -- so hacky! + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories ;\ + # echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ + # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ + + # use pyenv to download and compile specific python version + git clone --depth 1 https://github.com/pyenv/pyenv /usr/lib/pyenv ;\ + PYENV_ROOT=/usr/lib/pyenv /usr/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # move specific version to correct path delete pyenv, no longer needed + mv /usr/lib/pyenv/versions/$PYTHON_VERSION/ $PYTHON_PATH ;\ + rm -rfv /usr/lib/pyenv ;\ + # change the path on the header of every file from PYENV_ROOT to PYTHON_PATH + cd $PYTHON_PATH/bin/ && sed -i "s+/usr/lib/pyenv/versions/$PYTHON_VERSION/+$PYTHON_PATH/+g" * ;\ + # delete binary "duplicates" and replace them with symlinks + # this also optimizes space since they are actually the same binary + rm -f $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION \ + $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION \ + $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config \ + $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION ;\ + ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION ;\ + ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config ;\ + ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + # delete files to to reduce container size + # tips taken from main python docker repo + find /usr/lib/python$PYTHON_VERSION -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + + # remove build dependencies and any leftover apk cache + apk del --no-cache --purge .build-deps ;\ + rm -rf /var/cache/apk/* # since we will be "always" mounting the volume, we can set this up ENTRYPOINT ["/usr/bin/dumb-init"] diff --git a/3.6-onbuild/Dockerfile b/3.6-onbuild/Dockerfile new file mode 100644 index 0000000..dc09087 --- /dev/null +++ b/3.6-onbuild/Dockerfile @@ -0,0 +1,101 @@ +FROM alpine:3.7 + +# VERSIONS +ENV ALPINE_VERSION=3.7 \ + PYTHON_VERSION=3.6.5 + +# PATHS +ENV PYTHON_PATH=/usr/lib/python$PYTHON_VERSION \ + PATH="/usr/lib/python$PYTHON_VERSION/bin/:${PATH}" + +# PACKAGES +# * dumb-init: a proper init system for containers, to reap zombie children +# * musl: standard C library +# * lib6-compat: compatibility libraries for glibc +# * linux-headers: commonly needed, and an unusual package name from Alpine. +# * build-base: used so we include the basic development packages (gcc) +# * bash: so we can access /bin/bash +# * git: to ease up clones of repos +# * ca-certificates: for SSL verification during Pip and easy_install +ENV PACKAGES="\ + dumb-init \ + musl \ + libc6-compat \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ +" + +# PACKAGES needed to built python +ENV PYTHON_BUILD_PACKAGES="\ + readline-dev \ + zlib-dev \ + bzip2-dev \ + sqlite-dev \ + libressl-dev \ +" + +RUN set -ex ;\ + # find MAJOR and MINOR python versions based on $PYTHON_VERSION + export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ + export PYTHON_MINOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f2- | rev) ;\ + # replacing default repositories with edge ones + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories ;\ + + # Add the packages, with a CDN-breakage fallback if needed + apk add --no-cache $PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) ;\ + # Add packages just for the python build process with a CDN-breakage fallback if needed + apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES) ;\ + + # turn back the clock -- so hacky! + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories ;\ + # echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ + # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ + + # use pyenv to download and compile specific python version + git clone --depth 1 https://github.com/pyenv/pyenv /usr/lib/pyenv ;\ + PYENV_ROOT=/usr/lib/pyenv /usr/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # move specific version to correct path delete pyenv, no longer needed + mv /usr/lib/pyenv/versions/$PYTHON_VERSION/ $PYTHON_PATH ;\ + rm -rfv /usr/lib/pyenv ;\ + # change the path on the header of every file from PYENV_ROOT to PYTHON_PATH + cd $PYTHON_PATH/bin/ && sed -i "s+/usr/lib/pyenv/versions/$PYTHON_VERSION/+$PYTHON_PATH/+g" * ;\ + # delete binary "duplicates" and replace them with symlinks + # this also optimizes space since they are actually the same binary + rm -f $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION \ + $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION \ + $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config \ + $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION ;\ + ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION ;\ + ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config ;\ + ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + # delete files to to reduce container size + # tips taken from main python docker repo + find /usr/lib/python$PYTHON_VERSION -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + + # remove build dependencies and any leftover apk cache + apk del --no-cache --purge .build-deps ;\ + rm -rf /var/cache/apk/* + +# Copy in the entrypoint script -- this installs prerequisites on container start. +COPY entrypoint.sh /entrypoint.sh + +# install requirements +# this way when you build you won't need to install again +# and since COPY is cached we don't need to wait +ONBUILD COPY requirements.txt /tmp/requirements.txt + +# Run the dependencies installer and then allow it to be run again if needed. +ONBUILD RUN /entrypoint.sh -r /tmp/requirements.txt +ONBUILD RUN rm -f /requirements.installed + +# since we will be "always" mounting the volume, we can set this up +ENTRYPOINT ["/usr/bin/dumb-init"] +CMD ["python"] \ No newline at end of file diff --git a/recent-onbuild/entrypoint.sh b/3.6-onbuild/entrypoint.sh similarity index 100% rename from recent-onbuild/entrypoint.sh rename to 3.6-onbuild/entrypoint.sh diff --git a/recent-slim/Dockerfile b/3.6-slim/Dockerfile similarity index 100% rename from recent-slim/Dockerfile rename to 3.6-slim/Dockerfile diff --git a/recent-slim/entrypoint.sh b/3.6-slim/entrypoint.sh similarity index 100% rename from recent-slim/entrypoint.sh rename to 3.6-slim/entrypoint.sh diff --git a/3.6/Dockerfile b/3.6/Dockerfile new file mode 100644 index 0000000..6939fd4 --- /dev/null +++ b/3.6/Dockerfile @@ -0,0 +1,89 @@ +FROM alpine:3.7 + +# VERSIONS +ENV ALPINE_VERSION=3.7 \ + PYTHON_VERSION=3.6.5 + +# PATHS +ENV PYTHON_PATH=/usr/lib/python$PYTHON_VERSION \ + PATH="/usr/lib/python$PYTHON_VERSION/bin/:${PATH}" + +# PACKAGES +# * dumb-init: a proper init system for containers, to reap zombie children +# * musl: standard C library +# * lib6-compat: compatibility libraries for glibc +# * linux-headers: commonly needed, and an unusual package name from Alpine. +# * build-base: used so we include the basic development packages (gcc) +# * bash: so we can access /bin/bash +# * git: to ease up clones of repos +# * ca-certificates: for SSL verification during Pip and easy_install +ENV PACKAGES="\ + dumb-init \ + musl \ + libc6-compat \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ +" + +# PACKAGES needed to built python +ENV PYTHON_BUILD_PACKAGES="\ + readline-dev \ + zlib-dev \ + bzip2-dev \ + sqlite-dev \ + libressl-dev \ +" + +RUN set -ex ;\ + # find MAJOR and MINOR python versions based on $PYTHON_VERSION + export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ + export PYTHON_MINOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f2- | rev) ;\ + # replacing default repositories with edge ones + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories ;\ + + # Add the packages, with a CDN-breakage fallback if needed + apk add --no-cache $PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) ;\ + # Add packages just for the python build process with a CDN-breakage fallback if needed + apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES) ;\ + + # turn back the clock -- so hacky! + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories ;\ + # echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ + # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ + + # use pyenv to download and compile specific python version + git clone --depth 1 https://github.com/pyenv/pyenv /usr/lib/pyenv ;\ + PYENV_ROOT=/usr/lib/pyenv /usr/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # move specific version to correct path delete pyenv, no longer needed + mv /usr/lib/pyenv/versions/$PYTHON_VERSION/ $PYTHON_PATH ;\ + rm -rfv /usr/lib/pyenv ;\ + # change the path on the header of every file from PYENV_ROOT to PYTHON_PATH + cd $PYTHON_PATH/bin/ && sed -i "s+/usr/lib/pyenv/versions/$PYTHON_VERSION/+$PYTHON_PATH/+g" * ;\ + # delete binary "duplicates" and replace them with symlinks + # this also optimizes space since they are actually the same binary + rm -f $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION \ + $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION \ + $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config \ + $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION ;\ + ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION ;\ + ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config ;\ + ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + # delete files to to reduce container size + # tips taken from main python docker repo + find /usr/lib/python$PYTHON_VERSION -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + + # remove build dependencies and any leftover apk cache + apk del --no-cache --purge .build-deps ;\ + rm -rf /var/cache/apk/* + +# since we will be "always" mounting the volume, we can set this up +ENTRYPOINT ["/usr/bin/dumb-init"] +CMD ["python"] diff --git a/README.md b/README.md index a26b29e..a34e621 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ A small Python Docker image based on [Alpine Linux](http://alpinelinux.org/). - `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? -The default docker python images are too [big](https://github.com/docker-library/python/issues/45), much larger than they need to be. Hence I built this simple image based on [docker-alpine](https://github.com/gliderlabs/docker-alpine), that has everything needed for the most common python projects - including `python3-dev` (which is not common in most minimal alpine python packages). +The default docker python images are too [big](https://github.com/docker-library/python/issues/45), much larger than they need to be. Hence I built this simple image based on [docker-alpine](https://github.com/gliderlabs/docker-alpine), that has everything needed for the most common python projects - including `python-dev` (which is not common in most minimal alpine python packages). |REPOSITORY|TAG|SIZE| |-|-|-| @@ -55,7 +55,7 @@ The default docker python images are too [big](https://github.com/docker-library |jfloff/alpine-python|recent-slim|55.7MB| |python|3.6-slim|156MB| |||| -|jfloff/alpine-python|recent|239MB| +|jfloff/alpine-python|recent|268MB| |python|3.6|692MB| |python|3.6-alpine|92.1MB| @@ -199,6 +199,18 @@ You can also access `bash` inside the container: docker run --rm -ti jfloff/alpine-python:2.7-slim bash ``` +## Ecosystem + +These are some of the images that use `jfloff/alpine-python` as base image. *If you have another image that uses this as base image, please submit an issue or PR for it to be added. Image has to be published on Docker Hub.* + +- **[jfloff/alscipy](https://github.com/jfloff/docker-alscipy)** [![Docker Stars](https://img.shields.io/docker/stars/jfloff/alscipy.svg)][alscipy-hub] [![Docker Pulls](https://img.shields.io/docker/pulls/jfloff/alscipy.svg)][alscipy-hub] : image with common packages for Science in Alpine Python. + + +[alscipy-hub]: https://hub.docker.com/r/jfloff/alscipy/ + + + + ## License The code in this repository, unless otherwise noted, is MIT licensed. See the `LICENSE` file in this repository. diff --git a/recent-onbuild/Dockerfile b/recent-onbuild/Dockerfile deleted file mode 100644 index 404783c..0000000 --- a/recent-onbuild/Dockerfile +++ /dev/null @@ -1,70 +0,0 @@ -FROM alpine:3.7 - -ENV ALPINE_VERSION=3.7 - -# Install needed packages. Notes: -# * dumb-init: a proper init system for containers, to reap zombie children -# * musl: standard C library -# * lib6-compat: compatibility libraries for glibc -# * linux-headers: commonly needed, and an unusual package name from Alpine. -# * build-base: used so we include the basic development packages (gcc) -# * bash: so we can access /bin/bash -# * git: to ease up clones of repos -# * ca-certificates: for SSL verification during Pip and easy_install -# * python: the binaries themselves -# * python-dev: are used for gevent e.g. -ENV PACKAGES="\ - dumb-init \ - musl \ - libc6-compat \ - linux-headers \ - build-base \ - bash \ - git \ - ca-certificates \ - python3 \ - python3-dev \ -" - -RUN echo \ - # replacing default repositories with edge ones - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" > /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories \ - - # Add the packages, with a CDN-breakage fallback if needed - && apk add --no-cache $PACKAGES || \ - (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ - - # turn back the clock -- so hacky! - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ - # && echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ - # && echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories \ - # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ - - # make some useful symlinks that are expected to exist - && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi \ - && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python3-config /usr/bin/python-config; fi \ - && if [[ ! -e /usr/bin/pydoc ]]; then ln -sf /usr/bin/pydoc3 /usr/bin/pydoc; fi \ - && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf $(ls /usr/bin/easy_install*) /usr/bin/easy_install; fi \ - - # Install and upgrade Pip - && easy_install pip \ - && pip install --upgrade pip \ - && if [[ ! -e /usr/bin/pip ]]; then ln -sf /usr/bin/pip3 /usr/bin/pip; fi - -# Copy in the entrypoint script -- this installs prerequisites on container start. -COPY entrypoint.sh /entrypoint.sh - -# install requirements -# this way when you build you won't need to install again -# and since COPY is cached we don't need to wait -ONBUILD COPY requirements.txt /tmp/requirements.txt - -# Run the dependencies installer and then allow it to be run again if needed. -ONBUILD RUN /entrypoint.sh -r /tmp/requirements.txt -ONBUILD RUN rm -f /requirements.installed - -# since we will be "always" mounting the volume, we can set this up -ENTRYPOINT ["/usr/bin/dumb-init"] -CMD ["python"] \ No newline at end of file diff --git a/recent/Dockerfile b/recent/Dockerfile deleted file mode 100644 index 395d041..0000000 --- a/recent/Dockerfile +++ /dev/null @@ -1,58 +0,0 @@ -FROM alpine:3.7 - -ENV ALPINE_VERSION=3.7 - -# Install needed packages. Notes: -# * dumb-init: a proper init system for containers, to reap zombie children -# * musl: standard C library -# * lib6-compat: compatibility libraries for glibc -# * linux-headers: commonly needed, and an unusual package name from Alpine. -# * build-base: used so we include the basic development packages (gcc) -# * bash: so we can access /bin/bash -# * git: to ease up clones of repos -# * ca-certificates: for SSL verification during Pip and easy_install -# * python: the binaries themselves -# * python-dev: are used for gevent e.g. -ENV PACKAGES="\ - dumb-init \ - musl \ - libc6-compat \ - linux-headers \ - build-base \ - bash \ - git \ - ca-certificates \ - python3 \ - python3-dev \ -" - -RUN echo \ - # replacing default repositories with edge ones - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" > /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories \ - - # Add the packages, with a CDN-breakage fallback if needed - && apk add --no-cache $PACKAGES || \ - (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ - - # turn back the clock -- so hacky! - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ - # && echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ - # && echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories \ - # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ - - # make some useful symlinks that are expected to exist - && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi \ - && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python3-config /usr/bin/python-config; fi \ - && if [[ ! -e /usr/bin/pydoc ]]; then ln -sf /usr/bin/pydoc3 /usr/bin/pydoc; fi \ - && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf $(ls /usr/bin/easy_install*) /usr/bin/easy_install; fi \ - - # Install and upgrade Pip - && easy_install pip \ - && pip install --upgrade pip \ - && if [[ ! -e /usr/bin/pip ]]; then ln -sf /usr/bin/pip3 /usr/bin/pip; fi - -# since we will be "always" mounting the volume, we can set this up -ENTRYPOINT ["/usr/bin/dumb-init"] -CMD ["python"] From 6f93a57915805ff1d7f62d51df668bda9d105b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Loff?= Date: Sun, 6 May 2018 22:17:04 +0100 Subject: [PATCH 17/55] Update README and travis file --- .travis.yml | 6 +++--- README.md | 15 +++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index fc6aa87..a09fdfb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,9 +17,9 @@ env: - version='2.7' type='' - version='2.7' type='-onbuild' - version='2.7' type='-slim' - - version='recent' type='' - - version='recent' type='-onbuild' - - version='recent' type='-slim' + - version='3.6' type='' + - version='3.6' type='-onbuild' + - version='3.6' type='-slim' before_script: - sudo docker pull $alpine_image diff --git a/README.md b/README.md index a34e621..830a17c 100644 --- a/README.md +++ b/README.md @@ -32,12 +32,11 @@ A small Python Docker image based on [Alpine Linux](http://alpinelinux.org/). * **`2.7` ([2.7/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/2.7/Dockerfile))** * **`2.7-onbuild` ([2.7-onbuild/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/2.7-onbuild/Dockerfile))** * **`2.7-slim` ([2.7-slim/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/2.7-slim/Dockerfile))** -* **`recent` `latest` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/recent/Dockerfile))** -* **`recent-onbuild` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/recent-onbuild/Dockerfile))** -* **`recent-slim` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/recent-slim/Dockerfile))** +* **`3.6` `latest` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.6/Dockerfile))** +* **`3.6-onbuild` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.6-onbuild/Dockerfile))** +* **`3.6-slim` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.6-slim/Dockerfile))** **NOTES:** -- `recent` tags are the default `python3` version that Alpine current offers. **_Current recent is `3.6`_**. - `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? @@ -45,17 +44,17 @@ The default docker python images are too [big](https://github.com/docker-library |REPOSITORY|TAG|SIZE| |-|-|-| -|jfloff/alpine-python|2.7-slim|52.8MB| +|jfloff/alpine-python|2.7-slim|55MB| |python|2.7-slim|138MB| |||| |jfloff/alpine-python|2.7|232MB| |python|2.7-alpine|75.3MB| |python|2.7|681MB| |||| -|jfloff/alpine-python|recent-slim|55.7MB| +|jfloff/alpine-python|3.6-slim|58.1MB| |python|3.6-slim|156MB| |||| -|jfloff/alpine-python|recent|268MB| +|jfloff/alpine-python|3.6|268MB| |python|3.6|692MB| |python|3.6-alpine|92.1MB| @@ -83,7 +82,7 @@ docker run --rm -ti jfloff/alpine-python bash These images can be used to bake your dependencies into an image by extending the plain python images. To do so, create a custom `Dockerfile` like this: ```dockerfile -FROM jfloff/alpine-python:recent-onbuild +FROM jfloff/alpine-python:3.6-onbuild # for a flask server EXPOSE 5000 From ec08615d37b6b9994c2d69c96ec008717d25fd09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Loff?= Date: Sun, 6 May 2018 23:07:47 +0100 Subject: [PATCH 18/55] Update command with password-stdin --- .travis/push.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/push.sh b/.travis/push.sh index d9de0e8..f07bf44 100755 --- a/.travis/push.sh +++ b/.travis/push.sh @@ -9,7 +9,7 @@ if [[ "$TRAVIS_BRANCH" == "master" ]]; then echo "Skipping Docker push, no credentials specified." PUSH=0 else - sudo docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD ; + echo "$DOCKER_PASSWORD" | sudo docker login -u "$DOCKER_USERNAME" --password-stdin fi if [[ "$PUSH" -eq 1 ]]; then From 7ded5d81ac8dd38d855a902ee291517dfb99f4dd Mon Sep 17 00:00:00 2001 From: Trevor Robinson Date: Thu, 24 May 2018 13:05:14 -0700 Subject: [PATCH 19/55] For #26 - Adds some additional logging and options for verbosity. --- 2.7-onbuild/entrypoint.sh | 54 ++++++++++++++++++++++++++++++++------- 2.7-slim/Dockerfile | 2 -- 2.7-slim/entrypoint.sh | 54 ++++++++++++++++++++++++++++++++------- 3.6-onbuild/Dockerfile | 2 +- 3.6-onbuild/entrypoint.sh | 54 ++++++++++++++++++++++++++++++++------- 3.6-slim/Dockerfile | 2 -- 3.6-slim/entrypoint.sh | 54 ++++++++++++++++++++++++++++++++------- 7 files changed, 181 insertions(+), 41 deletions(-) diff --git a/2.7-onbuild/entrypoint.sh b/2.7-onbuild/entrypoint.sh index 7ab3f95..901491a 100755 --- a/2.7-onbuild/entrypoint.sh +++ b/2.7-onbuild/entrypoint.sh @@ -7,12 +7,13 @@ PIP_REQUIREMENTS=() APKFILE='/apk-requirements.txt' BUILDFILE='/build-requirements.txt' REQFILE='/requirements.txt' +VERBOSITY=1 TMP_REQFILE='/tmp/requirements.txt' function usage () { echo <<"EOF" -Usage: $0 [-a -b -p -A -B -P -r] [--] +Usage: $0 [-a -b -p -A -B -P -r -q -x] [--] -a : APK requirement. Can be specified multiple times. -b : APK build requirement. These will be removed at the end to save space. -p : Pip requirement. Can be specified multiple times. @@ -22,6 +23,9 @@ Usage: $0 [-a -b -p -A -B -P -r] [--] -P : requirements.txt file location, default: /requirements.txt -r : same as above, just to match Pip's -r flag. + -q : quiet, doesn't print anything at all. + -x : Bash debug mode. Extremely verbose! + -- : Separator for flags and your command Whatever you provide after your arguments is run at the end. @@ -29,8 +33,14 @@ EOF exit 1 } +function vlog () { + if [ $VERBOSITY -gt 0 ]; then + echo $1 + fi +} + # Get and process arguments -while getopts ":a:b:p:A:B:P:r:" opt; do +while getopts ":a:b:p:A:B:P:r:qx" opt; do case $opt in a) APK_REQUIREMENTS+=("$OPTARG") ;; b) BUILD_REQUIREMENTS+=("$OPTARG") ;; @@ -38,7 +48,9 @@ while getopts ":a:b:p:A:B:P:r:" opt; do A) APKFILE="$OPTARG" ;; B) BUILDFILE="$OPTARG" ;; P) REQFILE="$OPTARG" ;; - r) REQFILE="$OPTARG" ;; + r) REQFILE="$OPTARG" ;; + q) VERBOSITY=0 ;; + x) set -x ;; \?) echo "Invalid option: -$OPTARG" >&2 usage @@ -62,26 +74,46 @@ shift $((OPTIND-1)) # If there's a double dash at the end, get that off [[ $1 = "--" ]] && shift +# Make some common flags objects +PIP_FLAGS='' +if [ $VERBOSITY -eq 0 ]; then + PIP_FLAGS="$PIP_FLAGS -q" +fi + +APK_FLAGS='--no-cache --no-progress' +if [ $VERBOSITY -eq 0 ]; then + APK_FLAGS="$APK_FLAGS -q" +fi + # Don't do anything if we've already done this. if [[ ! -f /requirements.installed ]]; then + vlog "First run, checking for any requirements..." # Install any APK requirements if [[ -f "$APKFILE" ]]; then + vlog "APK requirements file detected!" APK_REQUIREMENTS+=($( cat "$APKFILE" )) fi if [[ -f "$BUILDFILE" ]]; then + vlog "Build requirements file detected!" BUILD_REQUIREMENTS+=($( cat "$BUILDFILE" )) fi # Unfortunately the Alpine repositories are in a slightly inconsistent state for now-- python2 only exists in 'edge', not main. # if [[ "$PYTHON_VERSION" == '2' ]]; then BUILD_PACKAGES="$(echo $BUILD_PACKAGES | sed -e 's/python2/python/g')"; fi \ - - apk add --no-cache $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" + vlog "Installing all APK requirements..." + apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" # Install any Pip requirements - TARGET_REQFILE="$REQFILE" + if [[ -f "$REQFILE" && "$(cat $REQFILE | wc -l)" -gt 0 ]]; then + # Do this check a little early-- since we merge cli in with file, + # we'd get a false positive for logging otherwise. + vlog "Pip requirements file detected!" + fi + # If we use CLI parameters, we'll have to reassign this. + TARGET_REQFILE="$REQFILE" if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then # Put all Pip requirements into the same file. printf "%s\n" "${PIP_REQUIREMENTS[@]}" >> "$TMP_REQFILE" @@ -94,14 +126,18 @@ if [[ ! -f /requirements.installed ]]; then fi if [[ -f $TARGET_REQFILE && "$(cat $TARGET_REQFILE | wc -l)" -gt 0 ]]; then - pip install --upgrade pip - pip install -r "$TARGET_REQFILE" + vlog "Upgrading Pip..." + pip install $PIP_FLAGS --upgrade pip + vlog "Installing all Pip requirements..." + pip install $PIP_FLAGS -r "$TARGET_REQFILE" fi # Remove packages that were only required for build. - apk del $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" + apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" touch /requirements.installed +else + vlog "/requirements.installed file exists-- skipping requirements installs." fi diff --git a/2.7-slim/Dockerfile b/2.7-slim/Dockerfile index e5244d4..f3a3920 100644 --- a/2.7-slim/Dockerfile +++ b/2.7-slim/Dockerfile @@ -49,14 +49,12 @@ COPY entrypoint.sh /entrypoint.sh # These packages are not installed immediately, but are added at runtime or ONBUILD to shrink the image as much as possible. Notes: # * build-base: used so we include the basic development packages (gcc) # * linux-headers: commonly needed, and an unusual package name from Alpine. -# * musl: standard C library # * lib6-compat: compatibility libraries for glibc # * python2-dev: are used for gevent e.g. # * git: to ease up clones of repos ENV BUILD_PACKAGES="\ build-base \ linux-headers \ - musl \ libc6-compat \ python2-dev \ git \ diff --git a/2.7-slim/entrypoint.sh b/2.7-slim/entrypoint.sh index 7ab3f95..901491a 100755 --- a/2.7-slim/entrypoint.sh +++ b/2.7-slim/entrypoint.sh @@ -7,12 +7,13 @@ PIP_REQUIREMENTS=() APKFILE='/apk-requirements.txt' BUILDFILE='/build-requirements.txt' REQFILE='/requirements.txt' +VERBOSITY=1 TMP_REQFILE='/tmp/requirements.txt' function usage () { echo <<"EOF" -Usage: $0 [-a -b -p -A -B -P -r] [--] +Usage: $0 [-a -b -p -A -B -P -r -q -x] [--] -a : APK requirement. Can be specified multiple times. -b : APK build requirement. These will be removed at the end to save space. -p : Pip requirement. Can be specified multiple times. @@ -22,6 +23,9 @@ Usage: $0 [-a -b -p -A -B -P -r] [--] -P : requirements.txt file location, default: /requirements.txt -r : same as above, just to match Pip's -r flag. + -q : quiet, doesn't print anything at all. + -x : Bash debug mode. Extremely verbose! + -- : Separator for flags and your command Whatever you provide after your arguments is run at the end. @@ -29,8 +33,14 @@ EOF exit 1 } +function vlog () { + if [ $VERBOSITY -gt 0 ]; then + echo $1 + fi +} + # Get and process arguments -while getopts ":a:b:p:A:B:P:r:" opt; do +while getopts ":a:b:p:A:B:P:r:qx" opt; do case $opt in a) APK_REQUIREMENTS+=("$OPTARG") ;; b) BUILD_REQUIREMENTS+=("$OPTARG") ;; @@ -38,7 +48,9 @@ while getopts ":a:b:p:A:B:P:r:" opt; do A) APKFILE="$OPTARG" ;; B) BUILDFILE="$OPTARG" ;; P) REQFILE="$OPTARG" ;; - r) REQFILE="$OPTARG" ;; + r) REQFILE="$OPTARG" ;; + q) VERBOSITY=0 ;; + x) set -x ;; \?) echo "Invalid option: -$OPTARG" >&2 usage @@ -62,26 +74,46 @@ shift $((OPTIND-1)) # If there's a double dash at the end, get that off [[ $1 = "--" ]] && shift +# Make some common flags objects +PIP_FLAGS='' +if [ $VERBOSITY -eq 0 ]; then + PIP_FLAGS="$PIP_FLAGS -q" +fi + +APK_FLAGS='--no-cache --no-progress' +if [ $VERBOSITY -eq 0 ]; then + APK_FLAGS="$APK_FLAGS -q" +fi + # Don't do anything if we've already done this. if [[ ! -f /requirements.installed ]]; then + vlog "First run, checking for any requirements..." # Install any APK requirements if [[ -f "$APKFILE" ]]; then + vlog "APK requirements file detected!" APK_REQUIREMENTS+=($( cat "$APKFILE" )) fi if [[ -f "$BUILDFILE" ]]; then + vlog "Build requirements file detected!" BUILD_REQUIREMENTS+=($( cat "$BUILDFILE" )) fi # Unfortunately the Alpine repositories are in a slightly inconsistent state for now-- python2 only exists in 'edge', not main. # if [[ "$PYTHON_VERSION" == '2' ]]; then BUILD_PACKAGES="$(echo $BUILD_PACKAGES | sed -e 's/python2/python/g')"; fi \ - - apk add --no-cache $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" + vlog "Installing all APK requirements..." + apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" # Install any Pip requirements - TARGET_REQFILE="$REQFILE" + if [[ -f "$REQFILE" && "$(cat $REQFILE | wc -l)" -gt 0 ]]; then + # Do this check a little early-- since we merge cli in with file, + # we'd get a false positive for logging otherwise. + vlog "Pip requirements file detected!" + fi + # If we use CLI parameters, we'll have to reassign this. + TARGET_REQFILE="$REQFILE" if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then # Put all Pip requirements into the same file. printf "%s\n" "${PIP_REQUIREMENTS[@]}" >> "$TMP_REQFILE" @@ -94,14 +126,18 @@ if [[ ! -f /requirements.installed ]]; then fi if [[ -f $TARGET_REQFILE && "$(cat $TARGET_REQFILE | wc -l)" -gt 0 ]]; then - pip install --upgrade pip - pip install -r "$TARGET_REQFILE" + vlog "Upgrading Pip..." + pip install $PIP_FLAGS --upgrade pip + vlog "Installing all Pip requirements..." + pip install $PIP_FLAGS -r "$TARGET_REQFILE" fi # Remove packages that were only required for build. - apk del $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" + apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" touch /requirements.installed +else + vlog "/requirements.installed file exists-- skipping requirements installs." fi diff --git a/3.6-onbuild/Dockerfile b/3.6-onbuild/Dockerfile index dc09087..52aaa23 100644 --- a/3.6-onbuild/Dockerfile +++ b/3.6-onbuild/Dockerfile @@ -98,4 +98,4 @@ ONBUILD RUN rm -f /requirements.installed # since we will be "always" mounting the volume, we can set this up ENTRYPOINT ["/usr/bin/dumb-init"] -CMD ["python"] \ No newline at end of file +CMD ["python"] diff --git a/3.6-onbuild/entrypoint.sh b/3.6-onbuild/entrypoint.sh index 7ab3f95..901491a 100755 --- a/3.6-onbuild/entrypoint.sh +++ b/3.6-onbuild/entrypoint.sh @@ -7,12 +7,13 @@ PIP_REQUIREMENTS=() APKFILE='/apk-requirements.txt' BUILDFILE='/build-requirements.txt' REQFILE='/requirements.txt' +VERBOSITY=1 TMP_REQFILE='/tmp/requirements.txt' function usage () { echo <<"EOF" -Usage: $0 [-a -b -p -A -B -P -r] [--] +Usage: $0 [-a -b -p -A -B -P -r -q -x] [--] -a : APK requirement. Can be specified multiple times. -b : APK build requirement. These will be removed at the end to save space. -p : Pip requirement. Can be specified multiple times. @@ -22,6 +23,9 @@ Usage: $0 [-a -b -p -A -B -P -r] [--] -P : requirements.txt file location, default: /requirements.txt -r : same as above, just to match Pip's -r flag. + -q : quiet, doesn't print anything at all. + -x : Bash debug mode. Extremely verbose! + -- : Separator for flags and your command Whatever you provide after your arguments is run at the end. @@ -29,8 +33,14 @@ EOF exit 1 } +function vlog () { + if [ $VERBOSITY -gt 0 ]; then + echo $1 + fi +} + # Get and process arguments -while getopts ":a:b:p:A:B:P:r:" opt; do +while getopts ":a:b:p:A:B:P:r:qx" opt; do case $opt in a) APK_REQUIREMENTS+=("$OPTARG") ;; b) BUILD_REQUIREMENTS+=("$OPTARG") ;; @@ -38,7 +48,9 @@ while getopts ":a:b:p:A:B:P:r:" opt; do A) APKFILE="$OPTARG" ;; B) BUILDFILE="$OPTARG" ;; P) REQFILE="$OPTARG" ;; - r) REQFILE="$OPTARG" ;; + r) REQFILE="$OPTARG" ;; + q) VERBOSITY=0 ;; + x) set -x ;; \?) echo "Invalid option: -$OPTARG" >&2 usage @@ -62,26 +74,46 @@ shift $((OPTIND-1)) # If there's a double dash at the end, get that off [[ $1 = "--" ]] && shift +# Make some common flags objects +PIP_FLAGS='' +if [ $VERBOSITY -eq 0 ]; then + PIP_FLAGS="$PIP_FLAGS -q" +fi + +APK_FLAGS='--no-cache --no-progress' +if [ $VERBOSITY -eq 0 ]; then + APK_FLAGS="$APK_FLAGS -q" +fi + # Don't do anything if we've already done this. if [[ ! -f /requirements.installed ]]; then + vlog "First run, checking for any requirements..." # Install any APK requirements if [[ -f "$APKFILE" ]]; then + vlog "APK requirements file detected!" APK_REQUIREMENTS+=($( cat "$APKFILE" )) fi if [[ -f "$BUILDFILE" ]]; then + vlog "Build requirements file detected!" BUILD_REQUIREMENTS+=($( cat "$BUILDFILE" )) fi # Unfortunately the Alpine repositories are in a slightly inconsistent state for now-- python2 only exists in 'edge', not main. # if [[ "$PYTHON_VERSION" == '2' ]]; then BUILD_PACKAGES="$(echo $BUILD_PACKAGES | sed -e 's/python2/python/g')"; fi \ - - apk add --no-cache $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" + vlog "Installing all APK requirements..." + apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" # Install any Pip requirements - TARGET_REQFILE="$REQFILE" + if [[ -f "$REQFILE" && "$(cat $REQFILE | wc -l)" -gt 0 ]]; then + # Do this check a little early-- since we merge cli in with file, + # we'd get a false positive for logging otherwise. + vlog "Pip requirements file detected!" + fi + # If we use CLI parameters, we'll have to reassign this. + TARGET_REQFILE="$REQFILE" if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then # Put all Pip requirements into the same file. printf "%s\n" "${PIP_REQUIREMENTS[@]}" >> "$TMP_REQFILE" @@ -94,14 +126,18 @@ if [[ ! -f /requirements.installed ]]; then fi if [[ -f $TARGET_REQFILE && "$(cat $TARGET_REQFILE | wc -l)" -gt 0 ]]; then - pip install --upgrade pip - pip install -r "$TARGET_REQFILE" + vlog "Upgrading Pip..." + pip install $PIP_FLAGS --upgrade pip + vlog "Installing all Pip requirements..." + pip install $PIP_FLAGS -r "$TARGET_REQFILE" fi # Remove packages that were only required for build. - apk del $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" + apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" touch /requirements.installed +else + vlog "/requirements.installed file exists-- skipping requirements installs." fi diff --git a/3.6-slim/Dockerfile b/3.6-slim/Dockerfile index 448d1fc..b4c5389 100644 --- a/3.6-slim/Dockerfile +++ b/3.6-slim/Dockerfile @@ -49,14 +49,12 @@ COPY entrypoint.sh /entrypoint.sh # These packages are not installed immediately, but are added at runtime or ONBUILD to shrink the image as much as possible. Notes: # * build-base: used so we include the basic development packages (gcc) # * linux-headers: commonly needed, and an unusual package name from Alpine. -# * musl: standard C library # * lib6-compat: compatibility libraries for glibc # * python3-dev: are used for gevent e.g. # * git: to ease up clones of repos ENV BUILD_PACKAGES="\ build-base \ linux-headers \ - musl \ libc6-compat \ python3-dev \ git \ diff --git a/3.6-slim/entrypoint.sh b/3.6-slim/entrypoint.sh index 7ab3f95..901491a 100755 --- a/3.6-slim/entrypoint.sh +++ b/3.6-slim/entrypoint.sh @@ -7,12 +7,13 @@ PIP_REQUIREMENTS=() APKFILE='/apk-requirements.txt' BUILDFILE='/build-requirements.txt' REQFILE='/requirements.txt' +VERBOSITY=1 TMP_REQFILE='/tmp/requirements.txt' function usage () { echo <<"EOF" -Usage: $0 [-a -b -p -A -B -P -r] [--] +Usage: $0 [-a -b -p -A -B -P -r -q -x] [--] -a : APK requirement. Can be specified multiple times. -b : APK build requirement. These will be removed at the end to save space. -p : Pip requirement. Can be specified multiple times. @@ -22,6 +23,9 @@ Usage: $0 [-a -b -p -A -B -P -r] [--] -P : requirements.txt file location, default: /requirements.txt -r : same as above, just to match Pip's -r flag. + -q : quiet, doesn't print anything at all. + -x : Bash debug mode. Extremely verbose! + -- : Separator for flags and your command Whatever you provide after your arguments is run at the end. @@ -29,8 +33,14 @@ EOF exit 1 } +function vlog () { + if [ $VERBOSITY -gt 0 ]; then + echo $1 + fi +} + # Get and process arguments -while getopts ":a:b:p:A:B:P:r:" opt; do +while getopts ":a:b:p:A:B:P:r:qx" opt; do case $opt in a) APK_REQUIREMENTS+=("$OPTARG") ;; b) BUILD_REQUIREMENTS+=("$OPTARG") ;; @@ -38,7 +48,9 @@ while getopts ":a:b:p:A:B:P:r:" opt; do A) APKFILE="$OPTARG" ;; B) BUILDFILE="$OPTARG" ;; P) REQFILE="$OPTARG" ;; - r) REQFILE="$OPTARG" ;; + r) REQFILE="$OPTARG" ;; + q) VERBOSITY=0 ;; + x) set -x ;; \?) echo "Invalid option: -$OPTARG" >&2 usage @@ -62,26 +74,46 @@ shift $((OPTIND-1)) # If there's a double dash at the end, get that off [[ $1 = "--" ]] && shift +# Make some common flags objects +PIP_FLAGS='' +if [ $VERBOSITY -eq 0 ]; then + PIP_FLAGS="$PIP_FLAGS -q" +fi + +APK_FLAGS='--no-cache --no-progress' +if [ $VERBOSITY -eq 0 ]; then + APK_FLAGS="$APK_FLAGS -q" +fi + # Don't do anything if we've already done this. if [[ ! -f /requirements.installed ]]; then + vlog "First run, checking for any requirements..." # Install any APK requirements if [[ -f "$APKFILE" ]]; then + vlog "APK requirements file detected!" APK_REQUIREMENTS+=($( cat "$APKFILE" )) fi if [[ -f "$BUILDFILE" ]]; then + vlog "Build requirements file detected!" BUILD_REQUIREMENTS+=($( cat "$BUILDFILE" )) fi # Unfortunately the Alpine repositories are in a slightly inconsistent state for now-- python2 only exists in 'edge', not main. # if [[ "$PYTHON_VERSION" == '2' ]]; then BUILD_PACKAGES="$(echo $BUILD_PACKAGES | sed -e 's/python2/python/g')"; fi \ - - apk add --no-cache $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" + vlog "Installing all APK requirements..." + apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" # Install any Pip requirements - TARGET_REQFILE="$REQFILE" + if [[ -f "$REQFILE" && "$(cat $REQFILE | wc -l)" -gt 0 ]]; then + # Do this check a little early-- since we merge cli in with file, + # we'd get a false positive for logging otherwise. + vlog "Pip requirements file detected!" + fi + # If we use CLI parameters, we'll have to reassign this. + TARGET_REQFILE="$REQFILE" if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then # Put all Pip requirements into the same file. printf "%s\n" "${PIP_REQUIREMENTS[@]}" >> "$TMP_REQFILE" @@ -94,14 +126,18 @@ if [[ ! -f /requirements.installed ]]; then fi if [[ -f $TARGET_REQFILE && "$(cat $TARGET_REQFILE | wc -l)" -gt 0 ]]; then - pip install --upgrade pip - pip install -r "$TARGET_REQFILE" + vlog "Upgrading Pip..." + pip install $PIP_FLAGS --upgrade pip + vlog "Installing all Pip requirements..." + pip install $PIP_FLAGS -r "$TARGET_REQFILE" fi # Remove packages that were only required for build. - apk del $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" + apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" touch /requirements.installed +else + vlog "/requirements.installed file exists-- skipping requirements installs." fi From dfa744113615c0448a6bdbaf4119e7924feda66c Mon Sep 17 00:00:00 2001 From: Trevor Robinson Date: Thu, 24 May 2018 13:10:37 -0700 Subject: [PATCH 20/55] Add docs --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 830a17c..cf83f0f 100644 --- a/README.md +++ b/README.md @@ -193,11 +193,18 @@ CMD ["ajenti-panel"] #### Debugging The `/entrypoint.sh` script that manages dependencies in the slim images creates an empty file, `/requirements.installed`, telling the script not to install any dependencies after the container's first run. Removing this file will allow the script to work again if it is needed. +You can use the `-x` flag to see everything the `/entrypoint.sh` script is doing. + You can also access `bash` inside the container: ```shell docker run --rm -ti jfloff/alpine-python:2.7-slim bash ``` +#### Additional Arguments + +`-q`: silences output from `/entrypoint.sh` +`-x`: turns on Bash debugging, making the output very verbose. + ## Ecosystem These are some of the images that use `jfloff/alpine-python` as base image. *If you have another image that uses this as base image, please submit an issue or PR for it to be added. Image has to be published on Docker Hub.* From 0e4b60f3580896f530166a975272ae9dec651611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Fr=C3=B6schlin?= Date: Thu, 18 Oct 2018 13:07:32 +0200 Subject: [PATCH 21/55] bump alpine and python version --- 2.7-onbuild/Dockerfile | 12 ++++-------- 2.7-slim/Dockerfile | 8 ++------ 2.7/Dockerfile | 12 ++++-------- 3.6-onbuild/Dockerfile | 10 +++------- 3.6-slim/Dockerfile | 8 ++------ 3.6/Dockerfile | 12 ++++-------- 6 files changed, 19 insertions(+), 43 deletions(-) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 851d3b1..4304a42 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -1,8 +1,8 @@ -FROM alpine:3.7 +FROM alpine:3.8 # VERSIONS -ENV ALPINE_VERSION=3.7 \ - PYTHON_VERSION=2.7.14 +ENV ALPINE_VERSION=3.8 \ + PYTHON_VERSION=2.7.15 # PATHS ENV PYTHON_PATH=/usr/lib/python$PYTHON_VERSION \ @@ -34,7 +34,7 @@ ENV PYTHON_BUILD_PACKAGES="\ zlib-dev \ bzip2-dev \ sqlite-dev \ - libressl-dev \ + openssl-dev \ " RUN set -ex ;\ @@ -44,20 +44,17 @@ RUN set -ex ;\ # replacing default repositories with edge ones echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories ;\ - # Add the packages, with a CDN-breakage fallback if needed apk add --no-cache $PACKAGES || \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) ;\ # Add packages just for the python build process with a CDN-breakage fallback if needed apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES || \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES) ;\ - # turn back the clock -- so hacky! echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories ;\ # echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ - # use pyenv to download and compile specific python version git clone --depth 1 https://github.com/pyenv/pyenv /usr/lib/pyenv ;\ PYENV_ROOT=/usr/lib/pyenv /usr/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ @@ -79,7 +76,6 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/lib/python$PYTHON_VERSION -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ - # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/2.7-slim/Dockerfile b/2.7-slim/Dockerfile index f3a3920..19d96a3 100644 --- a/2.7-slim/Dockerfile +++ b/2.7-slim/Dockerfile @@ -1,6 +1,6 @@ -FROM alpine:3.7 +FROM alpine:3.8 -ENV ALPINE_VERSION=3.7 +ENV ALPINE_VERSION=3.8 # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children @@ -21,22 +21,18 @@ RUN echo \ && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" > /etc/apk/repositories \ && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories \ - # Add the packages, with a CDN-breakage fallback if needed && apk add --no-cache $PACKAGES || \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ - # turn back the clock -- so hacky! && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ # && echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ # && echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories \ # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ - # make some useful symlinks that are expected to exist && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python2.7 /usr/bin/python; fi \ && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python2.7-config /usr/bin/python-config; fi \ && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf /usr/bin/easy_install-2.7 /usr/bin/easy_install; fi \ - # Install and upgrade Pip && easy_install pip \ && pip install --upgrade pip \ diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 83a6a6e..e697512 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -1,8 +1,8 @@ -FROM alpine:3.7 +FROM alpine:3.8 # VERSIONS -ENV ALPINE_VERSION=3.7 \ - PYTHON_VERSION=2.7.14 +ENV ALPINE_VERSION=3.8 \ + PYTHON_VERSION=2.7.15 # PATHS ENV PYTHON_PATH=/usr/lib/python$PYTHON_VERSION \ @@ -34,7 +34,7 @@ ENV PYTHON_BUILD_PACKAGES="\ zlib-dev \ bzip2-dev \ sqlite-dev \ - libressl-dev \ + openssl-dev \ " RUN set -ex ;\ @@ -44,20 +44,17 @@ RUN set -ex ;\ # replacing default repositories with edge ones echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories ;\ - # Add the packages, with a CDN-breakage fallback if needed apk add --no-cache $PACKAGES || \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) ;\ # Add packages just for the python build process with a CDN-breakage fallback if needed apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES || \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES) ;\ - # turn back the clock -- so hacky! echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories ;\ # echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ - # use pyenv to download and compile specific python version git clone --depth 1 https://github.com/pyenv/pyenv /usr/lib/pyenv ;\ PYENV_ROOT=/usr/lib/pyenv /usr/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ @@ -79,7 +76,6 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/lib/python$PYTHON_VERSION -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ - # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.6-onbuild/Dockerfile b/3.6-onbuild/Dockerfile index 52aaa23..e80ffd9 100644 --- a/3.6-onbuild/Dockerfile +++ b/3.6-onbuild/Dockerfile @@ -1,7 +1,7 @@ -FROM alpine:3.7 +FROM alpine:3.8 # VERSIONS -ENV ALPINE_VERSION=3.7 \ +ENV ALPINE_VERSION=3.8 \ PYTHON_VERSION=3.6.5 # PATHS @@ -34,7 +34,7 @@ ENV PYTHON_BUILD_PACKAGES="\ zlib-dev \ bzip2-dev \ sqlite-dev \ - libressl-dev \ + openssl-dev \ " RUN set -ex ;\ @@ -44,20 +44,17 @@ RUN set -ex ;\ # replacing default repositories with edge ones echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories ;\ - # Add the packages, with a CDN-breakage fallback if needed apk add --no-cache $PACKAGES || \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) ;\ # Add packages just for the python build process with a CDN-breakage fallback if needed apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES || \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES) ;\ - # turn back the clock -- so hacky! echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories ;\ # echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ - # use pyenv to download and compile specific python version git clone --depth 1 https://github.com/pyenv/pyenv /usr/lib/pyenv ;\ PYENV_ROOT=/usr/lib/pyenv /usr/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ @@ -79,7 +76,6 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/lib/python$PYTHON_VERSION -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ - # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.6-slim/Dockerfile b/3.6-slim/Dockerfile index b4c5389..c0ef390 100644 --- a/3.6-slim/Dockerfile +++ b/3.6-slim/Dockerfile @@ -1,6 +1,6 @@ -FROM alpine:3.7 +FROM alpine:3.8 -ENV ALPINE_VERSION=3.7 +ENV ALPINE_VERSION=3.8 # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children @@ -19,24 +19,20 @@ RUN echo \ && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" > /etc/apk/repositories \ && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories \ - # Add the packages, with a CDN-breakage fallback if needed && apk add --no-cache $PACKAGES || \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ - # turn back the clock -- so hacky! && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ # && echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ # && echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories \ # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ - # make some useful symlinks that are expected to exist && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi \ && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python-config3 /usr/bin/python-config; fi \ && if [[ ! -e /usr/bin/idle ]]; then ln -sf /usr/bin/idle3 /usr/bin/idle; fi \ && if [[ ! -e /usr/bin/pydoc ]]; then ln -sf /usr/bin/pydoc3 /usr/bin/pydoc; fi \ && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf $(ls /usr/bin/easy_install*) /usr/bin/easy_install; fi \ - # Install and upgrade Pip && easy_install pip \ && pip install --upgrade pip \ diff --git a/3.6/Dockerfile b/3.6/Dockerfile index 6939fd4..f2a6b7c 100644 --- a/3.6/Dockerfile +++ b/3.6/Dockerfile @@ -1,8 +1,8 @@ -FROM alpine:3.7 +FROM alpine:3.8 # VERSIONS -ENV ALPINE_VERSION=3.7 \ - PYTHON_VERSION=3.6.5 +ENV ALPINE_VERSION=3.8 \ + PYTHON_VERSION=3.6.6 # PATHS ENV PYTHON_PATH=/usr/lib/python$PYTHON_VERSION \ @@ -34,7 +34,7 @@ ENV PYTHON_BUILD_PACKAGES="\ zlib-dev \ bzip2-dev \ sqlite-dev \ - libressl-dev \ + openssl-dev \ " RUN set -ex ;\ @@ -44,20 +44,17 @@ RUN set -ex ;\ # replacing default repositories with edge ones echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories ;\ - # Add the packages, with a CDN-breakage fallback if needed apk add --no-cache $PACKAGES || \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) ;\ # Add packages just for the python build process with a CDN-breakage fallback if needed apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES || \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES) ;\ - # turn back the clock -- so hacky! echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories ;\ # echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ - # use pyenv to download and compile specific python version git clone --depth 1 https://github.com/pyenv/pyenv /usr/lib/pyenv ;\ PYENV_ROOT=/usr/lib/pyenv /usr/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ @@ -79,7 +76,6 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/lib/python$PYTHON_VERSION -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ - # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* From 92cea7fedbe78cc504cfdea79a99188feda34015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Fr=C3=B6schlin?= Date: Thu, 18 Oct 2018 13:12:32 +0200 Subject: [PATCH 22/55] add missing python version bump --- 3.6-onbuild/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3.6-onbuild/Dockerfile b/3.6-onbuild/Dockerfile index e80ffd9..43e37d3 100644 --- a/3.6-onbuild/Dockerfile +++ b/3.6-onbuild/Dockerfile @@ -2,7 +2,7 @@ FROM alpine:3.8 # VERSIONS ENV ALPINE_VERSION=3.8 \ - PYTHON_VERSION=3.6.5 + PYTHON_VERSION=3.6.6 # PATHS ENV PYTHON_PATH=/usr/lib/python$PYTHON_VERSION \ From 44aff04d57145642a3c84c511d63c3471abf8e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Fr=C3=B6schlin?= Date: Thu, 18 Oct 2018 13:17:23 +0200 Subject: [PATCH 23/55] Update alpine version in travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a09fdfb..02f303b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ before_install: env: global: - - alpine_image='alpine:3.7' + - alpine_image='alpine:3.8' - latest='recent' - repo='jfloff/alpine-python' matrix: From 85c776a7083fe1db5443ec4b117fe4429268bb53 Mon Sep 17 00:00:00 2001 From: qudongfang Date: Wed, 24 Oct 2018 11:40:39 +0800 Subject: [PATCH 24/55] Remove empty continuation lines. Empty continuation lines will become errors in a future release. --- 3.6/Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/3.6/Dockerfile b/3.6/Dockerfile index 6939fd4..79e7f6e 100644 --- a/3.6/Dockerfile +++ b/3.6/Dockerfile @@ -44,20 +44,20 @@ RUN set -ex ;\ # replacing default repositories with edge ones echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories ;\ - + # # Add the packages, with a CDN-breakage fallback if needed apk add --no-cache $PACKAGES || \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) ;\ # Add packages just for the python build process with a CDN-breakage fallback if needed apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES || \ (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES) ;\ - + # # turn back the clock -- so hacky! echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories ;\ # echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ - + # # use pyenv to download and compile specific python version git clone --depth 1 https://github.com/pyenv/pyenv /usr/lib/pyenv ;\ PYENV_ROOT=/usr/lib/pyenv /usr/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ @@ -79,7 +79,7 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/lib/python$PYTHON_VERSION -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ - + # # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* From e31a5b6b70a12c3b46f0ea511e136a5e622b0911 Mon Sep 17 00:00:00 2001 From: Niko Eckerskorn Date: Mon, 29 Oct 2018 14:56:21 +1100 Subject: [PATCH 25/55] Install required libssl1.0 dependency. Fixes jfloff/alpine-python#35. --- 2.7-onbuild/Dockerfile | 3 ++- 2.7/Dockerfile | 1 + 3.6-onbuild/Dockerfile | 1 + 3.6/Dockerfile | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 4304a42..863c1ee 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -26,6 +26,7 @@ ENV PACKAGES="\ bash \ git \ ca-certificates \ + libssl-1.0 \ " # PACKAGES needed to built python @@ -94,4 +95,4 @@ ONBUILD RUN rm -f /requirements.installed # since we will be "always" mounting the volume, we can set this up ENTRYPOINT ["/usr/bin/dumb-init"] -CMD ["python"] \ No newline at end of file +CMD ["python"] diff --git a/2.7/Dockerfile b/2.7/Dockerfile index e697512..3c2e6f5 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -26,6 +26,7 @@ ENV PACKAGES="\ bash \ git \ ca-certificates \ + libssl1.0 \ " # PACKAGES needed to built python diff --git a/3.6-onbuild/Dockerfile b/3.6-onbuild/Dockerfile index 43e37d3..4991644 100644 --- a/3.6-onbuild/Dockerfile +++ b/3.6-onbuild/Dockerfile @@ -26,6 +26,7 @@ ENV PACKAGES="\ bash \ git \ ca-certificates \ + libssl1.0 \ " # PACKAGES needed to built python diff --git a/3.6/Dockerfile b/3.6/Dockerfile index f2a6b7c..9e68253 100644 --- a/3.6/Dockerfile +++ b/3.6/Dockerfile @@ -26,6 +26,7 @@ ENV PACKAGES="\ bash \ git \ ca-certificates \ + libssl1.0 \ " # PACKAGES needed to built python From 6fa6b0783a1c3981ef14e0a6a2c7a21393746417 Mon Sep 17 00:00:00 2001 From: Niko Eckerskorn Date: Mon, 29 Oct 2018 15:14:02 +1100 Subject: [PATCH 26/55] Fix typo --- 2.7-onbuild/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 863c1ee..8fcd87c 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -26,7 +26,7 @@ ENV PACKAGES="\ bash \ git \ ca-certificates \ - libssl-1.0 \ + libssl1.0 \ " # PACKAGES needed to built python From 16d79d2b83608cdb5678fda11ebd3a41557439b6 Mon Sep 17 00:00:00 2001 From: Riley Chase Date: Wed, 9 Jan 2019 16:01:35 +1100 Subject: [PATCH 27/55] add support for python3.7.2 an additional package, libffi-dev, was required for the python3.7 build to complete successfully --- 3.7-onbuild/Dockerfile | 99 +++++++++++++++++++++++++ 3.7-onbuild/entrypoint.sh | 150 ++++++++++++++++++++++++++++++++++++++ 3.7/Dockerfile | 87 ++++++++++++++++++++++ 3 files changed, 336 insertions(+) create mode 100644 3.7-onbuild/Dockerfile create mode 100755 3.7-onbuild/entrypoint.sh create mode 100644 3.7/Dockerfile diff --git a/3.7-onbuild/Dockerfile b/3.7-onbuild/Dockerfile new file mode 100644 index 0000000..365f720 --- /dev/null +++ b/3.7-onbuild/Dockerfile @@ -0,0 +1,99 @@ +FROM alpine:3.8 + +# VERSIONS +ENV ALPINE_VERSION=3.8 \ + PYTHON_VERSION=3.7.2 + +# PATHS +ENV PYTHON_PATH=/usr/lib/python$PYTHON_VERSION \ + PATH="/usr/lib/python$PYTHON_VERSION/bin/:${PATH}" + +# PACKAGES +# * dumb-init: a proper init system for containers, to reap zombie children +# * musl: standard C library +# * lib6-compat: compatibility libraries for glibc +# * linux-headers: commonly needed, and an unusual package name from Alpine. +# * build-base: used so we include the basic development packages (gcc) +# * bash: so we can access /bin/bash +# * git: to ease up clones of repos +# * ca-certificates: for SSL verification during Pip and easy_install +ENV PACKAGES="\ + dumb-init \ + musl \ + libc6-compat \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ + libssl1.0 \ + libffi-dev \ +" + +# PACKAGES needed to built python +ENV PYTHON_BUILD_PACKAGES="\ + readline-dev \ + zlib-dev \ + bzip2-dev \ + sqlite-dev \ + openssl-dev \ +" + +RUN set -ex ;\ + # find MAJOR and MINOR python versions based on $PYTHON_VERSION + export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ + export PYTHON_MINOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f2- | rev) ;\ + # replacing default repositories with edge ones + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories ;\ + # Add the packages, with a CDN-breakage fallback if needed + apk add --no-cache $PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) ;\ + # Add packages just for the python build process with a CDN-breakage fallback if needed + apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES) ;\ + # turn back the clock -- so hacky! + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories ;\ + # echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ + # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ + # use pyenv to download and compile specific python version + git clone --depth 1 https://github.com/pyenv/pyenv /usr/lib/pyenv ;\ + PYENV_ROOT=/usr/lib/pyenv /usr/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # move specific version to correct path delete pyenv, no longer needed + mv /usr/lib/pyenv/versions/$PYTHON_VERSION/ $PYTHON_PATH ;\ + rm -rfv /usr/lib/pyenv ;\ + # change the path on the header of every file from PYENV_ROOT to PYTHON_PATH + cd $PYTHON_PATH/bin/ && sed -i "s+/usr/lib/pyenv/versions/$PYTHON_VERSION/+$PYTHON_PATH/+g" * ;\ + # delete binary "duplicates" and replace them with symlinks + # this also optimizes space since they are actually the same binary + rm -f $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION \ + $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION \ + $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config \ + $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION ;\ + ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION ;\ + ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config ;\ + ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + # delete files to to reduce container size + # tips taken from main python docker repo + find /usr/lib/python$PYTHON_VERSION -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # remove build dependencies and any leftover apk cache + apk del --no-cache --purge .build-deps ;\ + rm -rf /var/cache/apk/* + +# Copy in the entrypoint script -- this installs prerequisites on container start. +COPY entrypoint.sh /entrypoint.sh + +# install requirements +# this way when you build you won't need to install again +# and since COPY is cached we don't need to wait +ONBUILD COPY requirements.txt /tmp/requirements.txt + +# Run the dependencies installer and then allow it to be run again if needed. +ONBUILD RUN /entrypoint.sh -r /tmp/requirements.txt +ONBUILD RUN rm -f /requirements.installed + +# since we will be "always" mounting the volume, we can set this up +ENTRYPOINT ["/usr/bin/dumb-init"] +CMD ["python"] diff --git a/3.7-onbuild/entrypoint.sh b/3.7-onbuild/entrypoint.sh new file mode 100755 index 0000000..901491a --- /dev/null +++ b/3.7-onbuild/entrypoint.sh @@ -0,0 +1,150 @@ +#!/usr/bin/dumb-init /bin/bash +set -e + +APK_REQUIREMENTS=() +BUILD_REQUIREMENTS=() +PIP_REQUIREMENTS=() +APKFILE='/apk-requirements.txt' +BUILDFILE='/build-requirements.txt' +REQFILE='/requirements.txt' +VERBOSITY=1 + +TMP_REQFILE='/tmp/requirements.txt' + +function usage () { + echo <<"EOF" +Usage: $0 [-a -b -p -A -B -P -r -q -x] [--] + -a : APK requirement. Can be specified multiple times. + -b : APK build requirement. These will be removed at the end to save space. + -p : Pip requirement. Can be specified multiple times. + + -A : apk-requirements.txt file location, default: /apk-requirements.txt + -B : build-requirements.txt file location, default: /build-requirements.txt + -P : requirements.txt file location, default: /requirements.txt + -r : same as above, just to match Pip's -r flag. + + -q : quiet, doesn't print anything at all. + -x : Bash debug mode. Extremely verbose! + + -- : Separator for flags and your command + + Whatever you provide after your arguments is run at the end. +EOF + exit 1 +} + +function vlog () { + if [ $VERBOSITY -gt 0 ]; then + echo $1 + fi +} + +# Get and process arguments +while getopts ":a:b:p:A:B:P:r:qx" opt; do + case $opt in + a) APK_REQUIREMENTS+=("$OPTARG") ;; + b) BUILD_REQUIREMENTS+=("$OPTARG") ;; + p) PIP_REQUIREMENTS+=("$OPTARG") ;; + A) APKFILE="$OPTARG" ;; + B) BUILDFILE="$OPTARG" ;; + P) REQFILE="$OPTARG" ;; + r) REQFILE="$OPTARG" ;; + q) VERBOSITY=0 ;; + x) set -x ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + usage + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + usage + ;; + esac +done + +# Bad arguments +if [ $? -ne 0 ]; +then + usage +fi + +# Strip out all the arguments that have been processed +shift $((OPTIND-1)) + +# If there's a double dash at the end, get that off +[[ $1 = "--" ]] && shift + +# Make some common flags objects +PIP_FLAGS='' +if [ $VERBOSITY -eq 0 ]; then + PIP_FLAGS="$PIP_FLAGS -q" +fi + +APK_FLAGS='--no-cache --no-progress' +if [ $VERBOSITY -eq 0 ]; then + APK_FLAGS="$APK_FLAGS -q" +fi + +# Don't do anything if we've already done this. +if [[ ! -f /requirements.installed ]]; then + vlog "First run, checking for any requirements..." + + # Install any APK requirements + if [[ -f "$APKFILE" ]]; then + vlog "APK requirements file detected!" + APK_REQUIREMENTS+=($( cat "$APKFILE" )) + fi + + if [[ -f "$BUILDFILE" ]]; then + vlog "Build requirements file detected!" + BUILD_REQUIREMENTS+=($( cat "$BUILDFILE" )) + fi + + # Unfortunately the Alpine repositories are in a slightly inconsistent state for now-- python2 only exists in 'edge', not main. + # if [[ "$PYTHON_VERSION" == '2' ]]; then BUILD_PACKAGES="$(echo $BUILD_PACKAGES | sed -e 's/python2/python/g')"; fi \ + vlog "Installing all APK requirements..." + apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" + + # Install any Pip requirements + if [[ -f "$REQFILE" && "$(cat $REQFILE | wc -l)" -gt 0 ]]; then + # Do this check a little early-- since we merge cli in with file, + # we'd get a false positive for logging otherwise. + vlog "Pip requirements file detected!" + fi + + # If we use CLI parameters, we'll have to reassign this. + TARGET_REQFILE="$REQFILE" + if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then + # Put all Pip requirements into the same file. + printf "%s\n" "${PIP_REQUIREMENTS[@]}" >> "$TMP_REQFILE" + + if [[ -f "$REQFILE" && "$(cat $REQFILE | wc -l)" -gt 0 ]]; then + cat "$REQFILE" >> "$TMP_REQFILE" + fi + + TARGET_REQFILE="$TMP_REQFILE" + fi + + if [[ -f $TARGET_REQFILE && "$(cat $TARGET_REQFILE | wc -l)" -gt 0 ]]; then + vlog "Upgrading Pip..." + pip install $PIP_FLAGS --upgrade pip + vlog "Installing all Pip requirements..." + pip install $PIP_FLAGS -r "$TARGET_REQFILE" + fi + + # Remove packages that were only required for build. + apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" + + touch /requirements.installed +else + vlog "/requirements.installed file exists-- skipping requirements installs." +fi + + +if [[ ! -z "$@" ]]; then + # If the user has given us a command, run it. + $@ +else + # Otherwise, default to running 'python'. + python +fi diff --git a/3.7/Dockerfile b/3.7/Dockerfile new file mode 100644 index 0000000..89b5c8c --- /dev/null +++ b/3.7/Dockerfile @@ -0,0 +1,87 @@ +FROM alpine:3.8 + +# VERSIONS +ENV ALPINE_VERSION=3.8 \ + PYTHON_VERSION=3.7.2 + +# PATHS +ENV PYTHON_PATH=/usr/lib/python$PYTHON_VERSION \ + PATH="/usr/lib/python$PYTHON_VERSION/bin/:${PATH}" + +# PACKAGES +# * dumb-init: a proper init system for containers, to reap zombie children +# * musl: standard C library +# * lib6-compat: compatibility libraries for glibc +# * linux-headers: commonly needed, and an unusual package name from Alpine. +# * build-base: used so we include the basic development packages (gcc) +# * bash: so we can access /bin/bash +# * git: to ease up clones of repos +# * ca-certificates: for SSL verification during Pip and easy_install +ENV PACKAGES="\ + dumb-init \ + musl \ + libc6-compat \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ + libssl1.0 \ + libffi-dev \ +" + +# PACKAGES needed to built python +ENV PYTHON_BUILD_PACKAGES="\ + readline-dev \ + zlib-dev \ + bzip2-dev \ + sqlite-dev \ + openssl-dev \ +" + +RUN set -ex ;\ + # find MAJOR and MINOR python versions based on $PYTHON_VERSION + export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ + export PYTHON_MINOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f2- | rev) ;\ + # replacing default repositories with edge ones + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories ;\ + # Add the packages, with a CDN-breakage fallback if needed + apk add --no-cache $PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) ;\ + # Add packages just for the python build process with a CDN-breakage fallback if needed + apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES) ;\ + # turn back the clock -- so hacky! + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories ;\ + # echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ + # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ + # use pyenv to download and compile specific python version + git clone --depth 1 https://github.com/pyenv/pyenv /usr/lib/pyenv ;\ + PYENV_ROOT=/usr/lib/pyenv /usr/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # move specific version to correct path delete pyenv, no longer needed + mv /usr/lib/pyenv/versions/$PYTHON_VERSION/ $PYTHON_PATH ;\ + rm -rfv /usr/lib/pyenv ;\ + # change the path on the header of every file from PYENV_ROOT to PYTHON_PATH + cd $PYTHON_PATH/bin/ && sed -i "s+/usr/lib/pyenv/versions/$PYTHON_VERSION/+$PYTHON_PATH/+g" * ;\ + # delete binary "duplicates" and replace them with symlinks + # this also optimizes space since they are actually the same binary + rm -f $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION \ + $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION \ + $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config \ + $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION ;\ + ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION ;\ + ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config ;\ + ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + # delete files to to reduce container size + # tips taken from main python docker repo + find /usr/lib/python$PYTHON_VERSION -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # remove build dependencies and any leftover apk cache + apk del --no-cache --purge .build-deps ;\ + rm -rf /var/cache/apk/* + +# since we will be "always" mounting the volume, we can set this up +ENTRYPOINT ["/usr/bin/dumb-init"] +CMD ["python"] From 8bf5486f1197e3312491514e702b4830d7511d82 Mon Sep 17 00:00:00 2001 From: Michael K Date: Sun, 27 Jan 2019 08:28:58 -0500 Subject: [PATCH 28/55] chore(build): add 3.7 to the build matrix adds 3.7 to the build matrix in travis --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 02f303b..4337cd5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,9 @@ env: - version='3.6' type='' - version='3.6' type='-onbuild' - version='3.6' type='-slim' + - version='3.7' type='' + - version='3.7' type='-onbuild' + - version='3.7' type='-slim' before_script: - sudo docker pull $alpine_image From 3536ba0c384b1b86a9a0f646891ba8cef32a3cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Thu, 28 Feb 2019 14:44:20 +0000 Subject: [PATCH 29/55] Update all images with new script. Add 3.7-slim tag --- 2.7-onbuild/Dockerfile | 110 ++++++++++++++++-------------- 2.7-slim/Dockerfile | 137 +++++++++++++++++++++++-------------- 2.7/Dockerfile | 110 ++++++++++++++++-------------- 3.6-onbuild/Dockerfile | 112 ++++++++++++++++-------------- 3.6-slim/Dockerfile | 138 +++++++++++++++++++++++-------------- 3.6/Dockerfile | 112 ++++++++++++++++-------------- 3.7-onbuild/Dockerfile | 111 ++++++++++++++++-------------- 3.7-slim/Dockerfile | 102 ++++++++++++++++++++++++++++ 3.7-slim/entrypoint.sh | 150 +++++++++++++++++++++++++++++++++++++++++ 3.7/Dockerfile | 111 ++++++++++++++++-------------- README.md | 58 +++++++++------- 11 files changed, 823 insertions(+), 428 deletions(-) create mode 100644 3.7-slim/Dockerfile create mode 100644 3.7-slim/entrypoint.sh diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 8fcd87c..571d89d 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -5,38 +5,56 @@ ENV ALPINE_VERSION=3.8 \ PYTHON_VERSION=2.7.15 # PATHS -ENV PYTHON_PATH=/usr/lib/python$PYTHON_VERSION \ - PATH="/usr/lib/python$PYTHON_VERSION/bin/:${PATH}" - -# PACKAGES -# * dumb-init: a proper init system for containers, to reap zombie children -# * musl: standard C library -# * lib6-compat: compatibility libraries for glibc -# * linux-headers: commonly needed, and an unusual package name from Alpine. -# * build-base: used so we include the basic development packages (gcc) -# * bash: so we can access /bin/bash -# * git: to ease up clones of repos -# * ca-certificates: for SSL verification during Pip and easy_install -ENV PACKAGES="\ - dumb-init \ - musl \ - libc6-compat \ - linux-headers \ - build-base \ - bash \ - git \ - ca-certificates \ - libssl1.0 \ -" - -# PACKAGES needed to built python -ENV PYTHON_BUILD_PACKAGES="\ - readline-dev \ - zlib-dev \ - bzip2-dev \ - sqlite-dev \ - openssl-dev \ -" +ENV PYTHON_PATH=/usr/local/bin/ \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + # These are always installed. + # * dumb-init: a proper init system for containers, to reap zombie children + # * musl: standard C library + # * lib6-compat: compatibility libraries for glibc + # * linux-headers: commonly needed, and an unusual package name from Alpine. + # * build-base: used so we include the basic development packages (gcc) + # * bash: so we can access /bin/bash + # * git: to ease up clones of repos + # * ca-certificates: for SSL verification during Pip and easy_install + PACKAGES="\ + dumb-init \ + musl \ + libc6-compat \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ + libssl1.0 \ + " \ + # PACKAGES needed to built python + PYTHON_BUILD_PACKAGES="\ + bzip2-dev \ + coreutils \ + dpkg-dev dpkg \ + expat-dev \ + findutils \ + gcc \ + gdbm-dev \ + libc-dev \ + libffi-dev \ + libnsl-dev \ + libtirpc-dev \ + linux-headers \ + make \ + ncurses-dev \ + libressl-dev \ + pax-utils \ + readline-dev \ + sqlite-dev \ + tcl-dev \ + tk \ + tk-dev \ + util-linux-dev \ + xz-dev \ + zlib-dev \ + git \ + " RUN set -ex ;\ # find MAJOR and MINOR python versions based on $PYTHON_VERSION @@ -57,26 +75,18 @@ RUN set -ex ;\ # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ # use pyenv to download and compile specific python version - git clone --depth 1 https://github.com/pyenv/pyenv /usr/lib/pyenv ;\ - PYENV_ROOT=/usr/lib/pyenv /usr/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ - # move specific version to correct path delete pyenv, no longer needed - mv /usr/lib/pyenv/versions/$PYTHON_VERSION/ $PYTHON_PATH ;\ - rm -rfv /usr/lib/pyenv ;\ - # change the path on the header of every file from PYENV_ROOT to PYTHON_PATH - cd $PYTHON_PATH/bin/ && sed -i "s+/usr/lib/pyenv/versions/$PYTHON_VERSION/+$PYTHON_PATH/+g" * ;\ - # delete binary "duplicates" and replace them with symlinks - # this also optimizes space since they are actually the same binary - rm -f $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION \ - $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION \ - $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config \ - $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ - ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION ;\ - ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION ;\ - ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config ;\ - ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ + # install + GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # delete everything from pyenv except the installed version + # this throws an error but we ignore it + find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ # delete files to to reduce container size # tips taken from main python docker repo - find /usr/lib/python$PYTHON_VERSION -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/2.7-slim/Dockerfile b/2.7-slim/Dockerfile index 19d96a3..265cc2a 100644 --- a/2.7-slim/Dockerfile +++ b/2.7-slim/Dockerfile @@ -1,61 +1,98 @@ FROM alpine:3.8 -ENV ALPINE_VERSION=3.8 +# VERSIONS +ENV ALPINE_VERSION=3.8 \ + PYTHON_VERSION=2.7.15 -# These are always installed. Notes: -# * dumb-init: a proper init system for containers, to reap zombie children -# * bash: For entrypoint, and debugging -# * ca-certificates: for SSL verification during Pip and easy_install -# * python: the binaries themselves -# * py-setuptools: required only in major version 2, installs easy_install so we can install Pip. -ENV PACKAGES="\ - dumb-init \ - bash \ - ca-certificates \ - python2 \ - py-setuptools \ -" +ENV PYTHON_PATH=/usr/local/bin/ \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + # These are always installed. Notes: + # * dumb-init: a proper init system for containers, to reap zombie children + # * bash: For entrypoint, and debugging + # * ca-certificates: for SSL verification during Pip and easy_install + PACKAGES="\ + dumb-init \ + bash \ + ca-certificates \ + " \ + # PACKAGES needed to built python + PYTHON_BUILD_PACKAGES="\ + bzip2-dev \ + coreutils \ + dpkg-dev dpkg \ + expat-dev \ + findutils \ + gcc \ + gdbm-dev \ + libc-dev \ + libffi-dev \ + libnsl-dev \ + libtirpc-dev \ + linux-headers \ + make \ + ncurses-dev \ + libressl-dev \ + pax-utils \ + readline-dev \ + sqlite-dev \ + tcl-dev \ + tk \ + tk-dev \ + util-linux-dev \ + xz-dev \ + zlib-dev \ + git \ + " \ + # These packages are not installed immediately, but are added at runtime or ONBUILD to shrink the image as much as possible. Notes: + # * build-base: used so we include the basic development packages (gcc) + # * linux-headers: commonly needed, and an unusual package name from Alpine. + # * lib6-compat: compatibility libraries for glibc + # * git: to ease up clones of repos + BUILD_PACKAGES="\ + build-base \ + linux-headers \ + libc6-compat \ + git \ + " -RUN echo \ - # replacing default repositories with edge ones - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" > /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories \ - # Add the packages, with a CDN-breakage fallback if needed - && apk add --no-cache $PACKAGES || \ - (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ - # turn back the clock -- so hacky! - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ - # && echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ - # && echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories \ - # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ - # make some useful symlinks that are expected to exist - && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python2.7 /usr/bin/python; fi \ - && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python2.7-config /usr/bin/python-config; fi \ - && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf /usr/bin/easy_install-2.7 /usr/bin/easy_install; fi \ - # Install and upgrade Pip - && easy_install pip \ - && pip install --upgrade pip \ - && if [[ ! -e /usr/bin/pip ]]; then ln -sf /usr/bin/pip2.7 /usr/bin/pip; fi \ - && echo +RUN set -ex ;\ + # find MAJOR and MINOR python versions based on $PYTHON_VERSION + export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ + export PYTHON_MINOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f2- | rev) ;\ + # replacing default repositories with edge ones + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories ;\ + # Add the packages, with a CDN-breakage fallback if needed + apk add --no-cache $PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) ;\ + # Add packages just for the python build process with a CDN-breakage fallback if needed + apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES) ;\ + # turn back the clock -- so hacky! + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories ;\ + # echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ + # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ + # use pyenv to download and compile specific python version + git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ + # install + GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # delete everything from pyenv except the installed version + # this throws an error but we ignore it + find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ + # delete files to to reduce container size + # tips taken from main python docker repo + find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + # remove build dependencies and any leftover apk cache + apk del --no-cache --purge .build-deps ;\ + rm -rf /var/cache/apk/* # Copy in the entrypoint script -- this installs prerequisites on container start. COPY entrypoint.sh /entrypoint.sh -# These packages are not installed immediately, but are added at runtime or ONBUILD to shrink the image as much as possible. Notes: -# * build-base: used so we include the basic development packages (gcc) -# * linux-headers: commonly needed, and an unusual package name from Alpine. -# * lib6-compat: compatibility libraries for glibc -# * python2-dev: are used for gevent e.g. -# * git: to ease up clones of repos -ENV BUILD_PACKAGES="\ - build-base \ - linux-headers \ - libc6-compat \ - python2-dev \ - git \ -" - # This script installs APK and Pip prerequisites on container start, or ONBUILD. Notes: # * Reads the -a flags and /apk-requirements.txt for install requests # * Reads the -b flags and /build-requirements.txt for build packages -- removed when build is complete diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 3c2e6f5..2767a7e 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -5,38 +5,56 @@ ENV ALPINE_VERSION=3.8 \ PYTHON_VERSION=2.7.15 # PATHS -ENV PYTHON_PATH=/usr/lib/python$PYTHON_VERSION \ - PATH="/usr/lib/python$PYTHON_VERSION/bin/:${PATH}" - -# PACKAGES -# * dumb-init: a proper init system for containers, to reap zombie children -# * musl: standard C library -# * lib6-compat: compatibility libraries for glibc -# * linux-headers: commonly needed, and an unusual package name from Alpine. -# * build-base: used so we include the basic development packages (gcc) -# * bash: so we can access /bin/bash -# * git: to ease up clones of repos -# * ca-certificates: for SSL verification during Pip and easy_install -ENV PACKAGES="\ - dumb-init \ - musl \ - libc6-compat \ - linux-headers \ - build-base \ - bash \ - git \ - ca-certificates \ - libssl1.0 \ -" - -# PACKAGES needed to built python -ENV PYTHON_BUILD_PACKAGES="\ - readline-dev \ - zlib-dev \ - bzip2-dev \ - sqlite-dev \ - openssl-dev \ -" +ENV PYTHON_PATH=/usr/local/bin/ \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + # These are always installed. + # * dumb-init: a proper init system for containers, to reap zombie children + # * musl: standard C library + # * lib6-compat: compatibility libraries for glibc + # * linux-headers: commonly needed, and an unusual package name from Alpine. + # * build-base: used so we include the basic development packages (gcc) + # * bash: so we can access /bin/bash + # * git: to ease up clones of repos + # * ca-certificates: for SSL verification during Pip and easy_install + PACKAGES="\ + dumb-init \ + musl \ + libc6-compat \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ + libssl1.0 \ + " \ + # PACKAGES needed to built python + PYTHON_BUILD_PACKAGES="\ + bzip2-dev \ + coreutils \ + dpkg-dev dpkg \ + expat-dev \ + findutils \ + gcc \ + gdbm-dev \ + libc-dev \ + libffi-dev \ + libnsl-dev \ + libtirpc-dev \ + linux-headers \ + make \ + ncurses-dev \ + libressl-dev \ + pax-utils \ + readline-dev \ + sqlite-dev \ + tcl-dev \ + tk \ + tk-dev \ + util-linux-dev \ + xz-dev \ + zlib-dev \ + git \ + " RUN set -ex ;\ # find MAJOR and MINOR python versions based on $PYTHON_VERSION @@ -57,26 +75,18 @@ RUN set -ex ;\ # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ # use pyenv to download and compile specific python version - git clone --depth 1 https://github.com/pyenv/pyenv /usr/lib/pyenv ;\ - PYENV_ROOT=/usr/lib/pyenv /usr/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ - # move specific version to correct path delete pyenv, no longer needed - mv /usr/lib/pyenv/versions/$PYTHON_VERSION/ $PYTHON_PATH ;\ - rm -rfv /usr/lib/pyenv ;\ - # change the path on the header of every file from PYENV_ROOT to PYTHON_PATH - cd $PYTHON_PATH/bin/ && sed -i "s+/usr/lib/pyenv/versions/$PYTHON_VERSION/+$PYTHON_PATH/+g" * ;\ - # delete binary "duplicates" and replace them with symlinks - # this also optimizes space since they are actually the same binary - rm -f $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION \ - $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION \ - $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config \ - $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ - ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION ;\ - ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION ;\ - ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config ;\ - ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ + # install + GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # delete everything from pyenv except the installed version + # this throws an error but we ignore it + find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ # delete files to to reduce container size # tips taken from main python docker repo - find /usr/lib/python$PYTHON_VERSION -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.6-onbuild/Dockerfile b/3.6-onbuild/Dockerfile index 4991644..e2ff88d 100644 --- a/3.6-onbuild/Dockerfile +++ b/3.6-onbuild/Dockerfile @@ -2,41 +2,59 @@ FROM alpine:3.8 # VERSIONS ENV ALPINE_VERSION=3.8 \ - PYTHON_VERSION=3.6.6 + PYTHON_VERSION=3.6.8 # PATHS -ENV PYTHON_PATH=/usr/lib/python$PYTHON_VERSION \ - PATH="/usr/lib/python$PYTHON_VERSION/bin/:${PATH}" - -# PACKAGES -# * dumb-init: a proper init system for containers, to reap zombie children -# * musl: standard C library -# * lib6-compat: compatibility libraries for glibc -# * linux-headers: commonly needed, and an unusual package name from Alpine. -# * build-base: used so we include the basic development packages (gcc) -# * bash: so we can access /bin/bash -# * git: to ease up clones of repos -# * ca-certificates: for SSL verification during Pip and easy_install -ENV PACKAGES="\ - dumb-init \ - musl \ - libc6-compat \ - linux-headers \ - build-base \ - bash \ - git \ - ca-certificates \ - libssl1.0 \ -" - -# PACKAGES needed to built python -ENV PYTHON_BUILD_PACKAGES="\ - readline-dev \ - zlib-dev \ - bzip2-dev \ - sqlite-dev \ - openssl-dev \ -" +ENV PYTHON_PATH=/usr/local/bin/ \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + # These are always installed. + # * dumb-init: a proper init system for containers, to reap zombie children + # * musl: standard C library + # * lib6-compat: compatibility libraries for glibc + # * linux-headers: commonly needed, and an unusual package name from Alpine. + # * build-base: used so we include the basic development packages (gcc) + # * bash: so we can access /bin/bash + # * git: to ease up clones of repos + # * ca-certificates: for SSL verification during Pip and easy_install + PACKAGES="\ + dumb-init \ + musl \ + libc6-compat \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ + libssl1.0 \ + " \ + # PACKAGES needed to built python + PYTHON_BUILD_PACKAGES="\ + bzip2-dev \ + coreutils \ + dpkg-dev dpkg \ + expat-dev \ + findutils \ + gcc \ + gdbm-dev \ + libc-dev \ + libffi-dev \ + libnsl-dev \ + libtirpc-dev \ + linux-headers \ + make \ + ncurses-dev \ + libressl-dev \ + pax-utils \ + readline-dev \ + sqlite-dev \ + tcl-dev \ + tk \ + tk-dev \ + util-linux-dev \ + xz-dev \ + zlib-dev \ + git \ + " RUN set -ex ;\ # find MAJOR and MINOR python versions based on $PYTHON_VERSION @@ -57,26 +75,18 @@ RUN set -ex ;\ # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ # use pyenv to download and compile specific python version - git clone --depth 1 https://github.com/pyenv/pyenv /usr/lib/pyenv ;\ - PYENV_ROOT=/usr/lib/pyenv /usr/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ - # move specific version to correct path delete pyenv, no longer needed - mv /usr/lib/pyenv/versions/$PYTHON_VERSION/ $PYTHON_PATH ;\ - rm -rfv /usr/lib/pyenv ;\ - # change the path on the header of every file from PYENV_ROOT to PYTHON_PATH - cd $PYTHON_PATH/bin/ && sed -i "s+/usr/lib/pyenv/versions/$PYTHON_VERSION/+$PYTHON_PATH/+g" * ;\ - # delete binary "duplicates" and replace them with symlinks - # this also optimizes space since they are actually the same binary - rm -f $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION \ - $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION \ - $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config \ - $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ - ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION ;\ - ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION ;\ - ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config ;\ - ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ + # install + GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # delete everything from pyenv except the installed version + # this throws an error but we ignore it + find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ # delete files to to reduce container size # tips taken from main python docker repo - find /usr/lib/python$PYTHON_VERSION -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.6-slim/Dockerfile b/3.6-slim/Dockerfile index c0ef390..63f3a0d 100644 --- a/3.6-slim/Dockerfile +++ b/3.6-slim/Dockerfile @@ -1,61 +1,99 @@ FROM alpine:3.8 -ENV ALPINE_VERSION=3.8 +# VERSIONS +ENV ALPINE_VERSION=3.8 \ + PYTHON_VERSION=3.6.8 -# These are always installed. Notes: -# * dumb-init: a proper init system for containers, to reap zombie children -# * bash: For entrypoint, and debugging -# * ca-certificates: for SSL verification during Pip and easy_install -# * python: the binaries themselves -ENV PACKAGES="\ - dumb-init \ - bash \ - ca-certificates \ - python3 \ -" +# PATHS +ENV PYTHON_PATH=/usr/local/bin/ \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + # These are always installed. Notes: + # * dumb-init: a proper init system for containers, to reap zombie children + # * bash: For entrypoint, and debugging + # * ca-certificates: for SSL verification during Pip and easy_install + PACKAGES="\ + dumb-init \ + bash \ + ca-certificates \ + " \ + # PACKAGES needed to built python + PYTHON_BUILD_PACKAGES="\ + bzip2-dev \ + coreutils \ + dpkg-dev dpkg \ + expat-dev \ + findutils \ + gcc \ + gdbm-dev \ + libc-dev \ + libffi-dev \ + libnsl-dev \ + libtirpc-dev \ + linux-headers \ + make \ + ncurses-dev \ + libressl-dev \ + pax-utils \ + readline-dev \ + sqlite-dev \ + tcl-dev \ + tk \ + tk-dev \ + util-linux-dev \ + xz-dev \ + zlib-dev \ + git \ + " \ + # These packages are not installed immediately, but are added at runtime or ONBUILD to shrink the image as much as possible. Notes: + # * build-base: used so we include the basic development packages (gcc) + # * linux-headers: commonly needed, and an unusual package name from Alpine. + # * lib6-compat: compatibility libraries for glibc + # * git: to ease up clones of repos + BUILD_PACKAGES="\ + build-base \ + linux-headers \ + libc6-compat \ + git \ + " -RUN echo \ - # replacing default repositories with edge ones - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" > /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories \ - # Add the packages, with a CDN-breakage fallback if needed - && apk add --no-cache $PACKAGES || \ - (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) \ - # turn back the clock -- so hacky! - && echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories \ - # && echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories \ - # && echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories \ - # && echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories \ - # make some useful symlinks that are expected to exist - && if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi \ - && if [[ ! -e /usr/bin/python-config ]]; then ln -sf /usr/bin/python-config3 /usr/bin/python-config; fi \ - && if [[ ! -e /usr/bin/idle ]]; then ln -sf /usr/bin/idle3 /usr/bin/idle; fi \ - && if [[ ! -e /usr/bin/pydoc ]]; then ln -sf /usr/bin/pydoc3 /usr/bin/pydoc; fi \ - && if [[ ! -e /usr/bin/easy_install ]]; then ln -sf $(ls /usr/bin/easy_install*) /usr/bin/easy_install; fi \ - # Install and upgrade Pip - && easy_install pip \ - && pip install --upgrade pip \ - && if [[ ! -e /usr/bin/pip ]]; then ln -sf /usr/bin/pip3 /usr/bin/pip; fi \ - && echo +RUN set -ex ;\ + # find MAJOR and MINOR python versions based on $PYTHON_VERSION + export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ + export PYTHON_MINOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f2- | rev) ;\ + # replacing default repositories with edge ones + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories ;\ + # Add the packages, with a CDN-breakage fallback if needed + apk add --no-cache $PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) ;\ + # Add packages just for the python build process with a CDN-breakage fallback if needed + apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES) ;\ + # turn back the clock -- so hacky! + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories ;\ + # echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ + # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ + # use pyenv to download and compile specific python version + git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ + # install + GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # delete everything from pyenv except the installed version + # this throws an error but we ignore it + find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ + # delete files to to reduce container size + # tips taken from main python docker repo + find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + # remove build dependencies and any leftover apk cache + apk del --no-cache --purge .build-deps ;\ + rm -rf /var/cache/apk/* # Copy in the entrypoint script -- this installs prerequisites on container start. COPY entrypoint.sh /entrypoint.sh -# These packages are not installed immediately, but are added at runtime or ONBUILD to shrink the image as much as possible. Notes: -# * build-base: used so we include the basic development packages (gcc) -# * linux-headers: commonly needed, and an unusual package name from Alpine. -# * lib6-compat: compatibility libraries for glibc -# * python3-dev: are used for gevent e.g. -# * git: to ease up clones of repos -ENV BUILD_PACKAGES="\ - build-base \ - linux-headers \ - libc6-compat \ - python3-dev \ - git \ -" - # This script installs APK and Pip prerequisites on container start, or ONBUILD. Notes: # * Reads the -a flags and /apk-requirements.txt for install requests # * Reads the -b flags and /build-requirements.txt for build packages -- removed when build is complete diff --git a/3.6/Dockerfile b/3.6/Dockerfile index 9e68253..b620514 100644 --- a/3.6/Dockerfile +++ b/3.6/Dockerfile @@ -2,41 +2,59 @@ FROM alpine:3.8 # VERSIONS ENV ALPINE_VERSION=3.8 \ - PYTHON_VERSION=3.6.6 + PYTHON_VERSION=3.6.8 # PATHS -ENV PYTHON_PATH=/usr/lib/python$PYTHON_VERSION \ - PATH="/usr/lib/python$PYTHON_VERSION/bin/:${PATH}" - -# PACKAGES -# * dumb-init: a proper init system for containers, to reap zombie children -# * musl: standard C library -# * lib6-compat: compatibility libraries for glibc -# * linux-headers: commonly needed, and an unusual package name from Alpine. -# * build-base: used so we include the basic development packages (gcc) -# * bash: so we can access /bin/bash -# * git: to ease up clones of repos -# * ca-certificates: for SSL verification during Pip and easy_install -ENV PACKAGES="\ - dumb-init \ - musl \ - libc6-compat \ - linux-headers \ - build-base \ - bash \ - git \ - ca-certificates \ - libssl1.0 \ -" - -# PACKAGES needed to built python -ENV PYTHON_BUILD_PACKAGES="\ - readline-dev \ - zlib-dev \ - bzip2-dev \ - sqlite-dev \ - openssl-dev \ -" +ENV PYTHON_PATH=/usr/local/bin/ \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + # These are always installed. + # * dumb-init: a proper init system for containers, to reap zombie children + # * musl: standard C library + # * lib6-compat: compatibility libraries for glibc + # * linux-headers: commonly needed, and an unusual package name from Alpine. + # * build-base: used so we include the basic development packages (gcc) + # * bash: so we can access /bin/bash + # * git: to ease up clones of repos + # * ca-certificates: for SSL verification during Pip and easy_install + PACKAGES="\ + dumb-init \ + musl \ + libc6-compat \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ + libssl1.0 \ + " \ + # PACKAGES needed to built python + PYTHON_BUILD_PACKAGES="\ + bzip2-dev \ + coreutils \ + dpkg-dev dpkg \ + expat-dev \ + findutils \ + gcc \ + gdbm-dev \ + libc-dev \ + libffi-dev \ + libnsl-dev \ + libtirpc-dev \ + linux-headers \ + make \ + ncurses-dev \ + libressl-dev \ + pax-utils \ + readline-dev \ + sqlite-dev \ + tcl-dev \ + tk \ + tk-dev \ + util-linux-dev \ + xz-dev \ + zlib-dev \ + git \ + " RUN set -ex ;\ # find MAJOR and MINOR python versions based on $PYTHON_VERSION @@ -57,26 +75,18 @@ RUN set -ex ;\ # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ # use pyenv to download and compile specific python version - git clone --depth 1 https://github.com/pyenv/pyenv /usr/lib/pyenv ;\ - PYENV_ROOT=/usr/lib/pyenv /usr/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ - # move specific version to correct path delete pyenv, no longer needed - mv /usr/lib/pyenv/versions/$PYTHON_VERSION/ $PYTHON_PATH ;\ - rm -rfv /usr/lib/pyenv ;\ - # change the path on the header of every file from PYENV_ROOT to PYTHON_PATH - cd $PYTHON_PATH/bin/ && sed -i "s+/usr/lib/pyenv/versions/$PYTHON_VERSION/+$PYTHON_PATH/+g" * ;\ - # delete binary "duplicates" and replace them with symlinks - # this also optimizes space since they are actually the same binary - rm -f $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION \ - $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION \ - $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config \ - $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ - ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION ;\ - ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION ;\ - ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config ;\ - ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ + # install + GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # delete everything from pyenv except the installed version + # this throws an error but we ignore it + find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ # delete files to to reduce container size # tips taken from main python docker repo - find /usr/lib/python$PYTHON_VERSION -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.7-onbuild/Dockerfile b/3.7-onbuild/Dockerfile index 365f720..00ed5a0 100644 --- a/3.7-onbuild/Dockerfile +++ b/3.7-onbuild/Dockerfile @@ -5,39 +5,56 @@ ENV ALPINE_VERSION=3.8 \ PYTHON_VERSION=3.7.2 # PATHS -ENV PYTHON_PATH=/usr/lib/python$PYTHON_VERSION \ - PATH="/usr/lib/python$PYTHON_VERSION/bin/:${PATH}" - -# PACKAGES -# * dumb-init: a proper init system for containers, to reap zombie children -# * musl: standard C library -# * lib6-compat: compatibility libraries for glibc -# * linux-headers: commonly needed, and an unusual package name from Alpine. -# * build-base: used so we include the basic development packages (gcc) -# * bash: so we can access /bin/bash -# * git: to ease up clones of repos -# * ca-certificates: for SSL verification during Pip and easy_install -ENV PACKAGES="\ - dumb-init \ - musl \ - libc6-compat \ - linux-headers \ - build-base \ - bash \ - git \ - ca-certificates \ - libssl1.0 \ - libffi-dev \ -" - -# PACKAGES needed to built python -ENV PYTHON_BUILD_PACKAGES="\ - readline-dev \ - zlib-dev \ - bzip2-dev \ - sqlite-dev \ - openssl-dev \ -" +ENV PYTHON_PATH=/usr/local/bin/ \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + # These are always installed. + # * dumb-init: a proper init system for containers, to reap zombie children + # * musl: standard C library + # * lib6-compat: compatibility libraries for glibc + # * linux-headers: commonly needed, and an unusual package name from Alpine. + # * build-base: used so we include the basic development packages (gcc) + # * bash: so we can access /bin/bash + # * git: to ease up clones of repos + # * ca-certificates: for SSL verification during Pip and easy_install + PACKAGES="\ + dumb-init \ + musl \ + libc6-compat \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ + libssl1.0 \ + " \ + # PACKAGES needed to built python + PYTHON_BUILD_PACKAGES="\ + bzip2-dev \ + coreutils \ + dpkg-dev dpkg \ + expat-dev \ + findutils \ + gcc \ + gdbm-dev \ + libc-dev \ + libffi-dev \ + libnsl-dev \ + libtirpc-dev \ + linux-headers \ + make \ + ncurses-dev \ + libressl-dev \ + pax-utils \ + readline-dev \ + sqlite-dev \ + tcl-dev \ + tk \ + tk-dev \ + util-linux-dev \ + xz-dev \ + zlib-dev \ + git \ + " RUN set -ex ;\ # find MAJOR and MINOR python versions based on $PYTHON_VERSION @@ -58,26 +75,18 @@ RUN set -ex ;\ # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ # use pyenv to download and compile specific python version - git clone --depth 1 https://github.com/pyenv/pyenv /usr/lib/pyenv ;\ - PYENV_ROOT=/usr/lib/pyenv /usr/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ - # move specific version to correct path delete pyenv, no longer needed - mv /usr/lib/pyenv/versions/$PYTHON_VERSION/ $PYTHON_PATH ;\ - rm -rfv /usr/lib/pyenv ;\ - # change the path on the header of every file from PYENV_ROOT to PYTHON_PATH - cd $PYTHON_PATH/bin/ && sed -i "s+/usr/lib/pyenv/versions/$PYTHON_VERSION/+$PYTHON_PATH/+g" * ;\ - # delete binary "duplicates" and replace them with symlinks - # this also optimizes space since they are actually the same binary - rm -f $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION \ - $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION \ - $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config \ - $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ - ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION ;\ - ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION ;\ - ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config ;\ - ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ + # install + GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # delete everything from pyenv except the installed version + # this throws an error but we ignore it + find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ # delete files to to reduce container size # tips taken from main python docker repo - find /usr/lib/python$PYTHON_VERSION -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.7-slim/Dockerfile b/3.7-slim/Dockerfile new file mode 100644 index 0000000..c07a42a --- /dev/null +++ b/3.7-slim/Dockerfile @@ -0,0 +1,102 @@ +FROM alpine:3.8 + +# VERSIONS +ENV ALPINE_VERSION=3.8 \ + PYTHON_VERSION=3.7.2 + +# PATHS +ENV PYTHON_PATH=/usr/local/bin/ \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + # These are always installed. Notes: + # * dumb-init: a proper init system for containers, to reap zombie children + # * bash: For entrypoint, and debugging + # * ca-certificates: for SSL verification during Pip and easy_install + PACKAGES="\ + dumb-init \ + bash \ + ca-certificates \ + " \ + # PACKAGES needed to built python + PYTHON_BUILD_PACKAGES="\ + bzip2-dev \ + coreutils \ + dpkg-dev dpkg \ + expat-dev \ + findutils \ + gcc \ + gdbm-dev \ + libc-dev \ + libffi-dev \ + libnsl-dev \ + libtirpc-dev \ + linux-headers \ + make \ + ncurses-dev \ + libressl-dev \ + pax-utils \ + readline-dev \ + sqlite-dev \ + tcl-dev \ + tk \ + tk-dev \ + util-linux-dev \ + xz-dev \ + zlib-dev \ + git \ + " \ + # These packages are not installed immediately, but are added at runtime or ONBUILD to shrink the image as much as possible. Notes: + # * build-base: used so we include the basic development packages (gcc) + # * linux-headers: commonly needed, and an unusual package name from Alpine. + # * lib6-compat: compatibility libraries for glibc + # * git: to ease up clones of repos + BUILD_PACKAGES="\ + build-base \ + linux-headers \ + libc6-compat \ + git \ + " + +RUN set -ex ;\ + # find MAJOR and MINOR python versions based on $PYTHON_VERSION + export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ + export PYTHON_MINOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f2- | rev) ;\ + # replacing default repositories with edge ones + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories ;\ + # Add the packages, with a CDN-breakage fallback if needed + apk add --no-cache $PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) ;\ + # Add packages just for the python build process with a CDN-breakage fallback if needed + apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES) ;\ + # turn back the clock -- so hacky! + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories ;\ + # echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ + # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ + # use pyenv to download and compile specific python version + git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ + # install + GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # delete everything from pyenv except the installed version + # this throws an error but we ignore it + find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ + # delete files to to reduce container size + # tips taken from main python docker repo + find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + # remove build dependencies and any leftover apk cache + apk del --no-cache --purge .build-deps ;\ + rm -rf /var/cache/apk/* + +# Copy in the entrypoint script -- this installs prerequisites on container start. +COPY entrypoint.sh /entrypoint.sh + +# This script installs APK and Pip prerequisites on container start, or ONBUILD. Notes: +# * Reads the -a flags and /apk-requirements.txt for install requests +# * Reads the -b flags and /build-requirements.txt for build packages -- removed when build is complete +# * Reads the -p flags and /requirements.txt for Pip packages +# * Reads the -r flag to specify a different file path for /requirements.txt +ENTRYPOINT ["/usr/bin/dumb-init", "bash", "/entrypoint.sh"] diff --git a/3.7-slim/entrypoint.sh b/3.7-slim/entrypoint.sh new file mode 100644 index 0000000..901491a --- /dev/null +++ b/3.7-slim/entrypoint.sh @@ -0,0 +1,150 @@ +#!/usr/bin/dumb-init /bin/bash +set -e + +APK_REQUIREMENTS=() +BUILD_REQUIREMENTS=() +PIP_REQUIREMENTS=() +APKFILE='/apk-requirements.txt' +BUILDFILE='/build-requirements.txt' +REQFILE='/requirements.txt' +VERBOSITY=1 + +TMP_REQFILE='/tmp/requirements.txt' + +function usage () { + echo <<"EOF" +Usage: $0 [-a -b -p -A -B -P -r -q -x] [--] + -a : APK requirement. Can be specified multiple times. + -b : APK build requirement. These will be removed at the end to save space. + -p : Pip requirement. Can be specified multiple times. + + -A : apk-requirements.txt file location, default: /apk-requirements.txt + -B : build-requirements.txt file location, default: /build-requirements.txt + -P : requirements.txt file location, default: /requirements.txt + -r : same as above, just to match Pip's -r flag. + + -q : quiet, doesn't print anything at all. + -x : Bash debug mode. Extremely verbose! + + -- : Separator for flags and your command + + Whatever you provide after your arguments is run at the end. +EOF + exit 1 +} + +function vlog () { + if [ $VERBOSITY -gt 0 ]; then + echo $1 + fi +} + +# Get and process arguments +while getopts ":a:b:p:A:B:P:r:qx" opt; do + case $opt in + a) APK_REQUIREMENTS+=("$OPTARG") ;; + b) BUILD_REQUIREMENTS+=("$OPTARG") ;; + p) PIP_REQUIREMENTS+=("$OPTARG") ;; + A) APKFILE="$OPTARG" ;; + B) BUILDFILE="$OPTARG" ;; + P) REQFILE="$OPTARG" ;; + r) REQFILE="$OPTARG" ;; + q) VERBOSITY=0 ;; + x) set -x ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + usage + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + usage + ;; + esac +done + +# Bad arguments +if [ $? -ne 0 ]; +then + usage +fi + +# Strip out all the arguments that have been processed +shift $((OPTIND-1)) + +# If there's a double dash at the end, get that off +[[ $1 = "--" ]] && shift + +# Make some common flags objects +PIP_FLAGS='' +if [ $VERBOSITY -eq 0 ]; then + PIP_FLAGS="$PIP_FLAGS -q" +fi + +APK_FLAGS='--no-cache --no-progress' +if [ $VERBOSITY -eq 0 ]; then + APK_FLAGS="$APK_FLAGS -q" +fi + +# Don't do anything if we've already done this. +if [[ ! -f /requirements.installed ]]; then + vlog "First run, checking for any requirements..." + + # Install any APK requirements + if [[ -f "$APKFILE" ]]; then + vlog "APK requirements file detected!" + APK_REQUIREMENTS+=($( cat "$APKFILE" )) + fi + + if [[ -f "$BUILDFILE" ]]; then + vlog "Build requirements file detected!" + BUILD_REQUIREMENTS+=($( cat "$BUILDFILE" )) + fi + + # Unfortunately the Alpine repositories are in a slightly inconsistent state for now-- python2 only exists in 'edge', not main. + # if [[ "$PYTHON_VERSION" == '2' ]]; then BUILD_PACKAGES="$(echo $BUILD_PACKAGES | sed -e 's/python2/python/g')"; fi \ + vlog "Installing all APK requirements..." + apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" + + # Install any Pip requirements + if [[ -f "$REQFILE" && "$(cat $REQFILE | wc -l)" -gt 0 ]]; then + # Do this check a little early-- since we merge cli in with file, + # we'd get a false positive for logging otherwise. + vlog "Pip requirements file detected!" + fi + + # If we use CLI parameters, we'll have to reassign this. + TARGET_REQFILE="$REQFILE" + if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then + # Put all Pip requirements into the same file. + printf "%s\n" "${PIP_REQUIREMENTS[@]}" >> "$TMP_REQFILE" + + if [[ -f "$REQFILE" && "$(cat $REQFILE | wc -l)" -gt 0 ]]; then + cat "$REQFILE" >> "$TMP_REQFILE" + fi + + TARGET_REQFILE="$TMP_REQFILE" + fi + + if [[ -f $TARGET_REQFILE && "$(cat $TARGET_REQFILE | wc -l)" -gt 0 ]]; then + vlog "Upgrading Pip..." + pip install $PIP_FLAGS --upgrade pip + vlog "Installing all Pip requirements..." + pip install $PIP_FLAGS -r "$TARGET_REQFILE" + fi + + # Remove packages that were only required for build. + apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" + + touch /requirements.installed +else + vlog "/requirements.installed file exists-- skipping requirements installs." +fi + + +if [[ ! -z "$@" ]]; then + # If the user has given us a command, run it. + $@ +else + # Otherwise, default to running 'python'. + python +fi diff --git a/3.7/Dockerfile b/3.7/Dockerfile index 89b5c8c..f2f98d8 100644 --- a/3.7/Dockerfile +++ b/3.7/Dockerfile @@ -5,39 +5,56 @@ ENV ALPINE_VERSION=3.8 \ PYTHON_VERSION=3.7.2 # PATHS -ENV PYTHON_PATH=/usr/lib/python$PYTHON_VERSION \ - PATH="/usr/lib/python$PYTHON_VERSION/bin/:${PATH}" - -# PACKAGES -# * dumb-init: a proper init system for containers, to reap zombie children -# * musl: standard C library -# * lib6-compat: compatibility libraries for glibc -# * linux-headers: commonly needed, and an unusual package name from Alpine. -# * build-base: used so we include the basic development packages (gcc) -# * bash: so we can access /bin/bash -# * git: to ease up clones of repos -# * ca-certificates: for SSL verification during Pip and easy_install -ENV PACKAGES="\ - dumb-init \ - musl \ - libc6-compat \ - linux-headers \ - build-base \ - bash \ - git \ - ca-certificates \ - libssl1.0 \ - libffi-dev \ -" - -# PACKAGES needed to built python -ENV PYTHON_BUILD_PACKAGES="\ - readline-dev \ - zlib-dev \ - bzip2-dev \ - sqlite-dev \ - openssl-dev \ -" +ENV PYTHON_PATH=/usr/local/bin/ \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + # These are always installed. + # * dumb-init: a proper init system for containers, to reap zombie children + # * musl: standard C library + # * lib6-compat: compatibility libraries for glibc + # * linux-headers: commonly needed, and an unusual package name from Alpine. + # * build-base: used so we include the basic development packages (gcc) + # * bash: so we can access /bin/bash + # * git: to ease up clones of repos + # * ca-certificates: for SSL verification during Pip and easy_install + PACKAGES="\ + dumb-init \ + musl \ + libc6-compat \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ + libssl1.0 \ + " \ + # PACKAGES needed to built python + PYTHON_BUILD_PACKAGES="\ + bzip2-dev \ + coreutils \ + dpkg-dev dpkg \ + expat-dev \ + findutils \ + gcc \ + gdbm-dev \ + libc-dev \ + libffi-dev \ + libnsl-dev \ + libtirpc-dev \ + linux-headers \ + make \ + ncurses-dev \ + libressl-dev \ + pax-utils \ + readline-dev \ + sqlite-dev \ + tcl-dev \ + tk \ + tk-dev \ + util-linux-dev \ + xz-dev \ + zlib-dev \ + git \ + " RUN set -ex ;\ # find MAJOR and MINOR python versions based on $PYTHON_VERSION @@ -58,26 +75,18 @@ RUN set -ex ;\ # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ # use pyenv to download and compile specific python version - git clone --depth 1 https://github.com/pyenv/pyenv /usr/lib/pyenv ;\ - PYENV_ROOT=/usr/lib/pyenv /usr/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ - # move specific version to correct path delete pyenv, no longer needed - mv /usr/lib/pyenv/versions/$PYTHON_VERSION/ $PYTHON_PATH ;\ - rm -rfv /usr/lib/pyenv ;\ - # change the path on the header of every file from PYENV_ROOT to PYTHON_PATH - cd $PYTHON_PATH/bin/ && sed -i "s+/usr/lib/pyenv/versions/$PYTHON_VERSION/+$PYTHON_PATH/+g" * ;\ - # delete binary "duplicates" and replace them with symlinks - # this also optimizes space since they are actually the same binary - rm -f $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION \ - $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION \ - $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config \ - $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ - ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION ;\ - ln -sf $PYTHON_PATH/bin/python $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION ;\ - ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MAJOR_VERSION-config ;\ - ln -sf $PYTHON_PATH/bin/python-config $PYTHON_PATH/bin/python$PYTHON_MINOR_VERSION-config ;\ + git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ + # install + GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # delete everything from pyenv except the installed version + # this throws an error but we ignore it + find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ # delete files to to reduce container size # tips taken from main python docker repo - find /usr/lib/python$PYTHON_VERSION -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/README.md b/README.md index cf83f0f..e28624d 100644 --- a/README.md +++ b/README.md @@ -11,20 +11,23 @@ A small Python Docker image based on [Alpine Linux](http://alpinelinux.org/). -- [Supported tags](#supported-tags) -- [Why?](#why) -- [Details](#details) -- [Usage](#usage) -- [Usage of onbuild images](#usage-of-onbuild-images) -- [Usage of slim images](#usage-of-slim-images) - - [Via `docker run`](#via-docker-run) - - [Pip Dependencies](#pip-dependencies) - - [Run-Time Dependencies](#run-time-dependencies) - - [Build-Time Dependencies](#build-time-dependencies) - - [Creating Images](#creating-images) - - [Debugging](#debugging) -- [License](#license) -- [TODO](#todo) +- [alpine-python](#alpine-python) + - [Supported tags](#supported-tags) + - [Why?](#why) + - [Details](#details) + - [Usage](#usage) + - [Usage of `onbuild` images](#usage-of-onbuild-images) + - [Usage of `slim` images](#usage-of-slim-images) + - [Via `docker run`](#via-docker-run) + - [Pip Dependencies](#pip-dependencies) + - [Run-Time Dependencies](#run-time-dependencies) + - [Build-Time Dependencies](#build-time-dependencies) + - [Creating Images](#creating-images) + - [Debugging](#debugging) + - [Additional Arguments](#additional-arguments) + - [Ecosystem](#ecosystem) + - [License](#license) + - [TODO](#todo) @@ -44,19 +47,26 @@ The default docker python images are too [big](https://github.com/docker-library |REPOSITORY|TAG|SIZE| |-|-|-| -|jfloff/alpine-python|2.7-slim|55MB| -|python|2.7-slim|138MB| +|jfloff/alpine-python|2.7-slim|58.8MB| +|python|2.7-slim|120MB| +|python|2.7-alpine|61.2MB| |||| -|jfloff/alpine-python|2.7|232MB| -|python|2.7-alpine|75.3MB| -|python|2.7|681MB| +|jfloff/alpine-python|2.7|233MB| +|python|2.7|912MB| |||| -|jfloff/alpine-python|3.6-slim|58.1MB| -|python|3.6-slim|156MB| +|jfloff/alpine-python|3.6-slim|75MB| +|python|3.6-slim|138MB| +|python|3.6-alpine|79MB| |||| -|jfloff/alpine-python|3.6|268MB| -|python|3.6|692MB| -|python|3.6-alpine|92.1MB| +|jfloff/alpine-python|3.6|249MB| +|python|3.6|922MB| +|||| +|jfloff/alpine-python|3.7-slim|79.1MB| +|python|3.7-slim|86.7MB| +|python|3.7-alpine|143MB| +|||| +|jfloff/alpine-python|3.7|253MB| +|python|3.7|927MB| Perhaps this could be even smaller, but I'm not an Alpine guru. **Feel free to post a PR.** From 8ec1388042ad6a01f8fb7c034e4fde675952dacd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Thu, 28 Feb 2019 14:56:32 +0000 Subject: [PATCH 30/55] Update README --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index e28624d..c5755a7 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,6 @@ A small Python Docker image based on [Alpine Linux](http://alpinelinux.org/). - [Additional Arguments](#additional-arguments) - [Ecosystem](#ecosystem) - [License](#license) - - [TODO](#todo) @@ -229,8 +228,3 @@ These are some of the images that use `jfloff/alpine-python` as base image. *If ## License The code in this repository, unless otherwise noted, is MIT licensed. See the `LICENSE` file in this repository. - -## TODO -At this moment with Alpine APK we are not able to install previous packages versions, i.e., its virtually impossible to provide multiple versions of Python. This is limits us to only provide the latest `python3` package that's available in Alpine APK. - -Ideally we would support a solution like the official `python` images does (see example [here](https://github.com/docker-library/python/blob/master/3.4/alpine/Dockerfile)), where the specific Python version is downloaded and compiled. Yet, I don't want to follow the pitfall of copy-pasting that solution, otherwise we end up with almost the same image. ***I'm requesting PRs on this issue, either by optimizing official solution, or other.*** From 5e25e88bd5b5ee691cbae771f20b24e91bdb4605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Thu, 28 Feb 2019 15:13:19 +0000 Subject: [PATCH 31/55] One more image using jfloff/alpine-python --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c5755a7..02d3a92 100644 --- a/README.md +++ b/README.md @@ -219,9 +219,10 @@ docker run --rm -ti jfloff/alpine-python:2.7-slim bash These are some of the images that use `jfloff/alpine-python` as base image. *If you have another image that uses this as base image, please submit an issue or PR for it to be added. Image has to be published on Docker Hub.* - **[jfloff/alscipy](https://github.com/jfloff/docker-alscipy)** [![Docker Stars](https://img.shields.io/docker/stars/jfloff/alscipy.svg)][alscipy-hub] [![Docker Pulls](https://img.shields.io/docker/pulls/jfloff/alscipy.svg)][alscipy-hub] : image with common packages for Science in Alpine Python. - +- **[jfloff/pywfm](https://github.com/jfloff/pywfm)** [![Docker Stars](https://img.shields.io/docker/stars/jfloff/pywfm.svg)][pywfm-hub] [![Docker Pulls](https://img.shields.io/docker/pulls/jfloff/pywfm.svg)][pywfm-hub] : image from the python wrapper for Steffen Rendle's factorization machines library libFM. [alscipy-hub]: https://hub.docker.com/r/jfloff/alscipy/ +[pywfm-hub]: https://hub.docker.com/r/jfloff/alscipy/ From 12c0e548ebacf93d7bdf6f1a9476a112c2acf1c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Thu, 28 Feb 2019 16:41:06 +0000 Subject: [PATCH 32/55] Keep needed so files --- 2.7-onbuild/Dockerfile | 6 ++++++ 2.7-slim/Dockerfile | 6 ++++++ 2.7/Dockerfile | 6 ++++++ 3.6-onbuild/Dockerfile | 6 ++++++ 3.6-slim/Dockerfile | 6 ++++++ 3.6/Dockerfile | 6 ++++++ 3.7-onbuild/Dockerfile | 6 ++++++ 3.7-slim/Dockerfile | 6 ++++++ 3.7/Dockerfile | 6 ++++++ 9 files changed, 54 insertions(+) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 571d89d..436532f 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -79,6 +79,12 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # keep the needed so files + find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ diff --git a/2.7-slim/Dockerfile b/2.7-slim/Dockerfile index 265cc2a..47bee6c 100644 --- a/2.7-slim/Dockerfile +++ b/2.7-slim/Dockerfile @@ -78,6 +78,12 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # keep the needed so files + find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 2767a7e..d9487c7 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -79,6 +79,12 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # keep the needed so files + find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ diff --git a/3.6-onbuild/Dockerfile b/3.6-onbuild/Dockerfile index e2ff88d..55bb664 100644 --- a/3.6-onbuild/Dockerfile +++ b/3.6-onbuild/Dockerfile @@ -79,6 +79,12 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # keep the needed so files + find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ diff --git a/3.6-slim/Dockerfile b/3.6-slim/Dockerfile index 63f3a0d..3bfd2b0 100644 --- a/3.6-slim/Dockerfile +++ b/3.6-slim/Dockerfile @@ -79,6 +79,12 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # keep the needed so files + find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ diff --git a/3.6/Dockerfile b/3.6/Dockerfile index b620514..f0fd4a6 100644 --- a/3.6/Dockerfile +++ b/3.6/Dockerfile @@ -79,6 +79,12 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # keep the needed so files + find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ diff --git a/3.7-onbuild/Dockerfile b/3.7-onbuild/Dockerfile index 00ed5a0..58d6bfd 100644 --- a/3.7-onbuild/Dockerfile +++ b/3.7-onbuild/Dockerfile @@ -79,6 +79,12 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # keep the needed so files + find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ diff --git a/3.7-slim/Dockerfile b/3.7-slim/Dockerfile index c07a42a..d27cc44 100644 --- a/3.7-slim/Dockerfile +++ b/3.7-slim/Dockerfile @@ -79,6 +79,12 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # keep the needed so files + find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ diff --git a/3.7/Dockerfile b/3.7/Dockerfile index f2f98d8..74e5033 100644 --- a/3.7/Dockerfile +++ b/3.7/Dockerfile @@ -79,6 +79,12 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # keep the needed so files + find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ From 9c8d314e0c7de1309539a2b38956c5592c3bc753 Mon Sep 17 00:00:00 2001 From: slowr Date: Fri, 1 Mar 2019 06:51:07 -0800 Subject: [PATCH 33/55] Changed PATH variable to point to pyenv binaries Signed-off-by: slowr --- 2.7-onbuild/Dockerfile | 4 +--- 2.7-slim/Dockerfile | 4 +--- 2.7/Dockerfile | 4 +--- 3.6-onbuild/Dockerfile | 4 +--- 3.6-slim/Dockerfile | 4 +--- 3.6/Dockerfile | 4 +--- 3.7-onbuild/Dockerfile | 4 +--- 3.7-slim/Dockerfile | 4 +--- 3.7/Dockerfile | 4 +--- 9 files changed, 9 insertions(+), 27 deletions(-) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 436532f..9f55b51 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library @@ -91,8 +91,6 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ - # symlink the binaries - ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/2.7-slim/Dockerfile b/2.7-slim/Dockerfile index 47bee6c..2a0165e 100644 --- a/2.7-slim/Dockerfile +++ b/2.7-slim/Dockerfile @@ -5,7 +5,7 @@ ENV ALPINE_VERSION=3.8 \ PYTHON_VERSION=2.7.15 ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children # * bash: For entrypoint, and debugging @@ -90,8 +90,6 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ - # symlink the binaries - ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/2.7/Dockerfile b/2.7/Dockerfile index d9487c7..52b6606 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library @@ -91,8 +91,6 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ - # symlink the binaries - ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.6-onbuild/Dockerfile b/3.6-onbuild/Dockerfile index 55bb664..7045acf 100644 --- a/3.6-onbuild/Dockerfile +++ b/3.6-onbuild/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library @@ -91,8 +91,6 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ - # symlink the binaries - ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.6-slim/Dockerfile b/3.6-slim/Dockerfile index 3bfd2b0..e55e78d 100644 --- a/3.6-slim/Dockerfile +++ b/3.6-slim/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children # * bash: For entrypoint, and debugging @@ -91,8 +91,6 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ - # symlink the binaries - ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.6/Dockerfile b/3.6/Dockerfile index f0fd4a6..700e76b 100644 --- a/3.6/Dockerfile +++ b/3.6/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library @@ -91,8 +91,6 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ - # symlink the binaries - ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.7-onbuild/Dockerfile b/3.7-onbuild/Dockerfile index 58d6bfd..a90f45e 100644 --- a/3.7-onbuild/Dockerfile +++ b/3.7-onbuild/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library @@ -91,8 +91,6 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ - # symlink the binaries - ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.7-slim/Dockerfile b/3.7-slim/Dockerfile index d27cc44..dc727e6 100644 --- a/3.7-slim/Dockerfile +++ b/3.7-slim/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children # * bash: For entrypoint, and debugging @@ -91,8 +91,6 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ - # symlink the binaries - ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.7/Dockerfile b/3.7/Dockerfile index 74e5033..a4fe0b8 100644 --- a/3.7/Dockerfile +++ b/3.7/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library @@ -91,8 +91,6 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ - # symlink the binaries - ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* From 3f0751f9f368389fbde77aa3b4a0008ae82720ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Sat, 9 Mar 2019 16:35:51 -0500 Subject: [PATCH 34/55] Link pyenv binaries to correct path (reverting #47). Make sure script is not installing Alpine's python version. --- 2.7-onbuild/Dockerfile | 8 ++++++-- 2.7-slim/Dockerfile | 8 ++++++-- 2.7/Dockerfile | 8 ++++++-- 3.6-onbuild/Dockerfile | 8 ++++++-- 3.6-slim/Dockerfile | 8 ++++++-- 3.6/Dockerfile | 8 ++++++-- 3.7-onbuild/Dockerfile | 8 ++++++-- 3.7-slim/Dockerfile | 8 ++++++-- 3.7/Dockerfile | 8 ++++++-- 9 files changed, 54 insertions(+), 18 deletions(-) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 9f55b51..51d50c9 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library @@ -79,11 +79,13 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ - # keep the needed so files + # keep the needed .so files + # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | grep -vE '*libpython*' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it @@ -91,6 +93,8 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/2.7-slim/Dockerfile b/2.7-slim/Dockerfile index 2a0165e..c7e7883 100644 --- a/2.7-slim/Dockerfile +++ b/2.7-slim/Dockerfile @@ -5,7 +5,7 @@ ENV ALPINE_VERSION=3.8 \ PYTHON_VERSION=2.7.15 ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children # * bash: For entrypoint, and debugging @@ -78,11 +78,13 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ - # keep the needed so files + # keep the needed .so files + # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | grep -vE '*libpython*' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it @@ -90,6 +92,8 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 52b6606..0b1320f 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library @@ -79,11 +79,13 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ - # keep the needed so files + # keep the needed .so files + # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | grep -vE '*libpython*' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it @@ -91,6 +93,8 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.6-onbuild/Dockerfile b/3.6-onbuild/Dockerfile index 7045acf..5e931e1 100644 --- a/3.6-onbuild/Dockerfile +++ b/3.6-onbuild/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library @@ -79,11 +79,13 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ - # keep the needed so files + # keep the needed .so files + # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | grep -vE '*libpython*' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it @@ -91,6 +93,8 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.6-slim/Dockerfile b/3.6-slim/Dockerfile index e55e78d..09a7d78 100644 --- a/3.6-slim/Dockerfile +++ b/3.6-slim/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children # * bash: For entrypoint, and debugging @@ -79,11 +79,13 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ - # keep the needed so files + # keep the needed .so files + # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | grep -vE '*libpython*' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it @@ -91,6 +93,8 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.6/Dockerfile b/3.6/Dockerfile index 700e76b..9e71a3d 100644 --- a/3.6/Dockerfile +++ b/3.6/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library @@ -79,11 +79,13 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ - # keep the needed so files + # keep the needed .so files + # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | grep -vE '*libpython*' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it @@ -91,6 +93,8 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.7-onbuild/Dockerfile b/3.7-onbuild/Dockerfile index a90f45e..d804dea 100644 --- a/3.7-onbuild/Dockerfile +++ b/3.7-onbuild/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library @@ -79,11 +79,13 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ - # keep the needed so files + # keep the needed .so files + # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | grep -vE '*libpython*' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it @@ -91,6 +93,8 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.7-slim/Dockerfile b/3.7-slim/Dockerfile index dc727e6..41cadbb 100644 --- a/3.7-slim/Dockerfile +++ b/3.7-slim/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children # * bash: For entrypoint, and debugging @@ -79,11 +79,13 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ - # keep the needed so files + # keep the needed .so files + # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | grep -vE '*libpython*' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it @@ -91,6 +93,8 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.7/Dockerfile b/3.7/Dockerfile index a4fe0b8..a6e8f2a 100644 --- a/3.7/Dockerfile +++ b/3.7/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library @@ -79,11 +79,13 @@ RUN set -ex ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ - # keep the needed so files + # keep the needed .so files + # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | grep -vE '*libpython*' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it @@ -91,6 +93,8 @@ RUN set -ex ;\ # delete files to to reduce container size # tips taken from main python docker repo find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* From 6cc88130902c0c662b5e15e8fbcda0db9585dd13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Sun, 10 Mar 2019 00:42:47 -0500 Subject: [PATCH 35/55] Update latest tag --- .travis.yml | 2 +- README.md | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4337cd5..9515cc4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,8 @@ before_install: env: global: - alpine_image='alpine:3.8' - - latest='recent' - repo='jfloff/alpine-python' + - latest='3.7' matrix: - version='2.7' type='' - version='2.7' type='-onbuild' diff --git a/README.md b/README.md index 02d3a92..d2f9975 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,12 @@ A small Python Docker image based on [Alpine Linux](http://alpinelinux.org/). * **`2.7` ([2.7/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/2.7/Dockerfile))** * **`2.7-onbuild` ([2.7-onbuild/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/2.7-onbuild/Dockerfile))** * **`2.7-slim` ([2.7-slim/Dockerfile](https://github.com/jfloff/alpine-python/blob/master/2.7-slim/Dockerfile))** -* **`3.6` `latest` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.6/Dockerfile))** +* **`3.6` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.6/Dockerfile))** * **`3.6-onbuild` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.6-onbuild/Dockerfile))** * **`3.6-slim` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.6-slim/Dockerfile))** +* **`3.7` `latest` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.7/Dockerfile))** +* **`3.7-onbuild` `latest-onbuild` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.7-onbuild/Dockerfile))** +* **`3.7-slim` `latest-slim` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.7-slim/Dockerfile))** **NOTES:** - `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_. @@ -46,25 +49,25 @@ The default docker python images are too [big](https://github.com/docker-library |REPOSITORY|TAG|SIZE| |-|-|-| -|jfloff/alpine-python|2.7-slim|58.8MB| +|jfloff/alpine-python|2.7-slim|58.9MB| |python|2.7-slim|120MB| |python|2.7-alpine|61.2MB| |||| |jfloff/alpine-python|2.7|233MB| |python|2.7|912MB| |||| -|jfloff/alpine-python|3.6-slim|75MB| +|jfloff/alpine-python|3.6-slim|75.1MB| |python|3.6-slim|138MB| |python|3.6-alpine|79MB| |||| |jfloff/alpine-python|3.6|249MB| |python|3.6|922MB| |||| -|jfloff/alpine-python|3.7-slim|79.1MB| +|jfloff/alpine-python|3.7-slim|79.2MB| |python|3.7-slim|86.7MB| |python|3.7-alpine|143MB| |||| -|jfloff/alpine-python|3.7|253MB| +|jfloff/alpine-python|3.7|254MB| |python|3.7|927MB| Perhaps this could be even smaller, but I'm not an Alpine guru. **Feel free to post a PR.** From 2682e394125fe0cf57cb12720ba863e3a79a4557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Mon, 11 Mar 2019 23:21:09 +0000 Subject: [PATCH 36/55] Add libffi-dev to images --- 2.7-onbuild/Dockerfile | 6 ++++-- 2.7-slim/Dockerfile | 6 ++++-- 2.7/Dockerfile | 6 ++++-- 3.6-onbuild/Dockerfile | 6 ++++-- 3.6-slim/Dockerfile | 6 ++++-- 3.6/Dockerfile | 6 ++++-- 3.7-onbuild/Dockerfile | 6 ++++-- 3.7-slim/Dockerfile | 6 ++++-- 3.7/Dockerfile | 9 +++++++-- README.md | 16 ++++++++++------ 10 files changed, 49 insertions(+), 24 deletions(-) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 51d50c9..8308b49 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -78,15 +78,17 @@ RUN set -ex ;\ git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ - PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip --with-shared" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ # keep the needed .so files # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ - | grep -vE '*libpython*' \ + | grep -ve 'libpython' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ + # for debug + # | xargs -n1 echo ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ diff --git a/2.7-slim/Dockerfile b/2.7-slim/Dockerfile index c7e7883..24e7201 100644 --- a/2.7-slim/Dockerfile +++ b/2.7-slim/Dockerfile @@ -77,15 +77,17 @@ RUN set -ex ;\ git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ - PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip --with-shared" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ # keep the needed .so files # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ - | grep -vE '*libpython*' \ + | grep -ve 'libpython' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ + # for debug + # | xargs -n1 echo ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 0b1320f..3667db8 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -78,15 +78,17 @@ RUN set -ex ;\ git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ - PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip --with-shared" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ # keep the needed .so files # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ - | grep -vE '*libpython*' \ + | grep -ve 'libpython' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ + # for debug + # | xargs -n1 echo ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ diff --git a/3.6-onbuild/Dockerfile b/3.6-onbuild/Dockerfile index 5e931e1..efbe691 100644 --- a/3.6-onbuild/Dockerfile +++ b/3.6-onbuild/Dockerfile @@ -78,15 +78,17 @@ RUN set -ex ;\ git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ - PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip --with-shared" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ # keep the needed .so files # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ - | grep -vE '*libpython*' \ + | grep -ve 'libpython' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ + # for debug + # | xargs -n1 echo ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ diff --git a/3.6-slim/Dockerfile b/3.6-slim/Dockerfile index 09a7d78..8488ad5 100644 --- a/3.6-slim/Dockerfile +++ b/3.6-slim/Dockerfile @@ -78,15 +78,17 @@ RUN set -ex ;\ git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ - PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip --with-shared" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ # keep the needed .so files # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ - | grep -vE '*libpython*' \ + | grep -ve 'libpython' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ + # for debug + # | xargs -n1 echo ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ diff --git a/3.6/Dockerfile b/3.6/Dockerfile index 9e71a3d..8c51b0e 100644 --- a/3.6/Dockerfile +++ b/3.6/Dockerfile @@ -78,15 +78,17 @@ RUN set -ex ;\ git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ - PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip --with-shared" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ # keep the needed .so files # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ - | grep -vE '*libpython*' \ + | grep -ve 'libpython' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ + # for debug + # | xargs -n1 echo ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ diff --git a/3.7-onbuild/Dockerfile b/3.7-onbuild/Dockerfile index d804dea..66db608 100644 --- a/3.7-onbuild/Dockerfile +++ b/3.7-onbuild/Dockerfile @@ -78,15 +78,17 @@ RUN set -ex ;\ git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ - PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip --with-shared" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ # keep the needed .so files # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ - | grep -vE '*libpython*' \ + | grep -ve 'libpython' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ + # for debug + # | xargs -n1 echo ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ diff --git a/3.7-slim/Dockerfile b/3.7-slim/Dockerfile index 41cadbb..03ba493 100644 --- a/3.7-slim/Dockerfile +++ b/3.7-slim/Dockerfile @@ -78,15 +78,17 @@ RUN set -ex ;\ git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ - PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip --with-shared" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ # keep the needed .so files # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ - | grep -vE '*libpython*' \ + | grep -ve 'libpython' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ + # for debug + # | xargs -n1 echo ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ diff --git a/3.7/Dockerfile b/3.7/Dockerfile index a6e8f2a..6f0f684 100644 --- a/3.7/Dockerfile +++ b/3.7/Dockerfile @@ -26,6 +26,7 @@ ENV PYTHON_PATH=/usr/local/bin/ \ git \ ca-certificates \ libssl1.0 \ + libffi-dev \ " \ # PACKAGES needed to built python PYTHON_BUILD_PACKAGES="\ @@ -78,15 +79,19 @@ RUN set -ex ;\ git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ # install GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ - PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # flag explanation: + # --with-shared : python-dev + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip --with-shared" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ # keep the needed .so files # ignore libpython - that one comes from the pyenv instalation find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ | tr ',' '\n' \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ - | grep -vE '*libpython*' \ + | grep -ve 'libpython' \ | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ + # for debug + # | xargs -n1 echo ;\ # delete everything from pyenv except the installed version # this throws an error but we ignore it find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ diff --git a/README.md b/README.md index d2f9975..94e075b 100644 --- a/README.md +++ b/README.md @@ -49,27 +49,31 @@ The default docker python images are too [big](https://github.com/docker-library |REPOSITORY|TAG|SIZE| |-|-|-| -|jfloff/alpine-python|2.7-slim|58.9MB| +|jfloff/alpine-python|2.7-slim|62.4MB| |python|2.7-slim|120MB| |python|2.7-alpine|61.2MB| |||| -|jfloff/alpine-python|2.7|233MB| +|jfloff/alpine-python|2.7|236MB| |python|2.7|912MB| |||| -|jfloff/alpine-python|3.6-slim|75.1MB| +|jfloff/alpine-python|3.6-slim|78.8MB| |python|3.6-slim|138MB| |python|3.6-alpine|79MB| |||| -|jfloff/alpine-python|3.6|249MB| +|jfloff/alpine-python|3.6|253MB| |python|3.6|922MB| |||| -|jfloff/alpine-python|3.7-slim|79.2MB| +|jfloff/alpine-python|3.7-slim|82.9MB| |python|3.7-slim|86.7MB| |python|3.7-alpine|143MB| |||| -|jfloff/alpine-python|3.7|254MB| +|jfloff/alpine-python|3.7|257MB| |python|3.7|927MB| +2.7-slim 62.4MB +2.7-onbuild 236MB +2.7 236MB + Perhaps this could be even smaller, but I'm not an Alpine guru. **Feel free to post a PR.** ## Details From aaa03b83938db2392357a37c39fe023a74e0095d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Wed, 13 Mar 2019 20:32:23 +0000 Subject: [PATCH 37/55] Add pip dir to path --- 2.7-onbuild/Dockerfile | 2 +- 2.7-slim/Dockerfile | 2 +- 2.7/Dockerfile | 2 +- 3.6-onbuild/Dockerfile | 2 +- 3.6-slim/Dockerfile | 2 +- 3.6/Dockerfile | 2 +- 3.7-onbuild/Dockerfile | 2 +- 3.7-slim/Dockerfile | 2 +- 3.7/Dockerfile | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 8308b49..1210bdd 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library diff --git a/2.7-slim/Dockerfile b/2.7-slim/Dockerfile index 24e7201..c9e289e 100644 --- a/2.7-slim/Dockerfile +++ b/2.7-slim/Dockerfile @@ -5,7 +5,7 @@ ENV ALPINE_VERSION=3.8 \ PYTHON_VERSION=2.7.15 ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin:${PATH}" \ # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children # * bash: For entrypoint, and debugging diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 3667db8..f179674 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library diff --git a/3.6-onbuild/Dockerfile b/3.6-onbuild/Dockerfile index efbe691..52d5732 100644 --- a/3.6-onbuild/Dockerfile +++ b/3.6-onbuild/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library diff --git a/3.6-slim/Dockerfile b/3.6-slim/Dockerfile index 8488ad5..99655a6 100644 --- a/3.6-slim/Dockerfile +++ b/3.6-slim/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin:${PATH}" \ # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children # * bash: For entrypoint, and debugging diff --git a/3.6/Dockerfile b/3.6/Dockerfile index 8c51b0e..59ed6da 100644 --- a/3.6/Dockerfile +++ b/3.6/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library diff --git a/3.7-onbuild/Dockerfile b/3.7-onbuild/Dockerfile index 66db608..e80b535 100644 --- a/3.7-onbuild/Dockerfile +++ b/3.7-onbuild/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library diff --git a/3.7-slim/Dockerfile b/3.7-slim/Dockerfile index 03ba493..9ce634c 100644 --- a/3.7-slim/Dockerfile +++ b/3.7-slim/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin:${PATH}" \ # These are always installed. Notes: # * dumb-init: a proper init system for containers, to reap zombie children # * bash: For entrypoint, and debugging diff --git a/3.7/Dockerfile b/3.7/Dockerfile index 6f0f684..f82ca88 100644 --- a/3.7/Dockerfile +++ b/3.7/Dockerfile @@ -6,7 +6,7 @@ ENV ALPINE_VERSION=3.8 \ # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ - PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:${PATH}" \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin:${PATH}" \ # These are always installed. # * dumb-init: a proper init system for containers, to reap zombie children # * musl: standard C library From df682d51071d8c0b421ed4ba1238f9276b1f7985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Wed, 5 Jun 2019 11:37:43 +0100 Subject: [PATCH 38/55] Fix build-all script to use printf instead of echo. Simplify getting script path --- build-all.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/build-all.sh b/build-all.sh index a9256d5..221a350 100755 --- a/build-all.sh +++ b/build-all.sh @@ -8,20 +8,21 @@ reset="$(tput sgr0)" build_with_status () { tag="$1" - echo -n "Building $tag" + printf "${b}Building ${tag} ... " docker build . -t $tag &> /dev/null if [[ $? -ne 0 ]]; then - echo "$bold$red BUILD FAILED$reset" + printf "\n${bold}${red}BUILD FAILED${reset}" exit 1 fi echo 'print("something")' | docker run --rm -i $tag &> /dev/null if [[ $? -ne 0 ]]; then - echo "$bold$red TEST FAILED$reset" + printf "${bold}${red}TEST FAILED${reset}" exit 1 else - echo "$bold$green SUCCESS$reset" + printf "${bold}${green}SUCCESS${reset}" fi + printf "\n" } # quiet versions @@ -29,8 +30,8 @@ pushd() { builtin pushd $1 > /dev/null; } popd() { builtin popd > /dev/null; } # Move to where the script is -HERE="$(dirname $(readlink -f $0 || realpath $0))" -cd $HERE +HERE="$( cd "$(dirname "$0")" ; pwd -P )" +cd "$HERE" # Find all the top-level dirs for version in $(find -maxdepth 1 -not -name '.*' -type d -printf '%P\n' | sort); do From 575ab77a7b4ceef7d6341b0a1bcbcdd210db8779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Wed, 5 Jun 2019 11:47:51 +0100 Subject: [PATCH 39/55] Add tzdata and UTC timezone settings to images --- 2.7-onbuild/Dockerfile | 3 +++ 2.7/Dockerfile | 3 +++ 3.6-onbuild/Dockerfile | 3 +++ 3.6/Dockerfile | 3 +++ 3.7-onbuild/Dockerfile | 3 +++ 3.7/Dockerfile | 3 +++ README.md | 16 ++++++---------- 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 1210bdd..7620599 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -26,6 +26,7 @@ ENV PYTHON_PATH=/usr/local/bin/ \ git \ ca-certificates \ libssl1.0 \ + tzdata \ " \ # PACKAGES needed to built python PYTHON_BUILD_PACKAGES="\ @@ -97,6 +98,8 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + # set timezone info + ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/2.7/Dockerfile b/2.7/Dockerfile index f179674..749f21d 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -26,6 +26,7 @@ ENV PYTHON_PATH=/usr/local/bin/ \ git \ ca-certificates \ libssl1.0 \ + tzdata \ " \ # PACKAGES needed to built python PYTHON_BUILD_PACKAGES="\ @@ -97,6 +98,8 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + # set timezone info + ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.6-onbuild/Dockerfile b/3.6-onbuild/Dockerfile index 52d5732..df1b75c 100644 --- a/3.6-onbuild/Dockerfile +++ b/3.6-onbuild/Dockerfile @@ -26,6 +26,7 @@ ENV PYTHON_PATH=/usr/local/bin/ \ git \ ca-certificates \ libssl1.0 \ + tzdata \ " \ # PACKAGES needed to built python PYTHON_BUILD_PACKAGES="\ @@ -97,6 +98,8 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + # set timezone info + ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.6/Dockerfile b/3.6/Dockerfile index 59ed6da..ca96aac 100644 --- a/3.6/Dockerfile +++ b/3.6/Dockerfile @@ -26,6 +26,7 @@ ENV PYTHON_PATH=/usr/local/bin/ \ git \ ca-certificates \ libssl1.0 \ + tzdata \ " \ # PACKAGES needed to built python PYTHON_BUILD_PACKAGES="\ @@ -97,6 +98,8 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + # set timezone info + ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.7-onbuild/Dockerfile b/3.7-onbuild/Dockerfile index e80b535..fe6552a 100644 --- a/3.7-onbuild/Dockerfile +++ b/3.7-onbuild/Dockerfile @@ -26,6 +26,7 @@ ENV PYTHON_PATH=/usr/local/bin/ \ git \ ca-certificates \ libssl1.0 \ + tzdata \ " \ # PACKAGES needed to built python PYTHON_BUILD_PACKAGES="\ @@ -97,6 +98,8 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + # set timezone info + ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/3.7/Dockerfile b/3.7/Dockerfile index f82ca88..2ba00bb 100644 --- a/3.7/Dockerfile +++ b/3.7/Dockerfile @@ -27,6 +27,7 @@ ENV PYTHON_PATH=/usr/local/bin/ \ ca-certificates \ libssl1.0 \ libffi-dev \ + tzdata \ " \ # PACKAGES needed to built python PYTHON_BUILD_PACKAGES="\ @@ -100,6 +101,8 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + # set timezone info + ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* diff --git a/README.md b/README.md index 94e075b..1f2f2d5 100644 --- a/README.md +++ b/README.md @@ -49,31 +49,27 @@ The default docker python images are too [big](https://github.com/docker-library |REPOSITORY|TAG|SIZE| |-|-|-| -|jfloff/alpine-python|2.7-slim|62.4MB| +|jfloff/alpine-python|2.7-slim|60MB| |python|2.7-slim|120MB| |python|2.7-alpine|61.2MB| |||| -|jfloff/alpine-python|2.7|236MB| +|jfloff/alpine-python|2.7|235MB| |python|2.7|912MB| |||| -|jfloff/alpine-python|3.6-slim|78.8MB| +|jfloff/alpine-python|3.6-slim|76.3MB| |python|3.6-slim|138MB| |python|3.6-alpine|79MB| |||| -|jfloff/alpine-python|3.6|253MB| +|jfloff/alpine-python|3.6|252MB| |python|3.6|922MB| |||| -|jfloff/alpine-python|3.7-slim|82.9MB| +|jfloff/alpine-python|3.7-slim|80.4MB| |python|3.7-slim|86.7MB| |python|3.7-alpine|143MB| |||| -|jfloff/alpine-python|3.7|257MB| +|jfloff/alpine-python|3.7|256MB| |python|3.7|927MB| -2.7-slim 62.4MB -2.7-onbuild 236MB -2.7 236MB - Perhaps this could be even smaller, but I'm not an Alpine guru. **Feel free to post a PR.** ## Details From c4f30db63c269ad2d56c62f419b42e8925ea1936 Mon Sep 17 00:00:00 2001 From: Hosam Aly Date: Mon, 8 Jul 2019 10:39:20 +0100 Subject: [PATCH 40/55] Upgrade Python versions (#53) * Update Python 2.7 to v2.7.16 * Update Python 3.7 to v3.7.3 * Update Python 3.6 to 3.6.9 --- 2.7-onbuild/Dockerfile | 2 +- 2.7-slim/Dockerfile | 2 +- 2.7/Dockerfile | 2 +- 3.6-onbuild/Dockerfile | 2 +- 3.6-slim/Dockerfile | 2 +- 3.6/Dockerfile | 2 +- 3.7-onbuild/Dockerfile | 2 +- 3.7-slim/Dockerfile | 2 +- 3.7/Dockerfile | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 7620599..934a90d 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -2,7 +2,7 @@ FROM alpine:3.8 # VERSIONS ENV ALPINE_VERSION=3.8 \ - PYTHON_VERSION=2.7.15 + PYTHON_VERSION=2.7.16 # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ diff --git a/2.7-slim/Dockerfile b/2.7-slim/Dockerfile index c9e289e..02d205c 100644 --- a/2.7-slim/Dockerfile +++ b/2.7-slim/Dockerfile @@ -2,7 +2,7 @@ FROM alpine:3.8 # VERSIONS ENV ALPINE_VERSION=3.8 \ - PYTHON_VERSION=2.7.15 + PYTHON_VERSION=2.7.16 ENV PYTHON_PATH=/usr/local/bin/ \ PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin:${PATH}" \ diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 749f21d..655384f 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -2,7 +2,7 @@ FROM alpine:3.8 # VERSIONS ENV ALPINE_VERSION=3.8 \ - PYTHON_VERSION=2.7.15 + PYTHON_VERSION=2.7.16 # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ diff --git a/3.6-onbuild/Dockerfile b/3.6-onbuild/Dockerfile index df1b75c..4ce0ff9 100644 --- a/3.6-onbuild/Dockerfile +++ b/3.6-onbuild/Dockerfile @@ -2,7 +2,7 @@ FROM alpine:3.8 # VERSIONS ENV ALPINE_VERSION=3.8 \ - PYTHON_VERSION=3.6.8 + PYTHON_VERSION=3.6.9 # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ diff --git a/3.6-slim/Dockerfile b/3.6-slim/Dockerfile index 99655a6..7b71da7 100644 --- a/3.6-slim/Dockerfile +++ b/3.6-slim/Dockerfile @@ -2,7 +2,7 @@ FROM alpine:3.8 # VERSIONS ENV ALPINE_VERSION=3.8 \ - PYTHON_VERSION=3.6.8 + PYTHON_VERSION=3.6.9 # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ diff --git a/3.6/Dockerfile b/3.6/Dockerfile index ca96aac..362f426 100644 --- a/3.6/Dockerfile +++ b/3.6/Dockerfile @@ -2,7 +2,7 @@ FROM alpine:3.8 # VERSIONS ENV ALPINE_VERSION=3.8 \ - PYTHON_VERSION=3.6.8 + PYTHON_VERSION=3.6.9 # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ diff --git a/3.7-onbuild/Dockerfile b/3.7-onbuild/Dockerfile index fe6552a..25a773e 100644 --- a/3.7-onbuild/Dockerfile +++ b/3.7-onbuild/Dockerfile @@ -2,7 +2,7 @@ FROM alpine:3.8 # VERSIONS ENV ALPINE_VERSION=3.8 \ - PYTHON_VERSION=3.7.2 + PYTHON_VERSION=3.7.3 # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ diff --git a/3.7-slim/Dockerfile b/3.7-slim/Dockerfile index 9ce634c..c7e32cf 100644 --- a/3.7-slim/Dockerfile +++ b/3.7-slim/Dockerfile @@ -2,7 +2,7 @@ FROM alpine:3.8 # VERSIONS ENV ALPINE_VERSION=3.8 \ - PYTHON_VERSION=3.7.2 + PYTHON_VERSION=3.7.3 # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ diff --git a/3.7/Dockerfile b/3.7/Dockerfile index 2ba00bb..902cdac 100644 --- a/3.7/Dockerfile +++ b/3.7/Dockerfile @@ -2,7 +2,7 @@ FROM alpine:3.8 # VERSIONS ENV ALPINE_VERSION=3.8 \ - PYTHON_VERSION=3.7.2 + PYTHON_VERSION=3.7.3 # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ From 934a5b6c8f40a311b5819ee836688ed3fea51d92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Tue, 23 Jul 2019 18:27:11 +0100 Subject: [PATCH 41/55] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1f2f2d5..76362d4 100644 --- a/README.md +++ b/README.md @@ -222,10 +222,12 @@ docker run --rm -ti jfloff/alpine-python:2.7-slim bash These are some of the images that use `jfloff/alpine-python` as base image. *If you have another image that uses this as base image, please submit an issue or PR for it to be added. Image has to be published on Docker Hub.* - **[jfloff/alscipy](https://github.com/jfloff/docker-alscipy)** [![Docker Stars](https://img.shields.io/docker/stars/jfloff/alscipy.svg)][alscipy-hub] [![Docker Pulls](https://img.shields.io/docker/pulls/jfloff/alscipy.svg)][alscipy-hub] : image with common packages for Science in Alpine Python. -- **[jfloff/pywfm](https://github.com/jfloff/pywfm)** [![Docker Stars](https://img.shields.io/docker/stars/jfloff/pywfm.svg)][pywfm-hub] [![Docker Pulls](https://img.shields.io/docker/pulls/jfloff/pywfm.svg)][pywfm-hub] : image from the python wrapper for Steffen Rendle's factorization machines library libFM. +- **[jfloff/pywfm](https://github.com/jfloff/docker-pywfm)** [![Docker Stars](https://img.shields.io/docker/stars/jfloff/pywfm.svg)][pywfm-hub] [![Docker Pulls](https://img.shields.io/docker/pulls/jfloff/pywfm.svg)][pywfm-hub] : image from the python wrapper for Steffen Rendle's factorization machines library libFM. +- **[bismuthfoundation/Bismuth-Docker](https://github.com/bismuthfoundation/Bismuth-Docker)** [![Docker Stars](https://img.shields.io/docker/stars/eggdrasyl/bismuth-node.svg)][busmuth-hub] [![Docker Pulls](https://img.shields.io/docker/pulls/eggdrasyl/bismuth-node.svg)][busmuth-hub] : node and associated services, from scratch crypto-currency with Python codebase. [alscipy-hub]: https://hub.docker.com/r/jfloff/alscipy/ -[pywfm-hub]: https://hub.docker.com/r/jfloff/alscipy/ +[pywfm-hub]: https://hub.docker.com/r/jfloff/pywfm/ +[busmuth-hub]: https://hub.docker.com/r/eggdrasyl/bismuth-node/ From 2150d83a7845387a6db739be50bd68d23501c763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Mon, 23 Sep 2019 13:49:23 +0100 Subject: [PATCH 42/55] Add permissions for entrypoint.sh inside containers --- 2.7-onbuild/Dockerfile | 10 ++++++---- 2.7-slim/Dockerfile | 10 ++++++---- 3.6-onbuild/Dockerfile | 10 ++++++---- 3.6-slim/Dockerfile | 10 ++++++---- 3.7-onbuild/Dockerfile | 10 ++++++---- 3.7-slim/Dockerfile | 10 ++++++---- 6 files changed, 36 insertions(+), 24 deletions(-) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 934a90d..89143ce 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -57,6 +57,9 @@ ENV PYTHON_PATH=/usr/local/bin/ \ git \ " +# Copy in the entrypoint script -- this installs prerequisites on container start. +COPY entrypoint.sh /entrypoint.sh + RUN set -ex ;\ # find MAJOR and MINOR python versions based on $PYTHON_VERSION export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ @@ -102,10 +105,9 @@ RUN set -ex ;\ ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ - rm -rf /var/cache/apk/* - -# Copy in the entrypoint script -- this installs prerequisites on container start. -COPY entrypoint.sh /entrypoint.sh + rm -rf /var/cache/apk/* ;\ + # set proper permission to run entrypoint script + chmod /entrypoint.sh a+x # install requirements # this way when you build you won't need to install again diff --git a/2.7-slim/Dockerfile b/2.7-slim/Dockerfile index 02d205c..583c615 100644 --- a/2.7-slim/Dockerfile +++ b/2.7-slim/Dockerfile @@ -55,6 +55,9 @@ ENV PYTHON_PATH=/usr/local/bin/ \ git \ " +# Copy in the entrypoint script -- this installs prerequisites on container start. +COPY entrypoint.sh /entrypoint.sh + RUN set -ex ;\ # find MAJOR and MINOR python versions based on $PYTHON_VERSION export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ @@ -98,10 +101,9 @@ RUN set -ex ;\ ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ - rm -rf /var/cache/apk/* - -# Copy in the entrypoint script -- this installs prerequisites on container start. -COPY entrypoint.sh /entrypoint.sh + rm -rf /var/cache/apk/* ;\ + # set proper permission to run entrypoint script + chmod /entrypoint.sh a+x # This script installs APK and Pip prerequisites on container start, or ONBUILD. Notes: # * Reads the -a flags and /apk-requirements.txt for install requests diff --git a/3.6-onbuild/Dockerfile b/3.6-onbuild/Dockerfile index 4ce0ff9..fa987e9 100644 --- a/3.6-onbuild/Dockerfile +++ b/3.6-onbuild/Dockerfile @@ -57,6 +57,9 @@ ENV PYTHON_PATH=/usr/local/bin/ \ git \ " +# Copy in the entrypoint script -- this installs prerequisites on container start. +COPY entrypoint.sh /entrypoint.sh + RUN set -ex ;\ # find MAJOR and MINOR python versions based on $PYTHON_VERSION export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ @@ -102,10 +105,9 @@ RUN set -ex ;\ ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ - rm -rf /var/cache/apk/* - -# Copy in the entrypoint script -- this installs prerequisites on container start. -COPY entrypoint.sh /entrypoint.sh + rm -rf /var/cache/apk/* ;\ + # set proper permission to run entrypoint script + chmod /entrypoint.sh a+x # install requirements # this way when you build you won't need to install again diff --git a/3.6-slim/Dockerfile b/3.6-slim/Dockerfile index 7b71da7..930c6be 100644 --- a/3.6-slim/Dockerfile +++ b/3.6-slim/Dockerfile @@ -56,6 +56,9 @@ ENV PYTHON_PATH=/usr/local/bin/ \ git \ " +# Copy in the entrypoint script -- this installs prerequisites on container start. +COPY entrypoint.sh /entrypoint.sh + RUN set -ex ;\ # find MAJOR and MINOR python versions based on $PYTHON_VERSION export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ @@ -99,10 +102,9 @@ RUN set -ex ;\ ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ - rm -rf /var/cache/apk/* - -# Copy in the entrypoint script -- this installs prerequisites on container start. -COPY entrypoint.sh /entrypoint.sh + rm -rf /var/cache/apk/* ;\ + # set proper permission to run entrypoint script + chmod /entrypoint.sh a+x # This script installs APK and Pip prerequisites on container start, or ONBUILD. Notes: # * Reads the -a flags and /apk-requirements.txt for install requests diff --git a/3.7-onbuild/Dockerfile b/3.7-onbuild/Dockerfile index 25a773e..233943d 100644 --- a/3.7-onbuild/Dockerfile +++ b/3.7-onbuild/Dockerfile @@ -57,6 +57,9 @@ ENV PYTHON_PATH=/usr/local/bin/ \ git \ " +# Copy in the entrypoint script -- this installs prerequisites on container start. +COPY entrypoint.sh /entrypoint.sh + RUN set -ex ;\ # find MAJOR and MINOR python versions based on $PYTHON_VERSION export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ @@ -102,10 +105,9 @@ RUN set -ex ;\ ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ - rm -rf /var/cache/apk/* - -# Copy in the entrypoint script -- this installs prerequisites on container start. -COPY entrypoint.sh /entrypoint.sh + rm -rf /var/cache/apk/* ;\ + # set proper permission to run entrypoint script + chmod /entrypoint.sh a+x # install requirements # this way when you build you won't need to install again diff --git a/3.7-slim/Dockerfile b/3.7-slim/Dockerfile index c7e32cf..ff979b6 100644 --- a/3.7-slim/Dockerfile +++ b/3.7-slim/Dockerfile @@ -56,6 +56,9 @@ ENV PYTHON_PATH=/usr/local/bin/ \ git \ " +# Copy in the entrypoint script -- this installs prerequisites on container start. +COPY entrypoint.sh /entrypoint.sh + RUN set -ex ;\ # find MAJOR and MINOR python versions based on $PYTHON_VERSION export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ @@ -99,10 +102,9 @@ RUN set -ex ;\ ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ - rm -rf /var/cache/apk/* - -# Copy in the entrypoint script -- this installs prerequisites on container start. -COPY entrypoint.sh /entrypoint.sh + rm -rf /var/cache/apk/* ;\ + # set proper permission to run entrypoint script + chmod /entrypoint.sh a+x # This script installs APK and Pip prerequisites on container start, or ONBUILD. Notes: # * Reads the -a flags and /apk-requirements.txt for install requests From a700908156d395acb28a6f0bf1eb5eaad00c77f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Mon, 23 Sep 2019 13:55:54 +0100 Subject: [PATCH 43/55] Fix previous commit ... --- 2.7-onbuild/Dockerfile | 2 +- 2.7-slim/Dockerfile | 2 +- 3.6-onbuild/Dockerfile | 2 +- 3.6-slim/Dockerfile | 2 +- 3.7-onbuild/Dockerfile | 2 +- 3.7-slim/Dockerfile | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 89143ce..95b1340 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -107,7 +107,7 @@ RUN set -ex ;\ apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* ;\ # set proper permission to run entrypoint script - chmod /entrypoint.sh a+x + chmod a+x /entrypoint.sh # install requirements # this way when you build you won't need to install again diff --git a/2.7-slim/Dockerfile b/2.7-slim/Dockerfile index 583c615..883ccdf 100644 --- a/2.7-slim/Dockerfile +++ b/2.7-slim/Dockerfile @@ -103,7 +103,7 @@ RUN set -ex ;\ apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* ;\ # set proper permission to run entrypoint script - chmod /entrypoint.sh a+x + chmod a+x /entrypoint.sh # This script installs APK and Pip prerequisites on container start, or ONBUILD. Notes: # * Reads the -a flags and /apk-requirements.txt for install requests diff --git a/3.6-onbuild/Dockerfile b/3.6-onbuild/Dockerfile index fa987e9..6d264c1 100644 --- a/3.6-onbuild/Dockerfile +++ b/3.6-onbuild/Dockerfile @@ -107,7 +107,7 @@ RUN set -ex ;\ apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* ;\ # set proper permission to run entrypoint script - chmod /entrypoint.sh a+x + chmod a+x /entrypoint.sh # install requirements # this way when you build you won't need to install again diff --git a/3.6-slim/Dockerfile b/3.6-slim/Dockerfile index 930c6be..72b2847 100644 --- a/3.6-slim/Dockerfile +++ b/3.6-slim/Dockerfile @@ -104,7 +104,7 @@ RUN set -ex ;\ apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* ;\ # set proper permission to run entrypoint script - chmod /entrypoint.sh a+x + chmod a+x /entrypoint.sh # This script installs APK and Pip prerequisites on container start, or ONBUILD. Notes: # * Reads the -a flags and /apk-requirements.txt for install requests diff --git a/3.7-onbuild/Dockerfile b/3.7-onbuild/Dockerfile index 233943d..63c9758 100644 --- a/3.7-onbuild/Dockerfile +++ b/3.7-onbuild/Dockerfile @@ -107,7 +107,7 @@ RUN set -ex ;\ apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* ;\ # set proper permission to run entrypoint script - chmod /entrypoint.sh a+x + chmod a+x /entrypoint.sh # install requirements # this way when you build you won't need to install again diff --git a/3.7-slim/Dockerfile b/3.7-slim/Dockerfile index ff979b6..7157086 100644 --- a/3.7-slim/Dockerfile +++ b/3.7-slim/Dockerfile @@ -104,7 +104,7 @@ RUN set -ex ;\ apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* ;\ # set proper permission to run entrypoint script - chmod /entrypoint.sh a+x + chmod a+x /entrypoint.sh # This script installs APK and Pip prerequisites on container start, or ONBUILD. Notes: # * Reads the -a flags and /apk-requirements.txt for install requests From 7bbb825e44dead5eaf1219fbc1d68e15b36579fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Mon, 23 Sep 2019 15:09:53 +0100 Subject: [PATCH 44/55] Install APK requirements after removing build requirements - this could be better by using apk groups WIP --- 2.7-onbuild/entrypoint.sh | 3 +++ 2.7-slim/entrypoint.sh | 3 +++ 3.6-onbuild/entrypoint.sh | 3 +++ 3.6-slim/entrypoint.sh | 3 +++ 3.7-onbuild/entrypoint.sh | 3 +++ 3.7-slim/entrypoint.sh | 3 +++ 6 files changed, 18 insertions(+) diff --git a/2.7-onbuild/entrypoint.sh b/2.7-onbuild/entrypoint.sh index 901491a..05fef2d 100755 --- a/2.7-onbuild/entrypoint.sh +++ b/2.7-onbuild/entrypoint.sh @@ -135,6 +135,9 @@ if [[ ! -f /requirements.installed ]]; then # Remove packages that were only required for build. apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" + vlog "Installing APK requirements..." + apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" + touch /requirements.installed else vlog "/requirements.installed file exists-- skipping requirements installs." diff --git a/2.7-slim/entrypoint.sh b/2.7-slim/entrypoint.sh index 901491a..05fef2d 100755 --- a/2.7-slim/entrypoint.sh +++ b/2.7-slim/entrypoint.sh @@ -135,6 +135,9 @@ if [[ ! -f /requirements.installed ]]; then # Remove packages that were only required for build. apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" + vlog "Installing APK requirements..." + apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" + touch /requirements.installed else vlog "/requirements.installed file exists-- skipping requirements installs." diff --git a/3.6-onbuild/entrypoint.sh b/3.6-onbuild/entrypoint.sh index 901491a..05fef2d 100755 --- a/3.6-onbuild/entrypoint.sh +++ b/3.6-onbuild/entrypoint.sh @@ -135,6 +135,9 @@ if [[ ! -f /requirements.installed ]]; then # Remove packages that were only required for build. apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" + vlog "Installing APK requirements..." + apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" + touch /requirements.installed else vlog "/requirements.installed file exists-- skipping requirements installs." diff --git a/3.6-slim/entrypoint.sh b/3.6-slim/entrypoint.sh index 901491a..05fef2d 100755 --- a/3.6-slim/entrypoint.sh +++ b/3.6-slim/entrypoint.sh @@ -135,6 +135,9 @@ if [[ ! -f /requirements.installed ]]; then # Remove packages that were only required for build. apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" + vlog "Installing APK requirements..." + apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" + touch /requirements.installed else vlog "/requirements.installed file exists-- skipping requirements installs." diff --git a/3.7-onbuild/entrypoint.sh b/3.7-onbuild/entrypoint.sh index 901491a..05fef2d 100755 --- a/3.7-onbuild/entrypoint.sh +++ b/3.7-onbuild/entrypoint.sh @@ -135,6 +135,9 @@ if [[ ! -f /requirements.installed ]]; then # Remove packages that were only required for build. apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" + vlog "Installing APK requirements..." + apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" + touch /requirements.installed else vlog "/requirements.installed file exists-- skipping requirements installs." diff --git a/3.7-slim/entrypoint.sh b/3.7-slim/entrypoint.sh index 901491a..05fef2d 100644 --- a/3.7-slim/entrypoint.sh +++ b/3.7-slim/entrypoint.sh @@ -135,6 +135,9 @@ if [[ ! -f /requirements.installed ]]; then # Remove packages that were only required for build. apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" + vlog "Installing APK requirements..." + apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" + touch /requirements.installed else vlog "/requirements.installed file exists-- skipping requirements installs." From 7eb7290b5f115879f872606c7343dc36cd7f94c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Mon, 23 Sep 2019 15:37:29 +0100 Subject: [PATCH 45/55] Fix entrypoint --- 2.7-onbuild/entrypoint.sh | 2 +- 2.7-slim/entrypoint.sh | 2 +- 3.6-onbuild/entrypoint.sh | 2 +- 3.6-slim/entrypoint.sh | 2 +- 3.7-onbuild/entrypoint.sh | 2 +- 3.7-slim/entrypoint.sh | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/2.7-onbuild/entrypoint.sh b/2.7-onbuild/entrypoint.sh index 05fef2d..195ee87 100755 --- a/2.7-onbuild/entrypoint.sh +++ b/2.7-onbuild/entrypoint.sh @@ -136,7 +136,7 @@ if [[ ! -f /requirements.installed ]]; then apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" vlog "Installing APK requirements..." - apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" + apk add $APK_FLAGS "${APK_REQUIREMENTS[@]}" touch /requirements.installed else diff --git a/2.7-slim/entrypoint.sh b/2.7-slim/entrypoint.sh index 05fef2d..195ee87 100755 --- a/2.7-slim/entrypoint.sh +++ b/2.7-slim/entrypoint.sh @@ -136,7 +136,7 @@ if [[ ! -f /requirements.installed ]]; then apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" vlog "Installing APK requirements..." - apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" + apk add $APK_FLAGS "${APK_REQUIREMENTS[@]}" touch /requirements.installed else diff --git a/3.6-onbuild/entrypoint.sh b/3.6-onbuild/entrypoint.sh index 05fef2d..195ee87 100755 --- a/3.6-onbuild/entrypoint.sh +++ b/3.6-onbuild/entrypoint.sh @@ -136,7 +136,7 @@ if [[ ! -f /requirements.installed ]]; then apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" vlog "Installing APK requirements..." - apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" + apk add $APK_FLAGS "${APK_REQUIREMENTS[@]}" touch /requirements.installed else diff --git a/3.6-slim/entrypoint.sh b/3.6-slim/entrypoint.sh index 05fef2d..195ee87 100755 --- a/3.6-slim/entrypoint.sh +++ b/3.6-slim/entrypoint.sh @@ -136,7 +136,7 @@ if [[ ! -f /requirements.installed ]]; then apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" vlog "Installing APK requirements..." - apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" + apk add $APK_FLAGS "${APK_REQUIREMENTS[@]}" touch /requirements.installed else diff --git a/3.7-onbuild/entrypoint.sh b/3.7-onbuild/entrypoint.sh index 05fef2d..195ee87 100755 --- a/3.7-onbuild/entrypoint.sh +++ b/3.7-onbuild/entrypoint.sh @@ -136,7 +136,7 @@ if [[ ! -f /requirements.installed ]]; then apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" vlog "Installing APK requirements..." - apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" + apk add $APK_FLAGS "${APK_REQUIREMENTS[@]}" touch /requirements.installed else diff --git a/3.7-slim/entrypoint.sh b/3.7-slim/entrypoint.sh index 05fef2d..195ee87 100644 --- a/3.7-slim/entrypoint.sh +++ b/3.7-slim/entrypoint.sh @@ -136,7 +136,7 @@ if [[ ! -f /requirements.installed ]]; then apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" vlog "Installing APK requirements..." - apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" + apk add $APK_FLAGS "${APK_REQUIREMENTS[@]}" touch /requirements.installed else From 224ec454e28b9289d30fd3d1d7c8e292b2730809 Mon Sep 17 00:00:00 2001 From: Yuriy Shatrov Date: Wed, 18 Dec 2019 17:48:46 +0300 Subject: [PATCH 46/55] Add Python 3.8 support (#65) This PR adds support for Python 3.8.0 within a series of 3.8 tags similar to previous versions. Closes #64 --- 3.8-onbuild/Dockerfile | 123 ++++++++++++++++++++++++++++++ 3.8-onbuild/entrypoint.sh | 153 ++++++++++++++++++++++++++++++++++++++ 3.8-slim/Dockerfile | 115 ++++++++++++++++++++++++++++ 3.8-slim/entrypoint.sh | 153 ++++++++++++++++++++++++++++++++++++++ 3.8/Dockerfile | 112 ++++++++++++++++++++++++++++ 5 files changed, 656 insertions(+) create mode 100644 3.8-onbuild/Dockerfile create mode 100755 3.8-onbuild/entrypoint.sh create mode 100644 3.8-slim/Dockerfile create mode 100644 3.8-slim/entrypoint.sh create mode 100644 3.8/Dockerfile diff --git a/3.8-onbuild/Dockerfile b/3.8-onbuild/Dockerfile new file mode 100644 index 0000000..0f67794 --- /dev/null +++ b/3.8-onbuild/Dockerfile @@ -0,0 +1,123 @@ +FROM alpine:3.8 + +# VERSIONS +ENV ALPINE_VERSION=3.8 \ + PYTHON_VERSION=3.8.0 + +# PATHS +ENV PYTHON_PATH=/usr/local/bin/ \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin:${PATH}" \ + # These are always installed. + # * dumb-init: a proper init system for containers, to reap zombie children + # * musl: standard C library + # * lib6-compat: compatibility libraries for glibc + # * linux-headers: commonly needed, and an unusual package name from Alpine. + # * build-base: used so we include the basic development packages (gcc) + # * bash: so we can access /bin/bash + # * git: to ease up clones of repos + # * ca-certificates: for SSL verification during Pip and easy_install + PACKAGES="\ + dumb-init \ + musl \ + libc6-compat \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ + libssl1.0 \ + tzdata \ + " \ + # PACKAGES needed to built python + PYTHON_BUILD_PACKAGES="\ + bzip2-dev \ + coreutils \ + dpkg \ + dpkg-dev \ + expat-dev \ + findutils \ + gcc \ + gdbm-dev \ + libc-dev \ + libffi-dev \ + libnsl-dev \ + libtirpc-dev \ + linux-headers \ + make \ + ncurses-dev \ + libressl-dev \ + pax-utils \ + readline-dev \ + sqlite-dev \ + tcl-dev \ + tk \ + tk-dev \ + util-linux-dev \ + xz-dev \ + zlib-dev \ + " + +# Copy in the entrypoint script -- this installs prerequisites on container start. +COPY entrypoint.sh /entrypoint.sh + +RUN set -ex ;\ + # find MAJOR and MINOR python versions based on $PYTHON_VERSION + export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ + export PYTHON_MINOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f2- | rev) ;\ + # replacing default repositories with edge ones + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories ;\ + # Add the packages, with a CDN-breakage fallback if needed + apk add --no-cache $PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) ;\ + # Add packages just for the python build process with a CDN-breakage fallback if needed + apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES) ;\ + # turn back the clock -- so hacky! + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories ;\ + # echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ + # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ + # use pyenv to download and compile specific python version + git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ + # install + GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip --with-shared" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # keep the needed .so files + # ignore libpython - that one comes from the pyenv instalation + find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | grep -ve 'libpython' \ + | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ + # for debug + # | xargs -n1 echo ;\ + # delete everything from pyenv except the installed version + # this throws an error but we ignore it + find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ + # delete files to to reduce container size + # tips taken from main python docker repo + find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + # set timezone info + ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ + # remove build dependencies and any leftover apk cache + apk del --no-cache --purge .build-deps ;\ + rm -rf /var/cache/apk/* ;\ + # set proper permission to run entrypoint script + chmod a+x /entrypoint.sh + +# install requirements +# this way when you build you won't need to install again +# and since COPY is cached we don't need to wait +ONBUILD COPY requirements.txt /tmp/requirements.txt + +# Run the dependencies installer and then allow it to be run again if needed. +ONBUILD RUN /entrypoint.sh -r /tmp/requirements.txt +ONBUILD RUN rm -f /requirements.installed + +# since we will be "always" mounting the volume, we can set this up +ENTRYPOINT ["/usr/bin/dumb-init"] +CMD ["python"] diff --git a/3.8-onbuild/entrypoint.sh b/3.8-onbuild/entrypoint.sh new file mode 100755 index 0000000..50c2ab1 --- /dev/null +++ b/3.8-onbuild/entrypoint.sh @@ -0,0 +1,153 @@ +#!/usr/bin/dumb-init /bin/bash +set -e + +APK_REQUIREMENTS=() +BUILD_REQUIREMENTS=() +PIP_REQUIREMENTS=() +APKFILE='/apk-requirements.txt' +BUILDFILE='/build-requirements.txt' +REQFILE='/requirements.txt' +VERBOSITY=1 + +TMP_REQFILE='/tmp/requirements.txt' + +function usage () { + cat <<"EOF" +Usage: $0 [-a -b -p -A -B -P -r -q -x] [--] + -a : APK requirement. Can be specified multiple times. + -b : APK build requirement. These will be removed at the end to save space. + -p : Pip requirement. Can be specified multiple times. + + -A : apk-requirements.txt file location, default: /apk-requirements.txt + -B : build-requirements.txt file location, default: /build-requirements.txt + -P : requirements.txt file location, default: /requirements.txt + -r : same as above, just to match Pip's -r flag. + + -q : quiet, doesn't print anything at all. + -x : Bash debug mode. Extremely verbose! + + -- : Separator for flags and your command + + Whatever you provide after your arguments is run at the end. +EOF + exit 1 +} + +function vlog () { + if [ $VERBOSITY -gt 0 ]; then + echo $1 + fi +} + +# Get and process arguments +while getopts ":a:b:p:A:B:P:r:qx" opt; do + case $opt in + a) APK_REQUIREMENTS+=("$OPTARG") ;; + b) BUILD_REQUIREMENTS+=("$OPTARG") ;; + p) PIP_REQUIREMENTS+=("$OPTARG") ;; + A) APKFILE="$OPTARG" ;; + B) BUILDFILE="$OPTARG" ;; + P) REQFILE="$OPTARG" ;; + r) REQFILE="$OPTARG" ;; + q) VERBOSITY=0 ;; + x) set -x ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + usage + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + usage + ;; + esac +done + +# Bad arguments +if [ $? -ne 0 ]; +then + usage +fi + +# Strip out all the arguments that have been processed +shift $((OPTIND-1)) + +# If there's a double dash at the end, get that off +[[ $1 = "--" ]] && shift + +# Make some common flags objects +PIP_FLAGS='' +if [ $VERBOSITY -eq 0 ]; then + PIP_FLAGS="$PIP_FLAGS -q" +fi + +APK_FLAGS='--no-cache --no-progress' +if [ $VERBOSITY -eq 0 ]; then + APK_FLAGS="$APK_FLAGS -q" +fi + +# Don't do anything if we've already done this. +if [[ ! -f /requirements.installed ]]; then + vlog "First run, checking for any requirements..." + + # Install any APK requirements + if [[ -f "$APKFILE" ]]; then + vlog "APK requirements file detected!" + APK_REQUIREMENTS+=($( cat "$APKFILE" )) + fi + + if [[ -f "$BUILDFILE" ]]; then + vlog "Build requirements file detected!" + BUILD_REQUIREMENTS+=($( cat "$BUILDFILE" )) + fi + + # Unfortunately the Alpine repositories are in a slightly inconsistent state for now-- python2 only exists in 'edge', not main. + # if [[ "$PYTHON_VERSION" == '2' ]]; then BUILD_PACKAGES="$(echo $BUILD_PACKAGES | sed -e 's/python2/python/g')"; fi \ + vlog "Installing all APK requirements..." + apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" + + # Install any Pip requirements + if [[ -f "$REQFILE" && "$(cat $REQFILE | wc -l)" -gt 0 ]]; then + # Do this check a little early-- since we merge cli in with file, + # we'd get a false positive for logging otherwise. + vlog "Pip requirements file detected!" + fi + + # If we use CLI parameters, we'll have to reassign this. + TARGET_REQFILE="$REQFILE" + if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then + # Put all Pip requirements into the same file. + printf "%s\n" "${PIP_REQUIREMENTS[@]}" >> "$TMP_REQFILE" + + if [[ -f "$REQFILE" && "$(cat $REQFILE | wc -l)" -gt 0 ]]; then + cat "$REQFILE" >> "$TMP_REQFILE" + fi + + TARGET_REQFILE="$TMP_REQFILE" + fi + + if [[ -f $TARGET_REQFILE && "$(cat $TARGET_REQFILE | wc -l)" -gt 0 ]]; then + vlog "Upgrading Pip..." + pip install $PIP_FLAGS --upgrade pip + vlog "Installing all Pip requirements..." + pip install $PIP_FLAGS -r "$TARGET_REQFILE" + fi + + # Remove packages that were only required for build. + apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" + + vlog "Installing APK requirements..." + apk add $APK_FLAGS "${APK_REQUIREMENTS[@]}" + + touch /requirements.installed +else + vlog "/requirements.installed file exists-- skipping requirements installs." +fi + + +if [[ ! -z "$@" ]]; then + # If the user has given us a command, run it. + $@ +else + # Otherwise, default to running 'python'. + python +fi diff --git a/3.8-slim/Dockerfile b/3.8-slim/Dockerfile new file mode 100644 index 0000000..cff3d87 --- /dev/null +++ b/3.8-slim/Dockerfile @@ -0,0 +1,115 @@ +FROM alpine:3.8 + +# VERSIONS +ENV ALPINE_VERSION=3.8 \ + PYTHON_VERSION=3.8.0 + +# PATHS +ENV PYTHON_PATH=/usr/local/bin/ \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin:${PATH}" \ + # These are always installed. Notes: + # * dumb-init: a proper init system for containers, to reap zombie children + # * bash: For entrypoint, and debugging + # * ca-certificates: for SSL verification during Pip and easy_install + PACKAGES="\ + dumb-init \ + bash \ + ca-certificates \ + " \ + # PACKAGES needed to built python + PYTHON_BUILD_PACKAGES="\ + bzip2-dev \ + coreutils \ + dpkg \ + dpkg-dev \ + expat-dev \ + findutils \ + gcc \ + gdbm-dev \ + git \ + libc-dev \ + libffi-dev \ + libnsl-dev \ + libtirpc-dev \ + linux-headers \ + make \ + ncurses-dev \ + libressl-dev \ + pax-utils \ + readline-dev \ + sqlite-dev \ + tcl-dev \ + tk \ + tk-dev \ + util-linux-dev \ + xz-dev \ + zlib-dev \ + " \ + # These packages are not installed immediately, but are added at runtime or ONBUILD to shrink the image as much as possible. Notes: + # * build-base: used so we include the basic development packages (gcc) + # * linux-headers: commonly needed, and an unusual package name from Alpine. + # * lib6-compat: compatibility libraries for glibc + # * git: to ease up clones of repos + BUILD_PACKAGES="\ + build-base \ + linux-headers \ + libc6-compat \ + git \ + " + +# Copy in the entrypoint script -- this installs prerequisites on container start. +COPY entrypoint.sh /entrypoint.sh + +RUN set -ex ;\ + # find MAJOR and MINOR python versions based on $PYTHON_VERSION + export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ + export PYTHON_MINOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f2- | rev) ;\ + # replacing default repositories with edge ones + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories ;\ + # Add the packages, with a CDN-breakage fallback if needed + apk add --no-cache $PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) ;\ + # Add packages just for the python build process with a CDN-breakage fallback if needed + apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES) ;\ + # turn back the clock -- so hacky! + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories ;\ + # echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ + # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ + # use pyenv to download and compile specific python version + git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ + # install + GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip --with-shared" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # keep the needed .so files + # ignore libpython - that one comes from the pyenv instalation + find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | grep -ve 'libpython' \ + | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ + # for debug + # | xargs -n1 echo ;\ + # delete everything from pyenv except the installed version + # this throws an error but we ignore it + find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ + # delete files to to reduce container size + # tips taken from main python docker repo + find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + # remove build dependencies and any leftover apk cache + apk del --no-cache --purge .build-deps ;\ + rm -rf /var/cache/apk/* ;\ + # set proper permission to run entrypoint script + chmod a+x /entrypoint.sh + +# This script installs APK and Pip prerequisites on container start, or ONBUILD. Notes: +# * Reads the -a flags and /apk-requirements.txt for install requests +# * Reads the -b flags and /build-requirements.txt for build packages -- removed when build is complete +# * Reads the -p flags and /requirements.txt for Pip packages +# * Reads the -r flag to specify a different file path for /requirements.txt +ENTRYPOINT ["/usr/bin/dumb-init", "bash", "/entrypoint.sh"] diff --git a/3.8-slim/entrypoint.sh b/3.8-slim/entrypoint.sh new file mode 100644 index 0000000..50c2ab1 --- /dev/null +++ b/3.8-slim/entrypoint.sh @@ -0,0 +1,153 @@ +#!/usr/bin/dumb-init /bin/bash +set -e + +APK_REQUIREMENTS=() +BUILD_REQUIREMENTS=() +PIP_REQUIREMENTS=() +APKFILE='/apk-requirements.txt' +BUILDFILE='/build-requirements.txt' +REQFILE='/requirements.txt' +VERBOSITY=1 + +TMP_REQFILE='/tmp/requirements.txt' + +function usage () { + cat <<"EOF" +Usage: $0 [-a -b -p -A -B -P -r -q -x] [--] + -a : APK requirement. Can be specified multiple times. + -b : APK build requirement. These will be removed at the end to save space. + -p : Pip requirement. Can be specified multiple times. + + -A : apk-requirements.txt file location, default: /apk-requirements.txt + -B : build-requirements.txt file location, default: /build-requirements.txt + -P : requirements.txt file location, default: /requirements.txt + -r : same as above, just to match Pip's -r flag. + + -q : quiet, doesn't print anything at all. + -x : Bash debug mode. Extremely verbose! + + -- : Separator for flags and your command + + Whatever you provide after your arguments is run at the end. +EOF + exit 1 +} + +function vlog () { + if [ $VERBOSITY -gt 0 ]; then + echo $1 + fi +} + +# Get and process arguments +while getopts ":a:b:p:A:B:P:r:qx" opt; do + case $opt in + a) APK_REQUIREMENTS+=("$OPTARG") ;; + b) BUILD_REQUIREMENTS+=("$OPTARG") ;; + p) PIP_REQUIREMENTS+=("$OPTARG") ;; + A) APKFILE="$OPTARG" ;; + B) BUILDFILE="$OPTARG" ;; + P) REQFILE="$OPTARG" ;; + r) REQFILE="$OPTARG" ;; + q) VERBOSITY=0 ;; + x) set -x ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + usage + ;; + :) + echo "Option -$OPTARG requires an argument." >&2 + usage + ;; + esac +done + +# Bad arguments +if [ $? -ne 0 ]; +then + usage +fi + +# Strip out all the arguments that have been processed +shift $((OPTIND-1)) + +# If there's a double dash at the end, get that off +[[ $1 = "--" ]] && shift + +# Make some common flags objects +PIP_FLAGS='' +if [ $VERBOSITY -eq 0 ]; then + PIP_FLAGS="$PIP_FLAGS -q" +fi + +APK_FLAGS='--no-cache --no-progress' +if [ $VERBOSITY -eq 0 ]; then + APK_FLAGS="$APK_FLAGS -q" +fi + +# Don't do anything if we've already done this. +if [[ ! -f /requirements.installed ]]; then + vlog "First run, checking for any requirements..." + + # Install any APK requirements + if [[ -f "$APKFILE" ]]; then + vlog "APK requirements file detected!" + APK_REQUIREMENTS+=($( cat "$APKFILE" )) + fi + + if [[ -f "$BUILDFILE" ]]; then + vlog "Build requirements file detected!" + BUILD_REQUIREMENTS+=($( cat "$BUILDFILE" )) + fi + + # Unfortunately the Alpine repositories are in a slightly inconsistent state for now-- python2 only exists in 'edge', not main. + # if [[ "$PYTHON_VERSION" == '2' ]]; then BUILD_PACKAGES="$(echo $BUILD_PACKAGES | sed -e 's/python2/python/g')"; fi \ + vlog "Installing all APK requirements..." + apk add $APK_FLAGS $BUILD_PACKAGES "${APK_REQUIREMENTS[@]}" "${BUILD_REQUIREMENTS[@]}" + + # Install any Pip requirements + if [[ -f "$REQFILE" && "$(cat $REQFILE | wc -l)" -gt 0 ]]; then + # Do this check a little early-- since we merge cli in with file, + # we'd get a false positive for logging otherwise. + vlog "Pip requirements file detected!" + fi + + # If we use CLI parameters, we'll have to reassign this. + TARGET_REQFILE="$REQFILE" + if [[ ${#PIP_REQUIREMENTS[@]} -gt 0 ]]; then + # Put all Pip requirements into the same file. + printf "%s\n" "${PIP_REQUIREMENTS[@]}" >> "$TMP_REQFILE" + + if [[ -f "$REQFILE" && "$(cat $REQFILE | wc -l)" -gt 0 ]]; then + cat "$REQFILE" >> "$TMP_REQFILE" + fi + + TARGET_REQFILE="$TMP_REQFILE" + fi + + if [[ -f $TARGET_REQFILE && "$(cat $TARGET_REQFILE | wc -l)" -gt 0 ]]; then + vlog "Upgrading Pip..." + pip install $PIP_FLAGS --upgrade pip + vlog "Installing all Pip requirements..." + pip install $PIP_FLAGS -r "$TARGET_REQFILE" + fi + + # Remove packages that were only required for build. + apk del $APK_FLAGS $BUILD_PACKAGES "${BUILD_REQUIREMENTS[@]}" + + vlog "Installing APK requirements..." + apk add $APK_FLAGS "${APK_REQUIREMENTS[@]}" + + touch /requirements.installed +else + vlog "/requirements.installed file exists-- skipping requirements installs." +fi + + +if [[ ! -z "$@" ]]; then + # If the user has given us a command, run it. + $@ +else + # Otherwise, default to running 'python'. + python +fi diff --git a/3.8/Dockerfile b/3.8/Dockerfile new file mode 100644 index 0000000..f8a2e10 --- /dev/null +++ b/3.8/Dockerfile @@ -0,0 +1,112 @@ +FROM alpine:3.8 + +# VERSIONS +ENV ALPINE_VERSION=3.8 \ + PYTHON_VERSION=3.8.0 + +# PATHS +ENV PYTHON_PATH=/usr/local/bin/ \ + PATH="/usr/local/lib/python$PYTHON_VERSION/bin/:/usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin:${PATH}" \ + # These are always installed. + # * dumb-init: a proper init system for containers, to reap zombie children + # * musl: standard C library + # * lib6-compat: compatibility libraries for glibc + # * linux-headers: commonly needed, and an unusual package name from Alpine. + # * build-base: used so we include the basic development packages (gcc) + # * bash: so we can access /bin/bash + # * git: to ease up clones of repos + # * ca-certificates: for SSL verification during Pip and easy_install + PACKAGES="\ + dumb-init \ + musl \ + libc6-compat \ + linux-headers \ + build-base \ + bash \ + git \ + ca-certificates \ + libssl1.0 \ + libffi-dev \ + tzdata \ + " \ + # PACKAGES needed to built python + PYTHON_BUILD_PACKAGES="\ + bzip2-dev \ + coreutils \ + dpkg \ + dpkg-dev \ + expat-dev \ + findutils \ + gcc \ + gdbm-dev \ + libc-dev \ + libffi-dev \ + libnsl-dev \ + libtirpc-dev \ + linux-headers \ + make \ + ncurses-dev \ + libressl-dev \ + pax-utils \ + readline-dev \ + sqlite-dev \ + tcl-dev \ + tk \ + tk-dev \ + util-linux-dev \ + xz-dev \ + zlib-dev \ + " + +RUN set -ex ;\ + # find MAJOR and MINOR python versions based on $PYTHON_VERSION + export PYTHON_MAJOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f3- | rev) ;\ + export PYTHON_MINOR_VERSION=$(echo "${PYTHON_VERSION}" | rev | cut -d"." -f2- | rev) ;\ + # replacing default repositories with edge ones + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main" >> /etc/apk/repositories ;\ + # Add the packages, with a CDN-breakage fallback if needed + apk add --no-cache $PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache $PACKAGES) ;\ + # Add packages just for the python build process with a CDN-breakage fallback if needed + apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES || \ + (sed -i -e 's/dl-cdn/dl-4/g' /etc/apk/repositories && apk add --no-cache --virtual .build-deps $PYTHON_BUILD_PACKAGES) ;\ + # turn back the clock -- so hacky! + echo "http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/main/" > /etc/apk/repositories ;\ + # echo "@community http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/community" >> /etc/apk/repositories ;\ + # echo "@testing http://dl-cdn.alpinelinux.org/alpine/v$ALPINE_VERSION/testing" >> /etc/apk/repositories ;\ + # echo "@edge-main http://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories ;\ + # use pyenv to download and compile specific python version + git clone --depth 1 https://github.com/pyenv/pyenv /usr/local/lib/pyenv ;\ + # install + GNU_ARCH="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" ;\ + # flag explanation: + # --with-shared : python-dev + PYENV_ROOT=/usr/local/lib/pyenv CONFIGURE_OPTS="--build=$GNU_ARCH --enable-loadable-sqlite-extensions --enable-shared --with-system-expat --with-system-ffi --without-ensurepip --with-shared" /usr/local/lib/pyenv/bin/pyenv install $PYTHON_VERSION ;\ + # keep the needed .so files + # ignore libpython - that one comes from the pyenv instalation + find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + | grep -ve 'libpython' \ + | xargs -rt apk add --no-cache --virtual .python-rundeps ;\ + # for debug + # | xargs -n1 echo ;\ + # delete everything from pyenv except the installed version + # this throws an error but we ignore it + find /usr/local/lib/pyenv/ -mindepth 1 -name versions -prune -o -exec rm -rf {} \; || true ;\ + # delete files to to reduce container size + # tips taken from main python docker repo + find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ + # symlink the binaries + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + # set timezone info + ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ + # remove build dependencies and any leftover apk cache + apk del --no-cache --purge .build-deps ;\ + rm -rf /var/cache/apk/* + +# since we will be "always" mounting the volume, we can set this up +ENTRYPOINT ["/usr/bin/dumb-init"] +CMD ["python"] From 8f848cbbb1376fbe29b58325e1f2552e14594aad Mon Sep 17 00:00:00 2001 From: Yuriy Shatrov Date: Wed, 18 Dec 2019 17:52:09 +0300 Subject: [PATCH 47/55] Fix usage text output (#63) This PR fixes the issue that the usage text is never printed to the console if invalid arguments were passed to the `entrypoint.sh` script. The culprit is that the `usage` function uses the `< -a : APK requirement. Can be specified multiple times. -b : APK build requirement. These will be removed at the end to save space. diff --git a/2.7-slim/entrypoint.sh b/2.7-slim/entrypoint.sh index 195ee87..50c2ab1 100755 --- a/2.7-slim/entrypoint.sh +++ b/2.7-slim/entrypoint.sh @@ -12,7 +12,7 @@ VERBOSITY=1 TMP_REQFILE='/tmp/requirements.txt' function usage () { - echo <<"EOF" + cat <<"EOF" Usage: $0 [-a -b -p -A -B -P -r -q -x] [--] -a : APK requirement. Can be specified multiple times. -b : APK build requirement. These will be removed at the end to save space. diff --git a/3.6-onbuild/entrypoint.sh b/3.6-onbuild/entrypoint.sh index 195ee87..50c2ab1 100755 --- a/3.6-onbuild/entrypoint.sh +++ b/3.6-onbuild/entrypoint.sh @@ -12,7 +12,7 @@ VERBOSITY=1 TMP_REQFILE='/tmp/requirements.txt' function usage () { - echo <<"EOF" + cat <<"EOF" Usage: $0 [-a -b -p -A -B -P -r -q -x] [--] -a : APK requirement. Can be specified multiple times. -b : APK build requirement. These will be removed at the end to save space. diff --git a/3.6-slim/entrypoint.sh b/3.6-slim/entrypoint.sh index 195ee87..50c2ab1 100755 --- a/3.6-slim/entrypoint.sh +++ b/3.6-slim/entrypoint.sh @@ -12,7 +12,7 @@ VERBOSITY=1 TMP_REQFILE='/tmp/requirements.txt' function usage () { - echo <<"EOF" + cat <<"EOF" Usage: $0 [-a -b -p -A -B -P -r -q -x] [--] -a : APK requirement. Can be specified multiple times. -b : APK build requirement. These will be removed at the end to save space. diff --git a/3.7-onbuild/entrypoint.sh b/3.7-onbuild/entrypoint.sh index 195ee87..50c2ab1 100755 --- a/3.7-onbuild/entrypoint.sh +++ b/3.7-onbuild/entrypoint.sh @@ -12,7 +12,7 @@ VERBOSITY=1 TMP_REQFILE='/tmp/requirements.txt' function usage () { - echo <<"EOF" + cat <<"EOF" Usage: $0 [-a -b -p -A -B -P -r -q -x] [--] -a : APK requirement. Can be specified multiple times. -b : APK build requirement. These will be removed at the end to save space. diff --git a/3.7-slim/entrypoint.sh b/3.7-slim/entrypoint.sh index 195ee87..50c2ab1 100644 --- a/3.7-slim/entrypoint.sh +++ b/3.7-slim/entrypoint.sh @@ -12,7 +12,7 @@ VERBOSITY=1 TMP_REQFILE='/tmp/requirements.txt' function usage () { - echo <<"EOF" + cat <<"EOF" Usage: $0 [-a -b -p -A -B -P -r -q -x] [--] -a : APK requirement. Can be specified multiple times. -b : APK build requirement. These will be removed at the end to save space. From ac29ff38b5b488378287076f1f0bb6ebdd41c7f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Wed, 18 Dec 2019 15:02:41 +0000 Subject: [PATCH 48/55] Update travis build with 3.8 tag --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9515cc4..d131fe2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ env: global: - alpine_image='alpine:3.8' - repo='jfloff/alpine-python' - - latest='3.7' + - latest='3.8' matrix: - version='2.7' type='' - version='2.7' type='-onbuild' @@ -23,6 +23,9 @@ env: - version='3.7' type='' - version='3.7' type='-onbuild' - version='3.7' type='-slim' + - version='3.8' type='' + - version='3.8' type='-onbuild' + - version='3.8' type='-slim' before_script: - sudo docker pull $alpine_image From d3dcb619b5fbe2f3d1fd8ea6e76f5c094a95f898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Wed, 18 Dec 2019 15:05:58 +0000 Subject: [PATCH 49/55] Update README.md --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 76362d4..84cb392 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,12 @@ A small Python Docker image based on [Alpine Linux](http://alpinelinux.org/). * **`3.6` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.6/Dockerfile))** * **`3.6-onbuild` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.6-onbuild/Dockerfile))** * **`3.6-slim` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.6-slim/Dockerfile))** -* **`3.7` `latest` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.7/Dockerfile))** -* **`3.7-onbuild` `latest-onbuild` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.7-onbuild/Dockerfile))** -* **`3.7-slim` `latest-slim` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.7-slim/Dockerfile))** +* **`3.7` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.7/Dockerfile))** +* **`3.7-onbuild` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.7-onbuild/Dockerfile))** +* **`3.7-slim` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.7-slim/Dockerfile))** +* **`3.8` `latest` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.8/Dockerfile))** +* **`3.8-onbuild` `latest-onbuild` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.8-onbuild/Dockerfile))** +* **`3.8-slim` `latest-slim` ([Dockerfile](https://github.com/jfloff/alpine-python/blob/master/3.8-slim/Dockerfile))** **NOTES:** - `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_. From aa5cd7e98a0446bb0c222f82cee92f081b430ae2 Mon Sep 17 00:00:00 2001 From: Daniel Porto Date: Fri, 27 Mar 2020 13:01:09 +0000 Subject: [PATCH 50/55] Updates Alpine 3.11 and Python 3.8.0 to 3.8.2 (#67) --- 3.6-onbuild/Dockerfile | 6 +++--- 3.6-slim/Dockerfile | 4 ++-- 3.6/Dockerfile | 6 +++--- 3.7-onbuild/Dockerfile | 6 +++--- 3.7-slim/Dockerfile | 4 ++-- 3.7/Dockerfile | 6 +++--- 3.8-onbuild/Dockerfile | 6 +++--- 3.8-slim/Dockerfile | 6 +++--- 3.8/Dockerfile | 8 ++++---- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/3.6-onbuild/Dockerfile b/3.6-onbuild/Dockerfile index 6d264c1..2c4c2bb 100644 --- a/3.6-onbuild/Dockerfile +++ b/3.6-onbuild/Dockerfile @@ -1,7 +1,7 @@ -FROM alpine:3.8 +FROM alpine:3.11 # VERSIONS -ENV ALPINE_VERSION=3.8 \ +ENV ALPINE_VERSION=3.11 \ PYTHON_VERSION=3.6.9 # PATHS @@ -25,7 +25,7 @@ ENV PYTHON_PATH=/usr/local/bin/ \ bash \ git \ ca-certificates \ - libssl1.0 \ + libressl-dev \ tzdata \ " \ # PACKAGES needed to built python diff --git a/3.6-slim/Dockerfile b/3.6-slim/Dockerfile index 72b2847..7384148 100644 --- a/3.6-slim/Dockerfile +++ b/3.6-slim/Dockerfile @@ -1,7 +1,7 @@ -FROM alpine:3.8 +FROM alpine:3.11 # VERSIONS -ENV ALPINE_VERSION=3.8 \ +ENV ALPINE_VERSION=3.11 \ PYTHON_VERSION=3.6.9 # PATHS diff --git a/3.6/Dockerfile b/3.6/Dockerfile index 362f426..9d911d7 100644 --- a/3.6/Dockerfile +++ b/3.6/Dockerfile @@ -1,7 +1,7 @@ -FROM alpine:3.8 +FROM alpine:3.11 # VERSIONS -ENV ALPINE_VERSION=3.8 \ +ENV ALPINE_VERSION=3.11 \ PYTHON_VERSION=3.6.9 # PATHS @@ -25,7 +25,7 @@ ENV PYTHON_PATH=/usr/local/bin/ \ bash \ git \ ca-certificates \ - libssl1.0 \ + libressl-dev \ tzdata \ " \ # PACKAGES needed to built python diff --git a/3.7-onbuild/Dockerfile b/3.7-onbuild/Dockerfile index 63c9758..f544ee9 100644 --- a/3.7-onbuild/Dockerfile +++ b/3.7-onbuild/Dockerfile @@ -1,7 +1,7 @@ -FROM alpine:3.8 +FROM alpine:3.11 # VERSIONS -ENV ALPINE_VERSION=3.8 \ +ENV ALPINE_VERSION=3.11 \ PYTHON_VERSION=3.7.3 # PATHS @@ -25,7 +25,7 @@ ENV PYTHON_PATH=/usr/local/bin/ \ bash \ git \ ca-certificates \ - libssl1.0 \ + libressl-dev \ tzdata \ " \ # PACKAGES needed to built python diff --git a/3.7-slim/Dockerfile b/3.7-slim/Dockerfile index 7157086..1428cad 100644 --- a/3.7-slim/Dockerfile +++ b/3.7-slim/Dockerfile @@ -1,7 +1,7 @@ -FROM alpine:3.8 +FROM alpine:3.11 # VERSIONS -ENV ALPINE_VERSION=3.8 \ +ENV ALPINE_VERSION=3.11 \ PYTHON_VERSION=3.7.3 # PATHS diff --git a/3.7/Dockerfile b/3.7/Dockerfile index 902cdac..ab8f2f0 100644 --- a/3.7/Dockerfile +++ b/3.7/Dockerfile @@ -1,7 +1,7 @@ -FROM alpine:3.8 +FROM alpine:3.11 # VERSIONS -ENV ALPINE_VERSION=3.8 \ +ENV ALPINE_VERSION=3.11 \ PYTHON_VERSION=3.7.3 # PATHS @@ -25,7 +25,7 @@ ENV PYTHON_PATH=/usr/local/bin/ \ bash \ git \ ca-certificates \ - libssl1.0 \ + libressl-dev \ libffi-dev \ tzdata \ " \ diff --git a/3.8-onbuild/Dockerfile b/3.8-onbuild/Dockerfile index 0f67794..2ccce93 100644 --- a/3.8-onbuild/Dockerfile +++ b/3.8-onbuild/Dockerfile @@ -1,8 +1,8 @@ -FROM alpine:3.8 +FROM alpine:3.11 # VERSIONS -ENV ALPINE_VERSION=3.8 \ - PYTHON_VERSION=3.8.0 +ENV ALPINE_VERSION=3.11 \ + PYTHON_VERSION=3.8.2 # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ diff --git a/3.8-slim/Dockerfile b/3.8-slim/Dockerfile index cff3d87..5867f14 100644 --- a/3.8-slim/Dockerfile +++ b/3.8-slim/Dockerfile @@ -1,8 +1,8 @@ -FROM alpine:3.8 +FROM alpine:3.11 # VERSIONS -ENV ALPINE_VERSION=3.8 \ - PYTHON_VERSION=3.8.0 +ENV ALPINE_VERSION=3.11 \ + PYTHON_VERSION=3.8.2 # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ diff --git a/3.8/Dockerfile b/3.8/Dockerfile index f8a2e10..de9331f 100644 --- a/3.8/Dockerfile +++ b/3.8/Dockerfile @@ -1,8 +1,8 @@ -FROM alpine:3.8 +FROM alpine:3.11 # VERSIONS -ENV ALPINE_VERSION=3.8 \ - PYTHON_VERSION=3.8.0 +ENV ALPINE_VERSION=3.11 \ + PYTHON_VERSION=3.8.2 # PATHS ENV PYTHON_PATH=/usr/local/bin/ \ @@ -25,7 +25,7 @@ ENV PYTHON_PATH=/usr/local/bin/ \ bash \ git \ ca-certificates \ - libssl1.0 \ + libressl-dev \ libffi-dev \ tzdata \ " \ From bb0dd87ceea5128e9da8de64e3d2796268f5931c Mon Sep 17 00:00:00 2001 From: Daniel Porto Date: Fri, 27 Mar 2020 13:32:28 +0000 Subject: [PATCH 51/55] Hotfix - update ssl dependency for alpine 3.11 on-build --- 3.8-onbuild/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3.8-onbuild/Dockerfile b/3.8-onbuild/Dockerfile index 2ccce93..f73a428 100644 --- a/3.8-onbuild/Dockerfile +++ b/3.8-onbuild/Dockerfile @@ -25,7 +25,7 @@ ENV PYTHON_PATH=/usr/local/bin/ \ bash \ git \ ca-certificates \ - libssl1.0 \ + libressl-dev \ tzdata \ " \ # PACKAGES needed to built python From 553d3d3edc9422fff00cb3ff88c9e66dd067e692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Fri, 27 Mar 2020 21:05:10 +0000 Subject: [PATCH 52/55] link include files --- 2.7-onbuild/Dockerfile | 1 + 2.7-slim/Dockerfile | 1 + 2.7/Dockerfile | 1 + 3.6-onbuild/Dockerfile | 1 + 3.6-slim/Dockerfile | 1 + 3.6/Dockerfile | 1 + 3.7-onbuild/Dockerfile | 1 + 3.7-slim/Dockerfile | 1 + 3.7/Dockerfile | 1 + 3.8-onbuild/Dockerfile | 1 + 3.8-slim/Dockerfile | 1 + 3.8/Dockerfile | 1 + 12 files changed, 12 insertions(+) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 95b1340..9a710de 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -101,6 +101,7 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/include/python$PYTHON_MINOR_VERSION /usr/include/ ;\ # set timezone info ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ # remove build dependencies and any leftover apk cache diff --git a/2.7-slim/Dockerfile b/2.7-slim/Dockerfile index 883ccdf..ed637f4 100644 --- a/2.7-slim/Dockerfile +++ b/2.7-slim/Dockerfile @@ -99,6 +99,7 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/include/python$PYTHON_MINOR_VERSION /usr/include/ ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* ;\ diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 655384f..eede0f9 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -98,6 +98,7 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/include/python$PYTHON_MINOR_VERSION /usr/include/ ;\ # set timezone info ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ # remove build dependencies and any leftover apk cache diff --git a/3.6-onbuild/Dockerfile b/3.6-onbuild/Dockerfile index 2c4c2bb..08f8787 100644 --- a/3.6-onbuild/Dockerfile +++ b/3.6-onbuild/Dockerfile @@ -101,6 +101,7 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/include/python$PYTHON_MINOR_VERSION /usr/include/ ;\ # set timezone info ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ # remove build dependencies and any leftover apk cache diff --git a/3.6-slim/Dockerfile b/3.6-slim/Dockerfile index 7384148..976838f 100644 --- a/3.6-slim/Dockerfile +++ b/3.6-slim/Dockerfile @@ -100,6 +100,7 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/include/python$PYTHON_MINOR_VERSION /usr/include/ ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* ;\ diff --git a/3.6/Dockerfile b/3.6/Dockerfile index 9d911d7..ecfbfd8 100644 --- a/3.6/Dockerfile +++ b/3.6/Dockerfile @@ -98,6 +98,7 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/include/python$PYTHON_MINOR_VERSION /usr/include/ ;\ # set timezone info ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ # remove build dependencies and any leftover apk cache diff --git a/3.7-onbuild/Dockerfile b/3.7-onbuild/Dockerfile index f544ee9..1303fd1 100644 --- a/3.7-onbuild/Dockerfile +++ b/3.7-onbuild/Dockerfile @@ -101,6 +101,7 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/include/python$PYTHON_MINOR_VERSION /usr/include/ ;\ # set timezone info ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ # remove build dependencies and any leftover apk cache diff --git a/3.7-slim/Dockerfile b/3.7-slim/Dockerfile index 1428cad..d6b7888 100644 --- a/3.7-slim/Dockerfile +++ b/3.7-slim/Dockerfile @@ -100,6 +100,7 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/include/python$PYTHON_MINOR_VERSION /usr/include/ ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* ;\ diff --git a/3.7/Dockerfile b/3.7/Dockerfile index ab8f2f0..4c5c2ac 100644 --- a/3.7/Dockerfile +++ b/3.7/Dockerfile @@ -101,6 +101,7 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/include/python$PYTHON_MINOR_VERSION /usr/include/ ;\ # set timezone info ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ # remove build dependencies and any leftover apk cache diff --git a/3.8-onbuild/Dockerfile b/3.8-onbuild/Dockerfile index f73a428..dc13051 100644 --- a/3.8-onbuild/Dockerfile +++ b/3.8-onbuild/Dockerfile @@ -101,6 +101,7 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/include/python$PYTHON_MINOR_VERSION /usr/include/ ;\ # set timezone info ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ # remove build dependencies and any leftover apk cache diff --git a/3.8-slim/Dockerfile b/3.8-slim/Dockerfile index 5867f14..06aa447 100644 --- a/3.8-slim/Dockerfile +++ b/3.8-slim/Dockerfile @@ -101,6 +101,7 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/include/python$PYTHON_MINOR_VERSION /usr/include/ ;\ # remove build dependencies and any leftover apk cache apk del --no-cache --purge .build-deps ;\ rm -rf /var/cache/apk/* ;\ diff --git a/3.8/Dockerfile b/3.8/Dockerfile index de9331f..1c141c4 100644 --- a/3.8/Dockerfile +++ b/3.8/Dockerfile @@ -101,6 +101,7 @@ RUN set -ex ;\ find /usr/local/lib/pyenv/versions/$PYTHON_VERSION/ -depth \( -name '*.pyo' -o -name '*.pyc' -o -name 'test' -o -name 'tests' \) -exec rm -rf '{}' + ;\ # symlink the binaries ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/bin/* $PYTHON_PATH ;\ + ln -s /usr/local/lib/pyenv/versions/$PYTHON_VERSION/include/python$PYTHON_MINOR_VERSION /usr/include/ ;\ # set timezone info ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime ;\ # remove build dependencies and any leftover apk cache From 2cbadd9e16946582efa04e873948f94a1c04bb61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Fri, 27 Mar 2020 21:33:27 +0000 Subject: [PATCH 53/55] Update to Alpine 3.11 on 2.7 python images. Add contribution section to README --- 2.7-onbuild/Dockerfile | 2 +- 2.7-slim/Dockerfile | 2 +- 2.7/Dockerfile | 2 +- README.md | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 9a710de..d6b6a2d 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.8 +FROM alpine:3.11 # VERSIONS ENV ALPINE_VERSION=3.8 \ diff --git a/2.7-slim/Dockerfile b/2.7-slim/Dockerfile index ed637f4..f8da739 100644 --- a/2.7-slim/Dockerfile +++ b/2.7-slim/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.8 +FROM alpine:3.11 # VERSIONS ENV ALPINE_VERSION=3.8 \ diff --git a/2.7/Dockerfile b/2.7/Dockerfile index eede0f9..17e5c00 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.8 +FROM alpine:3.11 # VERSIONS ENV ALPINE_VERSION=3.8 \ diff --git a/README.md b/README.md index 84cb392..1b362a8 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ A small Python Docker image based on [Alpine Linux](http://alpinelinux.org/). - [Debugging](#debugging) - [Additional Arguments](#additional-arguments) - [Ecosystem](#ecosystem) + - [Contribution](#contribution) - [License](#license) @@ -233,7 +234,8 @@ These are some of the images that use `jfloff/alpine-python` as base image. *If [busmuth-hub]: https://hub.docker.com/r/eggdrasyl/bismuth-node/ - +## Contribution +Feel free to contribute with whatever you feel like this image is missing. There is also some changes that happen often like, updating Alpine or Python versions. Do not forget that this repo folders mirror **Python** version and **_not_** Alpine versions. ## License The code in this repository, unless otherwise noted, is MIT licensed. See the `LICENSE` file in this repository. From 6121dfd2c7a1233da78d5b3e980cb0f77cf3d6b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Sat, 28 Mar 2020 14:51:31 +0000 Subject: [PATCH 54/55] Fix ALPINE_VERSION env var on 2.7 builds --- 2.7-onbuild/Dockerfile | 2 +- 2.7-slim/Dockerfile | 2 +- 2.7/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index d6b6a2d..91f6140 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -1,7 +1,7 @@ FROM alpine:3.11 # VERSIONS -ENV ALPINE_VERSION=3.8 \ +ENV ALPINE_VERSION=3.11 \ PYTHON_VERSION=2.7.16 # PATHS diff --git a/2.7-slim/Dockerfile b/2.7-slim/Dockerfile index f8da739..d31f322 100644 --- a/2.7-slim/Dockerfile +++ b/2.7-slim/Dockerfile @@ -1,7 +1,7 @@ FROM alpine:3.11 # VERSIONS -ENV ALPINE_VERSION=3.8 \ +ENV ALPINE_VERSION=3.11 \ PYTHON_VERSION=2.7.16 ENV PYTHON_PATH=/usr/local/bin/ \ diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 17e5c00..721cffb 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -1,7 +1,7 @@ FROM alpine:3.11 # VERSIONS -ENV ALPINE_VERSION=3.8 \ +ENV ALPINE_VERSION=3.11 \ PYTHON_VERSION=2.7.16 # PATHS From 7ae8be3ff086e91051a478ae5fa9acb9f4ec6967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ferreira=20Loff?= Date: Sat, 28 Mar 2020 15:12:31 +0000 Subject: [PATCH 55/55] Fix libssl package for Alpine 3.11 --- 2.7-onbuild/Dockerfile | 2 +- 2.7/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/2.7-onbuild/Dockerfile b/2.7-onbuild/Dockerfile index 91f6140..c374ebc 100644 --- a/2.7-onbuild/Dockerfile +++ b/2.7-onbuild/Dockerfile @@ -25,7 +25,7 @@ ENV PYTHON_PATH=/usr/local/bin/ \ bash \ git \ ca-certificates \ - libssl1.0 \ + libressl-dev \ tzdata \ " \ # PACKAGES needed to built python diff --git a/2.7/Dockerfile b/2.7/Dockerfile index 721cffb..01384e4 100644 --- a/2.7/Dockerfile +++ b/2.7/Dockerfile @@ -25,7 +25,7 @@ ENV PYTHON_PATH=/usr/local/bin/ \ bash \ git \ ca-certificates \ - libssl1.0 \ + libressl-dev \ tzdata \ " \ # PACKAGES needed to built python