potiuk opened a new issue #22250:
URL: https://github.com/apache/airflow/issues/22250


   ### Description
   
   We should fail attemps to install packages by `pip` after switching to root 
user in PROD airlfow image.
   
   We should provide the user good error message with information on how to 
install `pip` packages properly (i..e. switching to `airflow` user first).
   
   ### Use case/motivation
   
   When extending  Ariflow image, all packages should be installed as "airflow" 
user. Some users attempt to run `pip install` right after adding some `apt` 
packages - which require switching to root.
   
   For example this is wrong:
   
   ```
   FROM apache/airflow:2.1.2-python3.8
   USER root
   RUN apt-get update \
     && apt-get install -y --no-install-recommends \
            vim \
            awscli \
     && apt-get autoremove -yqq --purge \
     && apt-get clean \
     && rm -rf /var/lib/apt/lists/*
   RUN pip install -Iv --no-cache-dir apache-airflow-providers-amazon==3.0.0
   
   USER airflow
   ```
   
   And should be:
   
   ```
   FROM apache/airflow:2.1.2-python3.8
   USER root
   RUN apt-get update \
     && apt-get install -y --no-install-recommends \
            vim \
            awscli \
     && apt-get autoremove -yqq --purge \
     && apt-get clean \
     && rm -rf /var/lib/apt/lists/*
   
   USER airflow
   
   RUN pip install -Iv --no-cache-dir apache-airflow-providers-amazon==3.0.0
   ```
   
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to