From fc292414466eea9ac18c8278e4a57fd3a96c9d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Fri, 7 Jun 2024 11:16:50 +0200 Subject: [PATCH] feat: cache edx-platform checkout in image build Similar to what we need with the MFE image, we leverage Docker's ADD directive to implement caching of the edx-platform git checkout step. See: https://github.com/overhangio/tutor-mfe/pull/163 https://docs.docker.com/reference/dockerfile/#add --- changelog.d/20240607_111921_regis_edx_platform_code_cache.md | 1 + tutor/templates/build/openedx/Dockerfile | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changelog.d/20240607_111921_regis_edx_platform_code_cache.md diff --git a/changelog.d/20240607_111921_regis_edx_platform_code_cache.md b/changelog.d/20240607_111921_regis_edx_platform_code_cache.md new file mode 100644 index 0000000000..f56c6f8dd3 --- /dev/null +++ b/changelog.d/20240607_111921_regis_edx_platform_code_cache.md @@ -0,0 +1 @@ +- 💥[Improvement] Ensure that the edx-platform repository git checkout is cached by Docker during image build. This means that the cache will automatically be cleared any time there is an upstream change. Thus, it is no longer necessary to run `tutor images build --no-cache` just to fetch the latest edx-platform changes. For this to work, any GitHub repository referenced by `EDX_PLATFORM_REPOSITORY` needs to end with ".git". Make sure that this is the case if you have modified the value of this setting in the past. (by @regisb) diff --git a/tutor/templates/build/openedx/Dockerfile b/tutor/templates/build/openedx/Dockerfile index 4d7d8b0081..65b7e6a2da 100644 --- a/tutor/templates/build/openedx/Dockerfile +++ b/tutor/templates/build/openedx/Dockerfile @@ -38,9 +38,9 @@ RUN $PYENV_ROOT/versions/$PYTHON_VERSION/bin/python -m venv /openedx/venv FROM minimal as code ARG EDX_PLATFORM_REPOSITORY={{ EDX_PLATFORM_REPOSITORY }} ARG EDX_PLATFORM_VERSION={{ EDX_PLATFORM_VERSION }} -RUN mkdir -p /openedx/edx-platform && \ - git clone $EDX_PLATFORM_REPOSITORY --branch $EDX_PLATFORM_VERSION --depth 1 /openedx/edx-platform +RUN mkdir -p /openedx/edx-platform WORKDIR /openedx/edx-platform +ADD --keep-git-dir=true $EDX_PLATFORM_REPOSITORY#$EDX_PLATFORM_VERSION . # Identify tutor user to apply patches using git RUN git config --global user.email "tutor@overhang.io" \