You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2020/11/12 21:10:59 UTC

[airflow] 04/08: The .pypirc file is read from docker-context-files (#11779)

This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch v1-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 45d6b277700f7f09a00b2a11606830161aedaa4f
Author: Jarek Potiuk <ja...@polidea.com>
AuthorDate: Fri Oct 23 17:55:15 2020 +0200

    The .pypirc file is read from docker-context-files (#11779)
    
    If you used context from git repo, the .piprc file was missing and
    COPY in Dockerfile is not conditional.
    
    This change copies the .pypirc conditionally from the
    docker-context-files folder instead.
    
    Also it was needlessly copied in the main image where it is not
    needed and it was even dangerous to do so.
    
    (cherry picked from commit 53e5d8f1f24eed4d4876cd3f5d4fe1a5873c10cc)
---
 .dockerignore                           | 1 -
 Dockerfile                              | 6 +++---
 docs/production-deployment.rst          | 7 +++----
 scripts/ci/libraries/_initialization.sh | 6 ------
 4 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/.dockerignore b/.dockerignore
index 8a8bb52..7c5ad9b 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -54,7 +54,6 @@
 !NOTICE
 !.github
 !empty
-!.pypirc
 
 # This folder is for you if you want to add any files to the docker context when you build your own
 # docker image. most of other files and any new folder you add will be excluded by default
diff --git a/Dockerfile b/Dockerfile
index 7cc7f94..a399c7c 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -164,7 +164,9 @@ RUN mkdir -p /root/.local/bin
 ARG AIRFLOW_PRE_CACHED_PIP_PACKAGES="true"
 ENV AIRFLOW_PRE_CACHED_PIP_PACKAGES=${AIRFLOW_PRE_CACHED_PIP_PACKAGES}
 
-COPY .pypirc /root/.pypirc
+RUN if [[ -f /docker-context-files/.pypirc ]]; then \
+        cp /docker-context-files/.pypirc /root/.pypirc; \
+    fi
 
 # In case of Production build image segment we want to pre-install master version of airflow
 # dependencies from github so that we do not have to always reinstall it from the scratch.
@@ -387,8 +389,6 @@ RUN chmod a+x /entrypoint /clean-logs
 # See https://github.com/apache/airflow/issues/9248
 RUN chmod g=u /etc/passwd
 
-COPY .pypirc ${AIRFLOW_USER_HOME_DIR}/.pypirc
-
 ENV PATH="${AIRFLOW_USER_HOME_DIR}/.local/bin:${PATH}"
 ENV GUNICORN_CMD_ARGS="--worker-tmp-dir /dev/shm"
 
diff --git a/docs/production-deployment.rst b/docs/production-deployment.rst
index de974a6..216f221 100644
--- a/docs/production-deployment.rst
+++ b/docs/production-deployment.rst
@@ -265,10 +265,9 @@ the resulting image using ``FROM:`` any dependencies you want.
 Customizing PYPI installation
 .............................
 
-You can customize PYPI sources used during image build by modifying .pypirc file that should be
-placed in the root of Airflow Directory. This .pypirc will never be committed to the repository
-and will not be present in the final production image. It is added and used only in the build
-segment of the image so it is never copied to the final image.
+You can customize PYPI sources used during image build by adding a docker-context-files/.pypirc file
+This .pypirc will never be committed to the repository and will not be present in the final production image.
+It is added and used only in the build segment of the image so it is never copied to the final image.
 
 External sources for dependencies
 ---------------------------------
diff --git a/scripts/ci/libraries/_initialization.sh b/scripts/ci/libraries/_initialization.sh
index 1b80364..91c45dd 100644
--- a/scripts/ci/libraries/_initialization.sh
+++ b/scripts/ci/libraries/_initialization.sh
@@ -34,12 +34,6 @@ function initialization::create_directories() {
     export FILES_DIR="${AIRFLOW_SOURCES}/files"
     readonly FILES_DIR
 
-    # Create an empty .pypirc file that you can customise. It is .gitignored so it will never
-    # land in the repository - it is only added to the "build image" of production image
-    # So you can keep your credentials safe as long as you do not push the build image.
-    # The final image does not contain it.
-    touch "${AIRFLOW_SOURCES}/.pypirc"
-
     # Directory where all the build cache is stored - we keep there status of all the docker images
     # As well as hashes of the important files, but also we generate build scripts there that are
     # Used to execute the commands for breeze