Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Dockerfile and plugin settings #23

Merged
merged 2 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,43 +56,27 @@ Application configuration
- ``CREDENTIALS_MYSQL_PASSWORD`` (default: ``"{{ 8|random_string }}"``)
- ``CREDENTIALS_DOCKER_IMAGE`` (default: ``"{{ DOCKER_REGISTRY }}overhangio/openedx-credentials:{{ CREDENTIALS_VERSION }}"``)
- ``CREDENTIALS_EXTRA_PIP_REQUIREMENTS`` (default: ``[]``)
- ``CREDENTIALS_SITE_NAME`` (default: ``"LMS_HOST"``)
- ``CREDENTIALS_REPOSITORY`` (default: ``"https://github.com/openedx/credentials.git"``)
- ``CREDENTIALS_REPOSITORY_VERSION`` (default: ``"{{ OPENEDX_COMMON_VERSION }}"``)

Marketing & Theming
~~~~~~~~~~~~~~~~~~~

- ``CREDENTIALS_LOGO_TRADEMARK_URL`` (default: ``"https://edx-cdn.org/v3/default/logo-trademark.svg"``)
- ``CREDENTIALS_LOGO_TRADEMARK_URL_PNG`` (default: ``"https://edx-cdn.org/v3/default/logo-trademark.png"``)
- ``CREDENTIALS_LOGO_TRADEMARK_URL_SVG`` (default: ``"https://edx-cdn.org/v3/default/logo-trademark.svg"``)
- ``CREDENTIALS_LOGO_URL`` (default: ``"https://edx-cdn.org/v3/default/logo.svg"``)
- ``CREDENTIALS_LOGO_URL_PNG`` (default: ``"https://edx-cdn.org/v3/default/logo.png"``)
- ``CREDENTIALS_LOGO_URL_SVG`` (default: ``"https://edx-cdn.org/v3/default/logo.svg"``)
- ``CREDENTIALS_LOGO_WHITE_URL`` (default: ``"https://edx-cdn.org/v3/default/logo-white.svg"``)
- ``CREDENTIALS_LOGO_WHITE_URL_PNG`` (default: ``"https://edx-cdn.org/v3/default/logo-white.png"``)
- ``CREDENTIALS_LOGO_WHITE_URL_SVG`` (default: ``"https://edx-cdn.org/v3/default/logo-white.svg"``)
- ``CREDENTIALS_FAVICON_URL`` (default: ``"https://edx-cdn.org/v3/default/favicon.ico"``)
- ``CREDENTIALS_THEME_NAME`` (default: ``"edx-theme"``)

Backend authentication
~~~~~~~~~~~~~~~~~~~~~~~

- ``CREDENTIALS_BACKEND_SERVICE_EDX_OAUTH2_KEY`` (default: ``"credentials-backend-service-key"``)
- ``CREDENTIALS_BACKEND_SERVICE_EDX_OAUTH2_SECRET`` (default: ``"{{ CREDENTIALS_OAUTH2_SECRET }}"``)
- ``CREDENTIALS_BACKEND_SERVICE_EDX_OAUTH2_PROVIDER_URL`` (default: ``"http://lms:8000/oauth2"``)
- ``CREDENTIALS_OAUTH2_KEY`` (default: ``credentials-backend-service-key"``)
- ``CREDENTIALS_OAUTH2_SECRET`` (default: ``"CHANGE-ME"``)

Application Third party authentication
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- ``CREDENTIALS_SOCIAL_AUTH_REDIRECT_IS_HTTPS`` (default: ``{% if ENABLE_HTTPS %}True{% else %}False{% endif %}``)
- ``CREDENTIALS_SOCIAL_AUTH_EDX_OAUTH2_ISSUER`` (default: ``"{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}"``)
- ``CREDENTIALS_SOCIAL_AUTH_EDX_OAUTH2_URL_ROOT`` (default: ``"http://lms:8000"``)
- ``CREDENTIALS_SOCIAL_AUTH_EDX_OAUTH2_KEY`` (default: ``"credentials-sso-key"``)
- ``CREDENTIALS_SOCIAL_AUTH_EDX_OAUTH2_SECRET`` (default: ``"credentials-sso-secret"``)
- ``CREDENTIALS_SOCIAL_AUTH_EDX_OAUTH2_LOGOUT_URL`` (default: ``"{{ SOCIAL_AUTH_EDX_OAUTH2_ISSUER }}/logout"``)

Funding
-------
Expand Down
1 change: 1 addition & 0 deletions changelog.d/20231130_110806_regis_simplify.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- 💥[Improvement] Simplify plugin settings. As a consequence, many marketing settings are deprecated. If they were useful to you, you can override them using the "credentials-settings-common" patch. (by @regisb)
18 changes: 0 additions & 18 deletions tutorcredentials/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,18 @@
config: t.Dict[str, t.Dict[str, t.Any]] = {
"defaults": {
"VERSION": __version__,
"BACKEND_SERVICE_EDX_OAUTH2_PROVIDER_URL": "http://lms:8000/oauth2",
"BACKEND_SERVICE_EDX_OAUTH2_KEY": "{{ CREDENTIALS_OAUTH2_KEY }}",
"DOCKER_IMAGE": "{{ DOCKER_REGISTRY }}overhangio/openedx-credentials:{{ CREDENTIALS_VERSION }}",
"EXTRA_PIP_REQUIREMENTS": [],
"FAVICON_URL": "https://edx-cdn.org/v3/default/favicon.ico",
"HOST": "credentials.{{ LMS_HOST }}",
"LOGO_TRADEMARK_URL": "https://edx-cdn.org/v3/default/logo-trademark.svg",
"LOGO_TRADEMARK_URL_PNG": "https://edx-cdn.org/v3/default/logo-trademark.png",
"LOGO_TRADEMARK_URL_SVG": "https://edx-cdn.org/v3/default/logo-trademark.svg",
"LOGO_URL": "",
"LOGO_URL_PNG": "{{ CREDENTIALS_LOGO_URL }}",
"LOGO_URL_SVG": "",
"LOGO_WHITE_URL": "{{ CREDENTIALS_LOGO_URL }}",
"LOGO_WHITE_URL_PNG": "{{ CREDENTIALS_LOGO_URL }}",
"LOGO_WHITE_URL_SVG": "",
"MYSQL_DATABASE": "credentials",
"MYSQL_USERNAME": "credentials",
"OAUTH2_KEY": "credentials-key",
"OAUTH2_KEY_DEV": "credentials-key-dev",
"OAUTH2_KEY_SSO": "credentials-key-sso",
"OAUTH2_KEY_SSO_DEV": "credentials-key-sso-dev",
"PLATFORM_NAME": "{{ PLATFORM_NAME }}",
"SITE_NAME": "{{ LMS_HOST }}",
"SOCIAL_AUTH_REDIRECT_IS_HTTPS": False,
"SOCIAL_AUTH_EDX_OAUTH2_ISSUER": "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}",
"SOCIAL_AUTH_EDX_OAUTH2_URL_ROOT": "http://lms:8000",
"SOCIAL_AUTH_EDX_OAUTH2_KEY": "credentials-sso-key",
"SOCIAL_AUTH_EDX_OAUTH2_LOGOUT_URL": "{{ LMS_HOST }}/logout",
"THEME_NAME": "edx-theme",
"TOS_URL": "{{ LMS_HOST }}/tos",
"REPOSITORY": "https://github.com/openedx/credentials.git",
"REPOSITORY_VERSION": "{{ OPENEDX_COMMON_VERSION }}",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

{% include "credentials/apps/credentials/settings/partials/common.py" %}

SOCIAL_AUTH_EDX_OAUTH2_PUBLIC_URL_ROOT = "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}:8000"
SOCIAL_AUTH_EDX_OAUTH2_PUBLIC_URL_ROOT = "http://{{ LMS_HOST }}:8000"
FAVICON_URL = "http://{{ LMS_HOST }}:8000/favicon.ico"

BACKEND_SERVICE_EDX_OAUTH2_KEY = "{{ CREDENTIALS_OAUTH2_KEY }}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@
}
]

LOGO_TRADEMARK_URL = "https://edx-cdn.org/v3/default/logo-trademark.svg"
LOGO_TRADEMARK_URL_PNG = "https://edx-cdn.org/v3/default/logo-trademark.png"
LOGO_TRADEMARK_URL_SVG = "https://edx-cdn.org/v3/default/logo-trademark.svg"
LOGO_URL = "https://edx-cdn.org/v3/default/logo.svg"
LOGO_URL_PNG = "https://edx-cdn.org/v3/default/logo.png"
LOGO_URL_SVG = "https://edx-cdn.org/v3/default/logo.svg"
LOGO_WHITE_URL = "https://edx-cdn.org/v3/default/logo-white.svg"
LOGO_WHITE_URL_PNG = "https://edx-cdn.org/v3/default/logo-white.png"
LOGO_WHITE_URL_SVG = "https://edx-cdn.org/v3/default/logo-white.svg"
FAVICON_URL = "https://edx-cdn.org/v3/default/favicon.ico"
LOGO_URL = "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/theming/asset/images/logo.png"
LOGO_TRADEMARK_URL = LOGO_URL
LOGO_TRADEMARK_URL_PNG = LOGO_URL
LOGO_TRADEMARK_URL_SVG = LOGO_URL
LOGO_URL_PNG = LOGO_URL
LOGO_URL_SVG = LOGO_URL
LOGO_WHITE_URL = LOGO_URL
LOGO_WHITE_URL_PNG = LOGO_URL
LOGO_WHITE_URL_SVG = LOGO_URL
FAVICON_URL = "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}/favicon.ico"

SOCIAL_AUTH_REDIRECT_IS_HTTPS = {% if ENABLE_HTTPS %}True{% else %}False{% endif %}
SOCIAL_AUTH_EDX_OAUTH2_ISSUER = "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}://{{ LMS_HOST }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,14 @@ WORKDIR /openedx/credentials

{{ patch("credentials-dockerfile-post-git-checkout") }}

###### Download extra locales to /openedx/locale/contrib/locale
# mcdaniel: including these just in case there are implied dependencies
# on emitted credential data, which would be platform specific obviously.
FROM minimal as locales
ARG OPENEDX_I18N_VERSION="{{ OPENEDX_COMMON_VERSION }}"
RUN cd /tmp \
&& curl -L -o openedx-i18n.tar.gz https://github.com/openedx/openedx-i18n/archive/$OPENEDX_I18N_VERSION.tar.gz \
&& tar xzf /tmp/openedx-i18n.tar.gz \
&& mkdir -p /openedx/locale/contrib \
&& mv openedx-i18n-*/edx-platform/locale /openedx/locale/contrib \
&& rm -rf openedx-i18n*

###### Install python requirements in virtualenv
FROM python as python-requirements
ENV PATH /openedx/venv/bin:${PATH}
ENV VIRTUAL_ENV /openedx/venv/

RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked {% endif %}apt update \
&& apt install -y software-properties-common libmysqlclient-dev libxmlsec1-dev libgeos-dev
&& apt install -y software-properties-common libmysqlclient-dev libxmlsec1-dev

# Note that this means that we need to reinstall all requirements whenever there is a
# change in credentials, which sucks. But there is no obvious alternative, as we need
Expand All @@ -80,8 +68,7 @@ RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/openedx/.cache/pip,
setuptools==67.7.2 pip==23.1.2. wheel==0.40.0

# Install base requirements
RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/openedx/.cache/pip,sharing=shared {% endif %}pip install -r requirements/pip_tools.txt
RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/openedx/.cache/pip,sharing=shared {% endif %}pip install -r requirements.txt
RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/openedx/.cache/pip,sharing=shared {% endif %}pip install -r requirements/production.txt

# Install extra requirements
RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/openedx/.cache/pip,sharing=shared {% endif %}pip install \
Expand All @@ -92,12 +79,6 @@ RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/openedx/.cache/pip,

{{ patch("credentials-dockerfile-post-python-requirements") }}

# Install private requirements: this is useful for installing custom xblocks.
COPY ./requirements/ /openedx/requirements
RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/openedx/.cache/pip,sharing=shared {% endif %}cd /openedx/requirements/ \
&& touch ./private.txt \
&& pip install -r ./private.txt

{% for extra_requirement in CREDENTIALS_EXTRA_PIP_REQUIREMENTS %}RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/openedx/.cache/pip,sharing=shared {% endif %}pip install '{{ extra_requirement }}'
{% endfor %}

Expand All @@ -120,11 +101,9 @@ RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/openedx/.npm/,shari
FROM minimal as production

# Install system requirements
# mcdaniel: these are the edx-platform system requirements.
# TO DO: remove any packages that are not needed for Credentials.
RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked {% endif %}apt update \
&& apt install -y gettext gfortran graphviz graphviz-dev libffi-dev libfreetype6-dev libgeos-dev libjpeg8-dev liblapack-dev libmysqlclient-dev libpng-dev libsqlite3-dev libxmlsec1-dev lynx mysql-client ntp pkg-config rdfind
&& apt install -y libxml2 libmysqlclient-dev mime-support

# From then on, run as unprivileged "app" user
ARG APP_USER_ID=1000
Expand All @@ -134,10 +113,8 @@ USER ${APP_USER_ID}

# change file ownership to the new app user
COPY --chown=app:app --from=code /openedx/credentials /openedx/credentials
COPY --chown=app:app --from=locales /openedx/locale /openedx/locale
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
COPY --chown=app:app --from=nodejs-requirements /openedx/nodeenv /openedx/nodeenv
COPY --chown=app:app --from=nodejs-requirements /openedx/credentials/node_modules /openedx/node_modules

Expand All @@ -148,9 +125,6 @@ ENV PATH /openedx/venv/bin:./node_modules/.bin:/openedx/nodeenv/bin:${PATH}
ENV VIRTUAL_ENV /openedx/venv/
WORKDIR /openedx/credentials

# Re-install local requirements, otherwise egg-info folders are missing
RUN pip install -r requirements/production.in

# Setup minimal yml config file, which is required by production settings
RUN echo "{}" > /openedx/config.yml
ENV CREDENTIALS_CFG /openedx/config.yml
Expand Down
4 changes: 2 additions & 2 deletions tutorcredentials/templates/credentials/tasks/credentials/init
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ echo "credentials service - ./manage.py migrate create_or_update_site"
# for production
./manage.py create_or_update_site \
--site-domain "{{ CREDENTIALS_HOST }}" \
--site-name "{{ CREDENTIALS_SITE_NAME }}" \
--site-name "{{ LMS_HOST }}" \
--platform-name "{{ PLATFORM_NAME }}" \
--lms-url-root "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}{{ LMS_HOST }}" \
--catalog-api-url "{% if ENABLE_HTTPS %}https{% else %}http{% endif %}{{ DISCOVERY_HOST }}/api/v1/" \
Expand All @@ -19,7 +19,7 @@ echo "credentials service - ./manage.py migrate create_or_update_site"
# for development
./manage.py create_or_update_site \
--site-domain "{{ CREDENTIALS_HOST }}" \
--site-name "{{ CREDENTIALS_SITE_NAME }}" \
--site-name "{{ LMS_HOST }}" \
--platform-name "{{ PLATFORM_NAME }}" \
--lms-url-root "http://{{ LMS_HOST }}:8000" \
--catalog-api-url "http://{{ DISCOVERY_HOST }}:8381/api/v1/" \
Expand Down
Loading