You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by ta...@apache.org on 2019/07/16 15:26:42 UTC

[impala] 04/06: IMPALA-8425: part 2: avoid chown when building containers

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

tarmstrong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 21586fbfbc885b1a330154a1199189d9f9a38609
Author: Tim Armstrong <ta...@cloudera.com>
AuthorDate: Thu Jun 20 19:37:34 2019 -0700

    IMPALA-8425: part 2: avoid chown when building containers
    
    This reduces the size of an image from 1.36GB to 705MB with
    a release build on my system.
    
    Thanks to Joe McDonnell for the suggestion.
    
    Testing:
    Precommit docker tests are sufficient to validate that
    the containers are functional.
    
    Change-Id: I5476a97a7a030499a60a6cef67f8c3cdffa7e756
    Reviewed-on: http://gerrit.cloudera.org:8080/13699
    Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 docker/impala_base/Dockerfile | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/docker/impala_base/Dockerfile b/docker/impala_base/Dockerfile
index 225adda..203f42b 100644
--- a/docker/impala_base/Dockerfile
+++ b/docker/impala_base/Dockerfile
@@ -27,11 +27,18 @@ RUN apt-get update && \
   apt-get clean && \
   rm -rf /var/lib/apt/lists/*
 
+# Use a non-privileged impala user to run the daemons in the container.
+# That user should own everything in the /opt/impala subdirectory.
+RUN groupadd -r impala && useradd --no-log-init -r -g impala impala && \
+    mkdir -p /opt/impala && chown impala /opt/impala && \
+    chmod ugo+w /etc/passwd
+USER impala
+
 # Copy build artifacts required for the daemon processes.
 # Need to have multiple copy commands to preserve directory structure.
-COPY lib /opt/impala/lib
-COPY www /opt/impala/www
-COPY bin /opt/impala/bin
+COPY --chown=impala lib /opt/impala/lib
+COPY --chown=impala www /opt/impala/www
+COPY --chown=impala bin /opt/impala/bin
 # Symlink here instead of in setup_build_context to avoid duplicate binaries.
 RUN cd /opt/impala/bin && ln -s impalad statestored && ln -s impalad catalogd && \
 # Create conf directory for later config injection.
@@ -39,11 +46,4 @@ RUN cd /opt/impala/bin && ln -s impalad statestored && ln -s impalad catalogd &&
 # Create logs directory to collect container logs.
     mkdir /opt/impala/logs
 
-# Use a non-privileged impala user to run the daemons in the container.
-# That user should own everything in the /opt/impala subdirectory.
-RUN groupadd -r impala && useradd --no-log-init -r -g impala impala && \
-    mkdir -p /opt/impala && chown impala -R /opt/impala && \
-    chmod ugo+w /etc/passwd
-USER impala
-
 WORKDIR /opt/impala/