From 8bb6a4764e3a3e92af0b14014efae26fdb4b6e61 Mon Sep 17 00:00:00 2001 From: Shadi Naif Date: Sun, 26 Nov 2023 16:41:38 +0300 Subject: [PATCH] feat: add atlas pull support - FC-0012 Add atlas pull behind a feature flag until it's fully implemented Refs: FC-0012 OEP-58 --- changelog.d/20231126_120405_shadinaif_atlas_pull.md | 1 + .../apps/openedx/settings/partials/common_all.py | 2 +- tutor/templates/build/openedx/Dockerfile | 9 ++++++++- tutor/templates/build/openedx/settings/cms/assets.py | 2 +- tutor/templates/build/openedx/settings/lms/assets.py | 2 +- tutor/templates/build/openedx/settings/partials/i18n.py | 2 +- tutor/templates/config/defaults.yml | 1 + 7 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 changelog.d/20231126_120405_shadinaif_atlas_pull.md diff --git a/changelog.d/20231126_120405_shadinaif_atlas_pull.md b/changelog.d/20231126_120405_shadinaif_atlas_pull.md new file mode 100644 index 00000000000..9a03851238c --- /dev/null +++ b/changelog.d/20231126_120405_shadinaif_atlas_pull.md @@ -0,0 +1 @@ +- [Feature] Pull translations via `atlas` during Docker build. (by @shadinaif) diff --git a/tutor/templates/apps/openedx/settings/partials/common_all.py b/tutor/templates/apps/openedx/settings/partials/common_all.py index c9b747a89f1..5e292996e17 100644 --- a/tutor/templates/apps/openedx/settings/partials/common_all.py +++ b/tutor/templates/apps/openedx/settings/partials/common_all.py @@ -169,7 +169,7 @@ EMAIL_FILE_PATH = "/tmp/openedx/emails" # Language/locales -LOCALE_PATHS.append("/openedx/locale/contrib/locale") +{% if not OPENEDX_ATLAS_PULL %}LOCALE_PATHS.append("/openedx/locale/contrib/locale"){% endif %} LOCALE_PATHS.append("/openedx/locale/user/locale") LANGUAGE_COOKIE_NAME = "openedx-language-preference" diff --git a/tutor/templates/build/openedx/Dockerfile b/tutor/templates/build/openedx/Dockerfile index 0f0aa66f4ed..3a0773a178e 100644 --- a/tutor/templates/build/openedx/Dockerfile +++ b/tutor/templates/build/openedx/Dockerfile @@ -159,7 +159,7 @@ USER ${APP_USER_ID} # https://hub.docker.com/r/powerman/dockerize/tags COPY --link --from=docker.io/powerman/dockerize:0.19.0 /usr/local/bin/dockerize /usr/local/bin/dockerize COPY --chown=app:app --from=edx-platform / /openedx/edx-platform -COPY --chown=app:app --from=locales /openedx/locale /openedx/locale +{% if not OPENEDX_ATLAS_PULL %}COPY --chown=app:app --from=locales /openedx/locale /openedx/locale{% endif %} COPY --chown=app:app --from=python /opt/pyenv /opt/pyenv COPY --chown=app:app --from=python-requirements /openedx/venv /openedx/venv COPY --chown=app:app --from=python-requirements /openedx/requirements /openedx/requirements @@ -187,6 +187,13 @@ ENV REVISION_CFG /openedx/config/revisions.yml COPY --chown=app:app settings/lms/*.py ./lms/envs/tutor/ COPY --chown=app:app settings/cms/*.py ./cms/envs/tutor/ +{% if OPENEDX_ATLAS_PULL %} +# Support the OEP-58 proposal behind a feature flag until it's fully implemented +RUN pip install openedx-atlas +RUN find conf/locale -mindepth 1 -maxdepth 1 -type d -exec rm -r {} \; +RUN atlas pull {{ patch("atlas-extra-args") }} translations/edx-platform/conf/locale:edx-platform/conf/locale +{% endif %} + # Copy user-specific locales to /openedx/locale/user/locale and compile them RUN mkdir /openedx/locale/user COPY --chown=app:app ./locale/ /openedx/locale/user/locale/ diff --git a/tutor/templates/build/openedx/settings/cms/assets.py b/tutor/templates/build/openedx/settings/cms/assets.py index 59b1dd0d30c..a3813ee8ba6 100644 --- a/tutor/templates/build/openedx/settings/cms/assets.py +++ b/tutor/templates/build/openedx/settings/cms/assets.py @@ -5,5 +5,5 @@ derive_settings(__name__) -LOCALE_PATHS.append("/openedx/locale/contrib/locale") +{% if not OPENEDX_ATLAS_PULL %}LOCALE_PATHS.append("/openedx/locale/contrib/locale"){% endif %} LOCALE_PATHS.append("/openedx/locale/user/locale") diff --git a/tutor/templates/build/openedx/settings/lms/assets.py b/tutor/templates/build/openedx/settings/lms/assets.py index 4cf476d1caa..ef17d9c19c5 100644 --- a/tutor/templates/build/openedx/settings/lms/assets.py +++ b/tutor/templates/build/openedx/settings/lms/assets.py @@ -5,5 +5,5 @@ derive_settings(__name__) -LOCALE_PATHS.append("/openedx/locale/contrib/locale") +{% if not OPENEDX_ATLAS_PULL %}LOCALE_PATHS.append("/openedx/locale/contrib/locale"){% endif %} LOCALE_PATHS.append("/openedx/locale/user/locale") diff --git a/tutor/templates/build/openedx/settings/partials/i18n.py b/tutor/templates/build/openedx/settings/partials/i18n.py index 708c2507e09..6e672e51d0a 100644 --- a/tutor/templates/build/openedx/settings/partials/i18n.py +++ b/tutor/templates/build/openedx/settings/partials/i18n.py @@ -14,7 +14,7 @@ derive_settings(__name__) -LOCALE_PATHS.append("/openedx/locale/contrib/locale") +{% if not OPENEDX_ATLAS_PULL %}LOCALE_PATHS.append("/openedx/locale/contrib/locale"){% endif %} LOCALE_PATHS.append("/openedx/locale/user/locale") {{ patch("openedx-common-i18n-settings") }} diff --git a/tutor/templates/config/defaults.yml b/tutor/templates/config/defaults.yml index e91b866182f..e99cf9a6354 100644 --- a/tutor/templates/config/defaults.yml +++ b/tutor/templates/config/defaults.yml @@ -44,6 +44,7 @@ MONGODB_PASSWORD: "" MONGODB_REPLICA_SET: "" MONGODB_USE_SSL: false MOUNTS: [] +OPENEDX_ATLAS_PULL: false OPENEDX_AWS_ACCESS_KEY: "" OPENEDX_AWS_SECRET_ACCESS_KEY: "" OPENEDX_CACHE_REDIS_DB: 1