You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2023/04/13 16:31:47 UTC

[superset] branch master updated: fix(docker): optimize docker build by better utilizing build cache (#23624)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 536b1c4816 fix(docker): optimize docker build by better utilizing build cache (#23624)
536b1c4816 is described below

commit 536b1c4816093cb31cf07924e2a63048e7e1561e
Author: Sebastian Liebscher <11...@users.noreply.github.com>
AuthorDate: Thu Apr 13 18:31:36 2023 +0200

    fix(docker): optimize docker build by better utilizing build cache (#23624)
---
 Dockerfile | 68 +++++++++++++++++++++++++++++---------------------------------
 1 file changed, 32 insertions(+), 36 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 9089fc8f28..aa83ff5fdb 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -58,52 +58,48 @@ ENV LANG=C.UTF-8 \
     SUPERSET_PORT=8088
 
 RUN mkdir -p ${PYTHONPATH} \
-        && useradd --user-group -d ${SUPERSET_HOME} -m --no-log-init --shell /bin/bash superset \
-        && apt-get update -y \
-        && apt-get install -y --no-install-recommends \
-            build-essential \
-            curl \
-            default-libmysqlclient-dev \
-            libsasl2-dev \
-            libsasl2-modules-gssapi-mit \
-            libpq-dev \
-            libecpg-dev \
-        && rm -rf /var/lib/apt/lists/*
-
-COPY ./requirements/*.txt  /app/requirements/
-COPY setup.py MANIFEST.in README.md /app/
+    && useradd --user-group -d ${SUPERSET_HOME} -m --no-log-init --shell /bin/bash superset \
+    && apt-get update -y \
+    && apt-get install -y --no-install-recommends \
+        build-essential \
+        curl \
+        default-libmysqlclient-dev \
+        libsasl2-dev \
+        libsasl2-modules-gssapi-mit \
+        libpq-dev \
+        libecpg-dev \
+    && rm -rf /var/lib/apt/lists/*
+
+WORKDIR /app
+
+COPY --chown=superset:superset ./requirements/*.txt  requirements/
+COPY --chown=superset:superset setup.py MANIFEST.in README.md ./
 
 # setup.py uses the version information in package.json
-COPY superset-frontend/package.json /app/superset-frontend/
+COPY --chown=superset:superset superset-frontend/package.json superset-frontend/
 
-RUN cd /app \
-    && mkdir -p superset/static \
+RUN mkdir -p superset/static \
     && touch superset/static/version_info.json \
-    && pip install --no-cache -r requirements/local.txt
+    && pip install --no-cache-dir -r requirements/local.txt
 
-COPY --from=superset-node /app/superset/static/assets /app/superset/static/assets
+COPY --chown=superset:superset --from=superset-node /app/superset/static/assets superset/static/assets
 
 ## Lastly, let's install superset itself
-COPY superset /app/superset
-COPY setup.py MANIFEST.in README.md /app/
-RUN cd /app \
-        && chown -R superset:superset * \
-        && pip install -e . \
-        && flask fab babel-compile --target superset/translations
+COPY --chown=superset:superset superset superset
+RUN chown -R superset:superset ./* \
+    && pip install --no-cache-dir -e . \
+    && flask fab babel-compile --target superset/translations
 
 COPY ./docker/run-server.sh /usr/bin/
-
 RUN chmod a+x /usr/bin/run-server.sh
 
-WORKDIR /app
-
 USER superset
 
 HEALTHCHECK CMD curl -f "http://localhost:$SUPERSET_PORT/health"
 
 EXPOSE ${SUPERSET_PORT}
 
-CMD /usr/bin/run-server.sh
+CMD ["/usr/bin/run-server.sh"]
 
 ######################################################################
 # Dev image...
@@ -118,13 +114,13 @@ USER root
 
 RUN apt-get update -y \
     && apt-get install -y --no-install-recommends \
-          libnss3 \
-          libdbus-glib-1-2 \
-          libgtk-3-0 \
-          libx11-xcb1 \
-          libasound2 \
-          libxtst6 \
-          wget
+        libnss3 \
+        libdbus-glib-1-2 \
+        libgtk-3-0 \
+        libx11-xcb1 \
+        libasound2 \
+        libxtst6 \
+        wget
 
 # Install GeckoDriver WebDriver
 RUN wget https://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}-linux64.tar.gz -O /tmp/geckodriver.tar.gz && \