From 1fe87a2b9da562ad3801b25125ada40b2dca79e5 Mon Sep 17 00:00:00 2001 From: RafalSkolasinski Date: Mon, 19 Jul 2021 10:33:15 +0100 Subject: [PATCH] fix push of conda base image (#3406) * fix push of conda base image * fix problem with not setting conda version * redhat image = local image * remove build_all_local as all builds are local --- testing/scripts/Makefile | 2 +- wrappers/s2i/python/Dockerfile.local | 6 +++- wrappers/s2i/python/Dockerfile.redhat | 29 ------------------- wrappers/s2i/python/Makefile | 10 +++---- wrappers/s2i/python/README.md | 3 +- .../python/build_scripts/build_all_local.sh | 4 --- .../build_scripts/build_local_redhat.sh | 1 - wrappers/s2i/python/build_scripts/push_all.sh | 1 + .../python/build_scripts/push_conda_base.sh | 1 + 9 files changed, 14 insertions(+), 43 deletions(-) delete mode 100644 wrappers/s2i/python/Dockerfile.redhat delete mode 100755 wrappers/s2i/python/build_scripts/build_all_local.sh delete mode 100755 wrappers/s2i/python/build_scripts/build_local_redhat.sh create mode 100755 wrappers/s2i/python/build_scripts/push_conda_base.sh diff --git a/testing/scripts/Makefile b/testing/scripts/Makefile index 31824ebe17..cf1bd4bfd2 100644 --- a/testing/scripts/Makefile +++ b/testing/scripts/Makefile @@ -139,7 +139,7 @@ port-forward-ambassador: .PHONY: s2i_build_base_images s2i_build_base_images: - cd ../../wrappers/s2i/python/build_scripts && ./build_all_local.sh + cd ../../wrappers/s2i/python/build_scripts && ./build_all.sh .PHONY: build_protos build_protos: diff --git a/wrappers/s2i/python/Dockerfile.local b/wrappers/s2i/python/Dockerfile.local index 151a8e5d4e..e71579c893 100644 --- a/wrappers/s2i/python/Dockerfile.local +++ b/wrappers/s2i/python/Dockerfile.local @@ -1,4 +1,3 @@ -ARG CONDA_VERSION ARG BASE_IMAGE ARG IMAGE_VERSION FROM $BASE_IMAGE:$IMAGE_VERSION @@ -6,7 +5,12 @@ FROM $BASE_IMAGE:$IMAGE_VERSION LABEL io.openshift.s2i.scripts-url="image:///s2i/bin" # This is to install desired version of Python without updating conda version +# Note: ARGs must be after FROM statement , see source: +# https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact + ARG PYTHON_VERSION +ARG CONDA_VERSION + RUN conda install --yes python=$PYTHON_VERSION conda=$CONDA_VERSION RUN dnf install -y make automake gcc gcc-c++ diff --git a/wrappers/s2i/python/Dockerfile.redhat b/wrappers/s2i/python/Dockerfile.redhat deleted file mode 100644 index e68fc02793..0000000000 --- a/wrappers/s2i/python/Dockerfile.redhat +++ /dev/null @@ -1,29 +0,0 @@ -ARG CONDA_VERSION -ARG IMAGE_VERSION -ARG BASE_IMAGE -FROM $BASE_IMAGE:$IMAGE_VERSION - -LABEL io.openshift.s2i.scripts-url="image:///s2i/bin" - -# This is to install desired version of Python without updating conda version -ARG PYTHON_VERSION -RUN conda install --yes python=$PYTHON_VERSION conda=$CONDA_VERSION -RUN dnf install -y make automake gcc gcc-c++ - -# Pin pip and setuptools -RUN pip install pip==20.2 setuptools==46.1 - -RUN mkdir microservice -WORKDIR /microservice - -COPY ./s2i/bin/ /s2i/bin - -# keep install of seldon-core after the COPY to force re-build of layer -COPY _python /microservice -RUN cd /microservice/python && pip install . -COPY _python/python/licenses/license.txt . - -RUN mkdir -p /.conda && chmod a+rwx /.conda -RUN yum -y update-minimal --security --sec-severity=Important --sec-severity=Critical - -EXPOSE 5000 diff --git a/wrappers/s2i/python/Makefile b/wrappers/s2i/python/Makefile index bd78b9ca42..37365f5cc8 100644 --- a/wrappers/s2i/python/Makefile +++ b/wrappers/s2i/python/Makefile @@ -24,6 +24,7 @@ get_local_repo: .PHONY: build build: get_local_repo set -x && docker build -f Dockerfile --build-arg IMAGE_VERSION=${IMAGE_VERSION} --build-arg PYTHON_VERSION=${PYTHON_VERSION} --build-arg CONDA_VERSION=${CONDA_VERSION} --build-arg BASE_IMAGE=${CONDA_BASE_IMAGE} -t $(IMAGE_NAME):$(IMAGE_VERSION) . + docker tag $(IMAGE_NAME):$(IMAGE_VERSION) $(IMAGE_NAME)-ubi8:$(IMAGE_VERSION) .PHONY: build_gpu build_gpu: get_local_repo @@ -33,14 +34,10 @@ build_gpu: get_local_repo build_local: get_local_repo set -x && docker build -f Dockerfile.local --build-arg PYTHON_VERSION=${PYTHON_VERSION} --build-arg CONDA_VERSION=${CONDA_VERSION} --build-arg BASE_IMAGE=${CONDA_BASE_IMAGE} --build-arg IMAGE_VERSION=${IMAGE_VERSION} -t $(IMAGE_NAME):$(IMAGE_VERSION) . -.PHONY: build_local -build_local_redhat: get_local_repo - set -x && docker build -f Dockerfile.local --build-arg PYTHON_VERSION=${PYTHON_VERSION} --build-arg CONDA_VERSION=${CONDA_VERSION} --build-arg BASE_IMAGE=${CONDA_BASE_IMAGE} --build-arg IMAGE_VERSION=${IMAGE_VERSION} -t $(IMAGE_NAME)-ubi8:$(IMAGE_VERSION) . .PHONY: build_redhat build_redhat: get_local_repo - set -x && docker build -f Dockerfile.redhat --build-arg PYTHON_VERSION=${PYTHON_VERSION} --build-arg CONDA_VERSION=${CONDA_VERSION} --build-arg BASE_IMAGE=${CONDA_BASE_IMAGE} --build-arg IMAGE_VERSION=${IMAGE_VERSION} -t $(IMAGE_NAME)-ubi8:$(IMAGE_VERSION) . - + set -x && docker build -f Dockerfile.local --build-arg PYTHON_VERSION=${PYTHON_VERSION} --build-arg CONDA_VERSION=${CONDA_VERSION} --build-arg BASE_IMAGE=${CONDA_BASE_IMAGE} --build-arg IMAGE_VERSION=${IMAGE_VERSION} -t $(IMAGE_NAME)-ubi8:$(IMAGE_VERSION) . tag_base_python: @@ -84,3 +81,6 @@ after_build_image_seldon_core_check: build_conda_base: docker build -f Dockerfile.conda --build-arg CONDA_VERSION=${CONDA_VERSION} -t ${CONDA_BASE_IMAGE}:${IMAGE_VERSION} . + +push_to_dockerhub_conda_base: + docker push $(CONDA_BASE_IMAGE):$(IMAGE_VERSION) diff --git a/wrappers/s2i/python/README.md b/wrappers/s2i/python/README.md index f1aa210441..d24265af16 100644 --- a/wrappers/s2i/python/README.md +++ b/wrappers/s2i/python/README.md @@ -5,7 +5,7 @@ e.g. from 0.3-SNAPSHOT to release 0.3 and create 0.4-SNAPSHOT * set IMAGE_VERSION to new stable version X in Makefile (e.g. 0.3) - * ```cd build_scripts``` and run ```./build_all.sh``` (OR ```./build_all_local.sh``` if pypi not updated yet) and then ```./push_all.sh``` + * ```cd build_scripts``` and run ```./build_all.sh``` and then ```./push_all.sh``` * Update IMAGE_VERSION to (X+1)-SNAPSHOT (e.g. 0.4-SNAPSHOT) * ```./build_all.sh``` and then ```./push_all.sh``` * Update main readme to show new versions of stable and snapshot @@ -13,4 +13,3 @@ e.g. from 0.3-SNAPSHOT to release 0.3 and create 0.4-SNAPSHOT ``` ./update_python_version.sh X X+1```, e.g ```./update_python_version.sh 0.2 0.3``` (check that any references to X-SNAPSHOT are updated to X - may need manual intervention) * Update the `doc/source/reference/images.md` manually with the latest image versions - diff --git a/wrappers/s2i/python/build_scripts/build_all_local.sh b/wrappers/s2i/python/build_scripts/build_all_local.sh deleted file mode 100755 index 706ebb3368..0000000000 --- a/wrappers/s2i/python/build_scripts/build_all_local.sh +++ /dev/null @@ -1,4 +0,0 @@ -./build_conda_base.sh -./build_local_python3.6.sh -./build_local_python3.7.sh -./build_local_redhat.sh diff --git a/wrappers/s2i/python/build_scripts/build_local_redhat.sh b/wrappers/s2i/python/build_scripts/build_local_redhat.sh deleted file mode 100755 index d606b47e35..0000000000 --- a/wrappers/s2i/python/build_scripts/build_local_redhat.sh +++ /dev/null @@ -1 +0,0 @@ -make -C ../ build_local_redhat diff --git a/wrappers/s2i/python/build_scripts/push_all.sh b/wrappers/s2i/python/build_scripts/push_all.sh index 622e03caa6..eaed905494 100755 --- a/wrappers/s2i/python/build_scripts/push_all.sh +++ b/wrappers/s2i/python/build_scripts/push_all.sh @@ -1,3 +1,4 @@ +./push_conda_base.sh ./push_python3.6.sh ./push_python3.7.sh ./push_python3.6_gpu.sh diff --git a/wrappers/s2i/python/build_scripts/push_conda_base.sh b/wrappers/s2i/python/build_scripts/push_conda_base.sh new file mode 100755 index 0000000000..e2a8829d9d --- /dev/null +++ b/wrappers/s2i/python/build_scripts/push_conda_base.sh @@ -0,0 +1 @@ +make -C ../ push_to_dockerhub_conda_base