root/build-tools/build-docker-images
Luan Nunes Utimura b08492b35c docker-images: Add loci patch to allow pip upgrade
In older versions of the pip tool, there is a known bug with the
dependency resolver that causes some package installations to take much
longer than expected due to various version and compatibility checks
done during this process ([1] and [2]).

Since the newer versions of the tool bring improvements to the
dependency resolver, updating it helps to avoid scenarios like the ones
described above.

Thus, this patch adds a build argument called UPGRADE_PIP_PACKAGES
which, when filled, allows LOCI to perform a `pip install --upgrade` on
the listed packages before proceeding with the installation of the
others.

[1] https://github.com/pypa/pip/issues/10967
[2] https://github.com/pypa/pip/issues/9517

Test Plan:
PASS: While building any image, verify in the output that the new patch
      is being applied on top of LOCI's Dockerfile:
      `Applying: Add build argument to allow pip upgrade`.
      (This step is performed regardless of the BUILDER type)
PASS: While building any loci-based image that DOES NOT use the build
      argument UPGRADE_PIP_PACKAGES, verify in the output that pip isn't
      upgrading itself or upgrading other packages before the
      installation step.
PASS: While building any loci-based image that DOES use the build
      argument UPGRADE_PIP_PACKAGES, verify in the output that pip is
      upgrading the listed packages before the installation step.

Signed-off-by: Luan Nunes Utimura <LuanNunes.Utimura@windriver.com>
Change-Id: I0e742e804746bf5f3f99fed181dd868c10fdf75b
2023-01-19 19:34:17 -03:00
..
loci/patches docker-images: Add loci patch to allow pip upgrade 2023-01-19 19:34:17 -03:00
stx-centos Revert "Add priority to repositories in base-image" 2022-01-13 10:38:00 -05:00
stx-debian build-tools: fix invalid apt cache removal 2022-07-25 17:30:25 +00:00
tag-management Add tag stx.8.0-v1.0.3 to vRAN docker images 2022-12-08 19:47:58 +00:00
base-image-build-centos-dev.cfg debian: base docker image: add support for debian 2022-03-14 12:58:31 -04:00
base-image-build-centos-stable.cfg debian: base docker image: add support for debian 2022-03-14 12:58:31 -04:00
build-stx-base.sh build-tools: apt repo priority based on "Origin" 2022-07-05 20:39:40 -04:00
build-stx-images.sh docker-images: Add loci patch to allow pip upgrade 2023-01-19 19:34:17 -03:00
FIXME docker-images: add Loci patches 2022-09-14 10:56:06 -04:00
internal-update-stx-image.sh Tool for incremental image updates 2019-06-03 20:36:16 +00:00
README Update wheels and build tool 2019-03-24 21:03:21 -04:00
update-stx-image.sh Fix incorrect entrypoint for updated image 2020-12-07 13:09:10 +02:00

## Example commands for building StarlingX images

PRIVATE_REGISTRY_USERID=myuser
PRIVATE_REGISTRY=xxx.xxx.xxx.xxx:9001
VERSION=2018.11.13
OS=centos
OS_VERSION=7.5.1804
BUILD_STREAM=stable
HOST_PORT=8088

## Step 1: Build stx-centos
time $MY_REPO/build-tools/build-docker-images/build-stx-base.sh \
    --os ${OS} \
    --os-version ${OS_VERSION} \
    --version ${VERSION} \
    --user ${PRIVATE_REGISTRY_USERID} \
    --registry ${PRIVATE_REGISTRY} \
    --push \
    --repo stx-local-build,http://${HOSTNAME}:${HOST_PORT}/${MY_WORKSPACE}/std/rpmbuild/RPMS \
    --repo stx-mirror-distro,http://${HOSTNAME}:${HOST_PORT}/${MY_REPO}/cgcs-root/cgcs-${OS}-repo/Binary \
    --clean


## Step 2: Build wheels (output as tarball)
time $MY_REPO/build-tools/build-wheels/build-wheel-tarball.sh \
    --os ${OS} \
    --os-version ${OS_VERSION} \
    --stream ${BUILD_STREAM}

## Step 3: Build images
time $MY_REPO/build-tools/build-docker-images/build-stx-images.sh \
    --os ${OS} \
    --version ${VERSION} \
    --stream ${BUILD_STREAM} \
    --base ${PRIVATE_REGISTRY}/${PRIVATE_REGISTRY_USERID}/stx-${OS}:${VERSION} \
    --wheels http://${HOSTNAME}:${HOST_PORT}/${MY_WORKSPACE}/std/build-wheels-${OS}-${BUILD_STREAM}/stx-${OS}-${BUILD_STREAM}-wheels.tar \
    --user ${PRIVATE_REGISTRY_USERID} \
    --registry ${PRIVATE_REGISTRY} \
    --push --latest \
    --clean


## Note: Verify that lighttpd is not bound to "localhost"
vi /etc/lighttpd/lighttpd.conf
# server.bind = "localhost"
systemctl restart lighttpd

## Note: You may need to add an iptables rule to allow the docker
## containers to access the http server on your host. For example:
iptables -I INPUT 6 -i docker0 -p tcp --dport ${HOST_PORT} -m state --state NEW,ESTABLISHED -j ACCEPT