Skip to content

Commit

Permalink
Fixes UI assets compilation from PROD image built from sources (apach…
Browse files Browse the repository at this point in the history
…e#17086)

The apache#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 apache#16939
  • Loading branch information
potiuk authored and tzanko-matev committed Aug 17, 2021
1 parent e72aeec commit 5da10d9
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 5da10d9

Please sign in to comment.