potiuk commented on a change in pull request #4543: [AIRFLOW-3718] [WIP]
Multi-layered version of the docker image
URL: https://github.com/apache/airflow/pull/4543#discussion_r264315536
##########
File path: Dockerfile
##########
@@ -70,6 +70,16 @@ COPY --from=wheel-cache /cache /cache
RUN pip install ${PIP_CACHE_DIRECTIVE} --upgrade pip==19.0.1 && \
pip install ${PIP_CACHE_DIRECTIVE} --no-use-pep517 -e ".[${EXTRAS}]"
+# Install necessary NPM dependencies - also taking into account only changes
in package.json
+COPY airflow/www/ /opt/airflow/airflow/www/
+
+WORKDIR /opt/airflow/airflow/www
+
+RUN npm ci \
Review comment:
In our case (of Docker Builds) it's not a problem. It's all but guaranteed
that there will not be node_modules when we reach that instruction in Docker.
For CI build, it's always from the scratch. For local builds the node_modules
dir is excluded in .dockerignore so it is not even sent as part of the context
to the Docker engine performing the build.
Now when you wrote it however, I actually think that I should add another
layer for that (COPY packages-json.lock -> npm ci -> COPY www -> npm run prod).
Then 'npm ci' will only be run when packages-lock.json changes - which should
be very rare case.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services