Uses airflow user for build segment of docker image (#20744)
Uses airflow user for build segment of docker image (#20744)

PIP produces a warning when root user is used to run pip install.
This is done for a good reason - because installing PIP this way
clashes with a number of distro-managed python packages.

The warning cannot be disabled even if our use case is legitimate
as has been extensively discussed in
https://github.com/pypa/pip/issues/10556.

However, the advice given by the warning is a bit misleading - it
suggests to use virtualenv, but since this is considered a bad practice
for container building and because we need to create virtualenvs
dynamically inside the image, using virtualenv is a bad solution for us.
It's been attempted in #19189 and failed.

Instead we create an airflow user and use PIP_USER="true" which
installs all dependencies in build segment to ~/.local folder
from where we can copy it to the main image.

That get rids of the warning and at the same time allows us to
keep the best practices of building the images.
danielvdende/incubator-airflow,Acehaidrey/incubator-airflow,mistercrunch/airflow,Acehaidrey/incubator-airflow,danielvdende/incubator-airflow,nathanielvarona/airflow,apache/airflow,cfei18/incubator-airflow,mistercrunch/airflow,apache/airflow,apache/airflow,nathanielvarona/airflow,cfei18/incubator-airflow,lyft/incubator-airflow,nathanielvarona/airflow,danielvdende/incubator-airflow,mistercrunch/airflow,danielvdende/incubator-airflow,cfei18/incubator-airflow,bolkedebruin/airflow,lyft/incubator-airflow,danielvdende/incubator-airflow,apache/airflow,Acehaidrey/incubator-airflow,lyft/incubator-airflow,apache/airflow,apache/airflow,mistercrunch/airflow,nathanielvarona/airflow,danielvdende/incubator-airflow,cfei18/incubator-airflow,cfei18/incubator-airflow,bolkedebruin/airflow,bolkedebruin/airflow,bolkedebruin/airflow,bolkedebruin/airflow,Acehaidrey/incubator-airflow,nathanielvarona/airflow,Acehaidrey/incubator-airflow,cfei18/incubator-airflow,lyft/incubator-airflow,nathanielvarona/airflow,Acehaidrey/incubator-airflow