Thanks to #DavidMaze comment 🙏 ...
You can set an environment variable
PIP_EXTRA_INDEX_URLwith the same effect, and either pass it in via a DockerfileARG(be careful to use a multistage build to avoid leaking the token though) or a build secret. See for example Passing PIP_EXTRA_INDEX_URL to docker build.
... to pass the argument, I added in .gitlab-ci.yml, in dockerize-env \ script :
export PIP_EXTRA_INDEX_URL="https://gitlab-ci-token:[email protected]/api/v4/groups/<GROUP_ID>/-/packages/pypi/simple"
and in DockerFile.project_env:
# Add a variable accessible during image build
# so that pip can access internal pypi repo
ARG PIP_EXTRA_INDEX_URL
After that my_package_on_gitlab_private_pypi can be installed from internal Pypi 🎉