Recompile requirements file used by Python in a container environment - IBM/ibm-spectrum-scale-bridge-for-grafana GitHub Wiki
Using Python requirements files is among Python development best practices. It dramatically reduces the need for managing and supervising different libraries. Managing your library dependencies from one place makes it easier, more convenient, and faster. It helps keep everything organized and easy for everyone involved.
It is a great way to ensure you have all the necessary dependencies installed for your project.
Also, GitHub provides automated vulnerability alerts for dependencies in your repository. By uploading a requirements.txt with your code, GitHub checks for any conflict and sends an alert to the administrator if it detects any. It can even resolve the vulnerabilities automatically!
If the conflicts in the requirements file could not be resolved automatically, or the base image version needs to be upgraded to a later version, or set to a different version, then the Python package requirements list can be recompiled by following the steps below.
Recompile requirements file used by Python in a container environment
Clone repository to your favourite directory on your test system.
# git clone https://github.com/IBM/ibm-spectrum-scale-bridge-for-grafana.git bridge_8.0.4-dev
Build the image for the desired version of the UBI base image by setting the --build-arg=BASE parameter. In addition, set the build argument BUILD_ENV to "test" to run pip-compile from requirements_ubi.in file. Dependencies in Python packages will be recompiled, built and tested during the image build.
# podman build --format=docker \
--build-arg=BASE=registry.access.redhat.com/ubi9/ubi:9.5-1741850090 \
--build-arg=BUILD_ENV=test -t bridge_compile:test .
Verify the build process finished successfully. Copy "Compiled python packages:" section from the CLI output to a new requirements_ubiXXX.txt file. Store the file under /requirements. Make sure the python packages install step in the Dockefile points to the new requirements file.
Build image with new ubi requirements file
# podman build --format=docker \
--build-arg=BASE=registry.access.redhat.com/ubi9/ubi:9.5-1741850090 \
-t bridge_from_ubi:8.0.4_dev .