diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..876a90ca4 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ +arch: s390x +services: + - docker +env: + global: + - TEST_DIR="$PWD/s390x/test/3.9/alpine3.12" + - TEST_SCRIPT="test.sh" + - BUILD_DIR="$PWD/s390x/3.9/alpine3.12" + - REPO="quay.io/ibmz/python" + - TAG="$REPO:3.9" +before_script: + - cd $TEST_DIR && chmod +x $TEST_SCRIPT + - docker login quay.io -u $ROBOT -p $ROBOT_TOKEN +script: + - docker build $BUILD_DIR --tag $TAG + - cd $TEST_DIR && bash $TEST_SCRIPT +after_script: + - docker push $REPO diff --git a/README.md b/README.md index df5b2bcea..250ca81d4 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,48 @@ -# https://github.com/docker-library/python +# Tags +> _Built from [`quay.io/ibm/alpine:3.12`](https://quay.io/repository/ibm/alpine?tab=info)_ +- `3.8` - [![Build Status](https://travis-ci.com/lcarcaramo/python.svg?branch=3.8)](https://travis-ci.com/lcarcaramo/python) +- `3.9` - [![Build Status](https://travis-ci.com/lcarcaramo/python.svg?branch=master)](https://travis-ci.com/lcarcaramo/python) -## Maintained by: [the Docker Community](https://github.com/docker-library/python) +### __[Original Source Code](https://github.com/docker-library/python)__ -This is the Git repo of the [Docker "Official Image"](https://github.com/docker-library/official-images#what-are-official-images) for [`python`](https://hub.docker.com/_/python/) (not to be confused with any official `python` image provided by `python` upstream). See [the Docker Hub page](https://hub.docker.com/_/python/) for the full readme on how to use this Docker image and for information regarding contributing and issues. +# Python -The [full image description on Docker Hub](https://hub.docker.com/_/python/) is generated/maintained over in [the docker-library/docs repository](https://github.com/docker-library/docs), specifically in [the `python` directory](https://github.com/docker-library/docs/tree/master/python). +Python is an interpreted, interactive, object-oriented, open-source programming language. It incorporates modules, exceptions, dynamic typing, very high level dynamic data types, and classes. Python combines remarkable power with very clear syntax. It has interfaces to many system calls and libraries, as well as to various window systems, and is extensible in C or C++. It is also usable as an extension language for applications that need a programmable interface. Finally, Python is portable: it runs on many Unix variants, on the Mac, and on Windows 2000 and later. -## See a change merged here that doesn't show up on Docker Hub yet? +> [wikipedia.org/wiki/Python_(programming_language)](https://en.wikipedia.org/wiki/Python_%28programming_language%29) -For more information about the full official images change lifecycle, see [the "An image's source changed in Git, now what?" FAQ entry](https://github.com/docker-library/faq#an-images-source-changed-in-git-now-what). +![logo](https://raw.githubusercontent.com/docker-library/docs/01c12653951b2fe592c1f93a13b4e289ada0e3a1/python/logo.png) -For outstanding `python` image PRs, check [PRs with the "library/python" label on the official-images repository](https://github.com/docker-library/official-images/labels/library%2Fpython). For the current "source of truth" for [`python`](https://hub.docker.com/_/python/), see [the `library/python` file in the official-images repository](https://github.com/docker-library/official-images/blob/master/library/python). +# How to use this image ---- +## Create a `Dockerfile` in your Python app project -- [![build status badge](https://img.shields.io/github/workflow/status/docker-library/python/GitHub%20CI/master?label=GitHub%20CI)](https://github.com/docker-library/python/actions?query=workflow%3A%22GitHub+CI%22+branch%3Amaster) -- [![build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/update.sh/job/python.svg?label=Automated%20update.sh)](https://doi-janky.infosiftr.net/job/update.sh/job/python/) +```dockerfile +FROM quay.io/ibm/python:3.9 -| Build | Status | Badges | (per-arch) | -|:-:|:-:|:-:|:-:| -| [![amd64 build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/amd64/job/python.svg?label=amd64)](https://doi-janky.infosiftr.net/job/multiarch/job/amd64/job/python/) | [![arm32v5 build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/arm32v5/job/python.svg?label=arm32v5)](https://doi-janky.infosiftr.net/job/multiarch/job/arm32v5/job/python/) | [![arm32v6 build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/arm32v6/job/python.svg?label=arm32v6)](https://doi-janky.infosiftr.net/job/multiarch/job/arm32v6/job/python/) | [![arm32v7 build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/arm32v7/job/python.svg?label=arm32v7)](https://doi-janky.infosiftr.net/job/multiarch/job/arm32v7/job/python/) | -| [![arm64v8 build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/arm64v8/job/python.svg?label=arm64v8)](https://doi-janky.infosiftr.net/job/multiarch/job/arm64v8/job/python/) | [![i386 build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/i386/job/python.svg?label=i386)](https://doi-janky.infosiftr.net/job/multiarch/job/i386/job/python/) | [![mips64le build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/mips64le/job/python.svg?label=mips64le)](https://doi-janky.infosiftr.net/job/multiarch/job/mips64le/job/python/) | [![ppc64le build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/ppc64le/job/python.svg?label=ppc64le)](https://doi-janky.infosiftr.net/job/multiarch/job/ppc64le/job/python/) | -| [![s390x build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/s390x/job/python.svg?label=s390x)](https://doi-janky.infosiftr.net/job/multiarch/job/s390x/job/python/) | [![windows-amd64 build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/multiarch/job/windows-amd64/job/python.svg?label=windows-amd64)](https://doi-janky.infosiftr.net/job/multiarch/job/windows-amd64/job/python/) | [![put-shared build status badge](https://img.shields.io/jenkins/s/https/doi-janky.infosiftr.net/job/put-shared/job/heavy.svg?label=put-shared)](https://doi-janky.infosiftr.net/job/put-shared/job/heavy/) | +WORKDIR /usr/src/app - +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +CMD [ "python", "./your-daemon-or-script.py" ] +``` + +You can then build and run the Docker image: + +```console +$ docker build -t my-python-app . +$ docker run -it --rm --name my-running-app my-python-app +``` + +# License + +View license information for [Python 2](https://docs.python.org/2/license.html) and [Python 3](https://docs.python.org/3/license.html). + +As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained). + +Some additional license information which was able to be auto-detected might be found in [the `repo-info` repository's `python/` directory](https://github.com/docker-library/repo-info/tree/master/repos/python). + +As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within. diff --git a/s390x/3.9/alpine3.12/Dockerfile b/s390x/3.9/alpine3.12/Dockerfile new file mode 100644 index 000000000..935c40067 --- /dev/null +++ b/s390x/3.9/alpine3.12/Dockerfile @@ -0,0 +1,136 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "update.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +FROM quay.io/ibm/alpine:3.12 + +# ensure local python is preferred over distribution python +ENV PATH /usr/local/bin:$PATH + +# http://bugs.python.org/issue19846 +# > At the moment, setting "LANG=C" on a Linux system *fundamentally breaks Python 3*, and that's not OK. +ENV LANG C.UTF-8 + +# install ca-certificates so that HTTPS works consistently +# other runtime dependencies for Python are installed later +RUN apk add --no-cache ca-certificates + +ENV GPG_KEY E3FF2839C048B25C084DEBE9B26995E310250568 +ENV PYTHON_VERSION 3.9.0 + +RUN set -ex \ + && apk add --no-cache --virtual .fetch-deps \ + gnupg \ + tar \ + xz \ + \ + && wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \ + && wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \ + && export GNUPGHOME="$(mktemp -d)" \ + && gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \ + && gpg --batch --verify python.tar.xz.asc python.tar.xz \ + && { command -v gpgconf > /dev/null && gpgconf --kill all || :; } \ + && rm -rf "$GNUPGHOME" python.tar.xz.asc \ + && mkdir -p /usr/src/python \ + && tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \ + && rm python.tar.xz \ + \ + && apk add --no-cache --virtual .build-deps \ + bluez-dev \ + 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 \ + openssl-dev \ + pax-utils \ + readline-dev \ + sqlite-dev \ + tcl-dev \ + tk \ + tk-dev \ + util-linux-dev \ + xz-dev \ + zlib-dev \ +# add build deps before removing fetch deps in case there's overlap + && apk del --no-network .fetch-deps \ + \ + && cd /usr/src/python \ + && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \ + && ./configure \ + --build="$gnuArch" \ + --enable-loadable-sqlite-extensions \ + --enable-optimizations \ + --enable-option-checking=fatal \ + --enable-shared \ + --with-system-expat \ + --with-system-ffi \ + --without-ensurepip \ + && make -j "$(nproc)" \ +# set thread stack size to 1MB so we don't segfault before we hit sys.getrecursionlimit() +# https://github.com/alpinelinux/aports/commit/2026e1259422d4e0cf92391ca2d3844356c649d0 + EXTRA_CFLAGS="-DTHREAD_STACK_SIZE=0x100000" \ + LDFLAGS="-Wl,--strip-all" \ + && make install \ + && rm -rf /usr/src/python \ + \ + && find /usr/local -depth \ + \( \ + \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ + -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name '*.a' \) \) \ + \) -exec rm -rf '{}' + \ + \ + && 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 \ + && apk del --no-network .build-deps \ + \ + && python3 --version + +# make some useful symlinks that are expected to exist +RUN cd /usr/local/bin \ + && ln -s idle3 idle \ + && ln -s pydoc3 pydoc \ + && ln -s python3 python \ + && ln -s python3-config python-config + +# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value ''" +ENV PYTHON_PIP_VERSION 20.2.4 +# https://github.com/pypa/get-pip +ENV PYTHON_GET_PIP_URL https://github.com/pypa/get-pip/raw/8283828b8fd6f1783daf55a765384e6d8d2c5014/get-pip.py +ENV PYTHON_GET_PIP_SHA256 2250ab0a7e70f6fd22b955493f7f5cf1ea53e70b584a84a32573644a045b4bfb + +RUN set -ex; \ + \ + wget -O get-pip.py "$PYTHON_GET_PIP_URL"; \ + echo "$PYTHON_GET_PIP_SHA256 *get-pip.py" | sha256sum -c -; \ + \ + python get-pip.py \ + --disable-pip-version-check \ + --no-cache-dir \ + "pip==$PYTHON_PIP_VERSION" \ + ; \ + pip --version; \ + \ + find /usr/local -depth \ + \( \ + \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \ + -o \ + \( -type f -a \( -name '*.pyc' -o -name '*.pyo' \) \) \ + \) -exec rm -rf '{}' +; \ + rm -f get-pip.py + +CMD ["python3"] diff --git a/s390x/test/3.9/alpine3.12/runs-python-programs/Dockerfile b/s390x/test/3.9/alpine3.12/runs-python-programs/Dockerfile new file mode 100644 index 000000000..dc7b738dc --- /dev/null +++ b/s390x/test/3.9/alpine3.12/runs-python-programs/Dockerfile @@ -0,0 +1,10 @@ +FROM quay.io/ibmz/python:3.9 + +WORKDIR /usr/src/app + +COPY requirements.txt ./ +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +CMD [ "python", "./test.py" ] diff --git a/s390x/test/3.9/alpine3.12/runs-python-programs/requirements.txt b/s390x/test/3.9/alpine3.12/runs-python-programs/requirements.txt new file mode 100644 index 000000000..9ca086f0b --- /dev/null +++ b/s390x/test/3.9/alpine3.12/runs-python-programs/requirements.txt @@ -0,0 +1 @@ +ansicolors diff --git a/s390x/test/3.9/alpine3.12/runs-python-programs/test.py b/s390x/test/3.9/alpine3.12/runs-python-programs/test.py new file mode 100644 index 000000000..ab69f3973 --- /dev/null +++ b/s390x/test/3.9/alpine3.12/runs-python-programs/test.py @@ -0,0 +1,4 @@ +from colors import * + +print(color("Success! This Python program is running on the quay.io/ibmz/python image!", fg='green')) +print(color("Test Complete. Terminating program...", fg='green')) diff --git a/s390x/test/3.9/alpine3.12/test.sh b/s390x/test/3.9/alpine3.12/test.sh new file mode 100644 index 000000000..d73b7f999 --- /dev/null +++ b/s390x/test/3.9/alpine3.12/test.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +set -e + +export ANSI_YELLOW_BOLD="\e[1;33m" +export ANSI_GREEN="\e[32m" +export ANSI_YELLOW_BACKGROUND="\e[1;7;33m" +export ANSI_GREEN_BACKGROUND="\e[1;7;32m" +export ANSI_CYAN="\e[36m" +export ANSI_RESET="\e[0m" +export DOCKERFILE_TOP="**************************************** DOCKERFILE ******************************************" +export DOCKERFILE_BOTTOM="**********************************************************************************************" +export TEST_SUITE_START="**************************************** SMOKE TESTS *****************************************" +export TEST_SUITE_END="************************************** TEST SUCCESSFUL ***************************************" + +# Pass in path to folder where Dockerfile lives +print_dockerfile () { + echo -e "\n$ANSI_CYAN$DOCKERFILE_TOP\n$(<$1/Dockerfile)\n$ANSI_CYAN$DOCKERFILE_BOTTOM $ANSI_RESET\n" +} + +# Pass in test case message +print_test_case () { + echo -e "\n$ANSI_YELLOW_BOLD$1 $ANSI_RESET" +} + +print_success () { + echo -e "\n$ANSI_GREEN$1 $ANSI_RESET \n" + +} + +# Pass in path to folder where Dockerfile lives +build () { + print_dockerfile $1 + docker build -q -t $1 $1 +} + +cleanup () { + docker rmi $1 +} + +suite_start () { + echo -e "\n$ANSI_YELLOW_BACKGROUND$TEST_SUITE_START$ANSI_RESET \n" +} + +suite_end () { + echo -e "\n$ANSI_GREEN_BACKGROUND$TEST_SUITE_END$ANSI_RESET \n" +} + + +suite_start + print_test_case "It can run a Python program:" + build "runs-python-programs" + docker run --rm --name runs-python-programs "runs-python-programs" + cleanup "runs-python-programs" +suite_end