Skip to content

Commit

Permalink
Fixes UI assets compilation from PROD image built from sources (#17086)
Browse files Browse the repository at this point in the history
The #16577 change removed yarn.lock from installed packages
and it removed the possibility of preparing assets after the
package is installed - so far that was the way it was done in
the PROD image built from sources. The asset compilation
was supposed to work after the change but it was not
performed in this case.

The change fixes it by:

* detecting properly if the PROD image is built from sources
  (INSTALLATION_METHOD)
* compiling the assets from sources, not from package
* installing airflow from sources AFTER assets were compiled

Fixes #16939
  • Loading branch information
potiuk committed Jul 19, 2021
1 parent bb1d79c commit 660027f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,16 @@ ENV ADDITIONAL_PYTHON_DEPS=${ADDITIONAL_PYTHON_DEPS} \
WORKDIR /opt/airflow

# hadolint ignore=SC2086, SC2010
RUN if [[ ${INSTALL_FROM_DOCKER_CONTEXT_FILES} == "true" ]]; then \
bash /scripts/docker/install_from_docker_context_files.sh; \
elif [[ ${INSTALL_FROM_PYPI} == "true" ]]; then \
bash /scripts/docker/install_airflow.sh; \
else \
RUN if [[ ${AIRFLOW_INSTALLATION_METHOD} == "." ]]; then \
# only compile assets if the prod image is build from sources
# otherwise they are already compiled-in
bash /scripts/docker/compile_www_assets.sh; \
fi; \
if [[ ${INSTALL_FROM_DOCKER_CONTEXT_FILES} == "true" ]]; then \
bash /scripts/docker/install_from_docker_context_files.sh; \
elif [[ ${INSTALL_FROM_PYPI} == "true" ]]; then \
bash /scripts/docker/install_airflow.sh; \
fi; \
if [[ -n "${ADDITIONAL_PYTHON_DEPS}" ]]; then \
bash /scripts/docker/install_additional_dependencies.sh; \
fi; \
Expand Down
7 changes: 6 additions & 1 deletion scripts/docker/compile_www_assets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ function compile_www_assets() {
md5sum_file="static/dist/sum.md5"
readonly md5sum_file
local www_dir
www_dir="$(python -m site --user-site)/airflow/www"
if [[ ${AIRFLOW_INSTALLATION_METHOD=} == "." ]]; then
# In case we are building from sources in production image, we should build the assets
www_dir="${AIRFLOW_SOURCES_TO}/airflow/www"
else
www_dir="$(python -m site --user-site)/airflow/www"
fi
pushd ${www_dir} || exit 1
yarn install --frozen-lockfile --no-cache
yarn run prod
Expand Down

0 comments on commit 660027f

Please sign in to comment.