forked from zalando-stups/docker-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…lando-stups#24) and force pip3.7 to be default pip (zalando-stups#23)
- Loading branch information
Dmytro Zavalkin
committed
Mar 24, 2020
1 parent
01759f1
commit 58dd981
Showing
5 changed files
with
50 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
FROM registry.opensource.zalan.do/stups/ubuntu:latest | ||
MAINTAINER Zalando SE | ||
ARG UBUNTU_VERSION=latest | ||
|
||
# Install python tools and dev packages | ||
RUN apt-get update \ | ||
&& apt-get install -q -y --no-install-recommends python3.7-dev python3-pip python3-setuptools python3-wheel gcc \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
FROM registry.opensource.zalan.do/stups/ubuntu:$UBUNTU_VERSION | ||
LABEL maintainer="Zalando SE" | ||
|
||
# set python 3 as the default python version | ||
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1 \ | ||
&& update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 | ||
RUN pip3 install --upgrade pip requests setuptools pipenv | ||
# Install python 3.7 tools and dev packages | ||
RUN apt-get update && \ | ||
apt-get install -q -y --no-install-recommends \ | ||
python3.7 \ | ||
python3.7-dev \ | ||
python3-pip && \ | ||
python3.7 -m pip install --no-cache-dir --upgrade --force-reinstall pip setuptools wheel && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# make requests library use the Debian CA bundle (includes Zalando CA) | ||
# Set python 3.7 as the default python version and pip 3.7 as the default pip version | ||
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1 && \ | ||
update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1 && \ | ||
rm -f /usr/bin/pip3 && \ | ||
update-alternatives --install /usr/bin/pip3 pip3 /usr/local/bin/pip3.7 1 && \ | ||
update-alternatives --install /usr/bin/pip pip /usr/local/bin/pip3.7 1 | ||
|
||
# Check that default python and pip commands have correct versions | ||
RUN python -V | grep 'Python 3.7' && \ | ||
pip -V | grep '(python 3.7)' | ||
|
||
# Make requests library use the Debian CA bundle (includes Zalando CA) | ||
ENV REQUESTS_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt | ||
|
||
CMD python3 | ||
CMD python | ||
|
||
RUN purge.sh |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,32 @@ | ||
version: "2017-09-20" | ||
dependencies: | ||
- id: base | ||
type: docker | ||
ref: registry.opensource.zalan.do/stups/ubuntu | ||
- id: base_ubuntu | ||
type: docker | ||
ref: registry.opensource.zalan.do/stups/ubuntu | ||
pipeline: | ||
- id: build | ||
type: script | ||
env: | ||
IMAGE: registry-write.opensource.zalan.do/stups/python | ||
commands: | ||
- desc: 'Install Docker' | ||
cmd: 'curl -sSL https://delivery.cloud.zalando.com/utils/ensure-docker | sh' | ||
- desc: 'Build' | ||
- desc: Build the docker image | ||
cmd: | | ||
# use the resolved Ubuntu base image version | ||
echo "Ubuntu base image version: ${DEP_BASE_VERSION}" | ||
sed -i "s,:latest,:${DEP_BASE_VERSION}," Dockerfile | ||
image=python-temp:${CDP_BUILD_VERSION} | ||
docker build -t $image --squash . | ||
sed -i "s,UNTESTED,$image,g" Dockerfile.test | ||
docker build -t $image-test -f Dockerfile.test . | ||
# get current Python version | ||
out=$(docker run $image-test) | ||
echo "$out" | ||
# e.g. "Python Version: CPython 3.6.1" | ||
version=$(echo "$out" | grep 'Python Version:' | awk '{ print $4}') | ||
release=registry-write.opensource.zalan.do/stups/python:$version-${CDP_TARGET_BRANCH_COUNTER} | ||
docker tag $image $release | ||
IS_PR_BUILD=${CDP_PULL_REQUEST_NUMBER+"true"} | ||
if [[ ${IS_PR_BUILD} != "true" ]] | ||
then | ||
docker push $release | ||
# Use the resolved Ubuntu base image version | ||
echo "Ubuntu base image version: ${DEP_BASE_UBUNTU_VERSION}" | ||
docker build --squash \ | ||
--tag ${IMAGE}:local \ | ||
--build-arg UBUNTU_VERSION=${DEP_BASE_UBUNTU_VERSION} \ | ||
. | ||
# Get current Python version | ||
PYTHON_VERSION=$(docker run ${IMAGE}:local python -V | awk '{ print $2}') | ||
echo "Successfully built docker image with Python version: ${PYTHON_VERSION}" | ||
# Tag and push the image (but only if it is a master branch) | ||
if [ -z "$CDP_PULL_REQUEST_NUMBER" ]; then | ||
TAG=${PYTHON_VERSION}-${CDP_TARGET_BRANCH_COUNTER} | ||
docker tag ${IMAGE}:local ${IMAGE}:${TAG} | ||
docker push ${IMAGE}:${TAG} | ||
else | ||
echo "Image not pushed because the build is not a push to master" | ||
echo "Image not pushed because the build is not a push to master" | ||
fi |