Skip to content
This repository was archived by the owner on Jul 3, 2025. It is now read-only.
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
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ variables:
TUTOR_IMAGES: ecommerce ecommerce-worker
TUTOR_PYPI_PACKAGE: tutor-ecommerce
TUTOR_EXTRA_ENABLED_PLUGINS: discovery mfe
OPENEDX_RELEASE: maple
OPENEDX_RELEASE: nutmeg
GITHUB_REPO: overhangio/tutor-ecommerce

include:
Expand Down
8 changes: 3 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,15 @@
long_description=readme,
packages=find_packages(exclude=["tests*"]),
include_package_data=True,
python_requires=">=3.5",
install_requires=["tutor>=13.0.0,<14.0.0", "tutor-discovery>=13.0.0,<14.0.0", "tutor-mfe>=13.0.0,<14.0.0"],
entry_points={"tutor.plugin.v0": ["ecommerce = tutorecommerce.plugin"]},
python_requires=">=3.7",
install_requires=["tutor>=14.0.0,<15.0.0", "tutor-discovery>=14.0.0,<15.0.0", "tutor-mfe>=14.0.0,<15.0.0"],
entry_points={"tutor.plugin.v1": ["ecommerce = tutorecommerce.plugin"]},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand Down
2 changes: 1 addition & 1 deletion tutorecommerce/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "13.0.1"
__version__ = "14.0.0"
104 changes: 81 additions & 23 deletions tutorecommerce/plugin.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from glob import glob
import os

from .__about__ import __version__
import pkg_resources

HERE = os.path.abspath(os.path.dirname(__file__))
from tutor import hooks as tutor_hooks

templates = os.path.join(HERE, "templates")
from .__about__ import __version__

config = {
"add": {
"unique": {
"MYSQL_PASSWORD": "{{ 8|random_string }}",
"SECRET_KEY": "{{ 20|random_string }}",
"OAUTH2_SECRET": "{{ 8|random_string }}",
Expand Down Expand Up @@ -78,24 +78,82 @@
},
}

hooks = {
"build-image": {
"ecommerce": "{{ ECOMMERCE_DOCKER_IMAGE }}",
"ecommerce-worker": "{{ ECOMMERCE_WORKER_DOCKER_IMAGE }}",
},
"remote-image": {
"ecommerce": "{{ ECOMMERCE_DOCKER_IMAGE }}",
"ecommerce-worker": "{{ ECOMMERCE_WORKER_DOCKER_IMAGE }}",
},
"init": ["mysql", "lms", "ecommerce"],
}
# Initialization hooks
tutor_hooks.Filters.COMMANDS_INIT.add_item((
"mysql",
("ecommerce", "tasks", "mysql", "init"),
))
tutor_hooks.Filters.COMMANDS_INIT.add_item((
"lms",
("ecommerce", "tasks", "lms", "init"),
))
tutor_hooks.Filters.COMMANDS_INIT.add_item((
"ecommerce",
("ecommerce", "tasks", "ecommerce", "init"),
))

# Image management
tutor_hooks.Filters.IMAGES_BUILD.add_item((
"ecommerce",
("plugins", "ecommerce", "build", "ecommerce"),
"{{ ECOMMERCE_DOCKER_IMAGE }}",
(),
))
tutor_hooks.Filters.IMAGES_BUILD.add_item((
"ecommerce-worker",
("plugins", "ecommerce", "build", "ecommerce-worker"),
"{{ ECOMMERCE_WORKER_DOCKER_IMAGE }}",
(),
))
tutor_hooks.Filters.IMAGES_PULL.add_item((
"ecommerce",
"{{ ECOMMERCE_DOCKER_IMAGE }}",
))
tutor_hooks.Filters.IMAGES_PULL.add_item((
"ecommerce-worker",
"{{ ECOMMERCE_WORKER_DOCKER_IMAGE }}",
))
tutor_hooks.Filters.IMAGES_PUSH.add_item((
"ecommerce",
"{{ ECOMMERCE_DOCKER_IMAGE }}",
))
tutor_hooks.Filters.IMAGES_PUSH.add_item((
"ecommerce-worker",
"{{ ECOMMERCE_WORKER_DOCKER_IMAGE }}",
))

def patches():
all_patches = {}
for path in glob(os.path.join(HERE, "patches", "*")):
with open(path) as patch_file:
name = os.path.basename(path)
content = patch_file.read()
all_patches[name] = content
return all_patches
####### Boilerplate code
# Add the "templates" folder as a template root
tutor_hooks.Filters.ENV_TEMPLATE_ROOTS.add_item(
pkg_resources.resource_filename("tutorecommerce", "templates")
)
# Render the "build" and "apps" folders
tutor_hooks.Filters.ENV_TEMPLATE_TARGETS.add_items(
[
("ecommerce/build", "plugins"),
("ecommerce/apps", "plugins"),
],
)
# Load patches from files
for path in glob(
os.path.join(
pkg_resources.resource_filename("tutorecommerce", "patches"),
"*",
)
):
with open(path, encoding="utf-8") as patch_file:
tutor_hooks.Filters.ENV_PATCHES.add_item((os.path.basename(path), patch_file.read()))
# Add configuration entries
tutor_hooks.Filters.CONFIG_DEFAULTS.add_items(
[
(f"ECOMMERCE_{key}", value)
for key, value in config.get("defaults", {}).items()
]
)
tutor_hooks.Filters.CONFIG_UNIQUE.add_items(
[
(f"ECOMMERCE_{key}", value)
for key, value in config.get("unique", {}).items()
]
)
tutor_hooks.Filters.CONFIG_OVERRIDES.add_items(list(config.get("overrides", {}).items()))
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
logger["handlers"].remove("local")

common_payment_processor_config = json.loads("""{{ ECOMMERCE_PAYMENT_PROCESSORS|tojson(indent=4) }}""")
# Fix cybersource-rest configuration
if "cybersource" in common_payment_processor_config and "cybersource-rest" not in common_payment_processor_config:
common_payment_processor_config["cybersource-rest"] = common_payment_processor_config["cybersource"]
PAYMENT_PROCESSOR_CONFIG = {
"openedx": common_payment_processor_config,
"dev": common_payment_processor_config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ WORKDIR /openedx/ecommerce_worker
# Install python venv
RUN python3 -m venv ../venv/
ENV PATH "/openedx/venv/bin:$PATH"
RUN pip install setuptools==44.1.0 pip==20.3.4 wheel==0.37.0
RUN pip install setuptools==62.1.0 pip==22.0.4 wheel==0.37.1
RUN pip install -r requirements/production.txt

ENV WORKER_CONFIGURATION_MODULE ecommerce_worker.settings.production
Expand Down
11 changes: 3 additions & 8 deletions tutorecommerce/templates/ecommerce/build/ecommerce/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ USER ${APP_USER_ID}
# Create python venv
RUN python3 -m venv /openedx/venv/
ENV PATH "/openedx/venv/bin:$PATH"
RUN pip install setuptools==44.1.0 pip==20.3.4 wheel==0.37.0
RUN pip install setuptools==62.1.0 pip==22.0.4 wheel==0.37.1

# Install a recent version of nodejs
RUN pip install nodeenv
RUN nodeenv /openedx/nodeenv --node=12.13.0 --prebuilt
RUN nodeenv /openedx/nodeenv --node=16.14.2 --prebuilt
ENV PATH /openedx/nodeenv/bin:${PATH}

# Install ecommerce
Expand All @@ -28,19 +28,14 @@ WORKDIR /openedx/ecommerce
RUN git config --global user.email "tutor@overhang.io" \
&& git config --global user.name "Tutor"

# Fix payment MFE connection
# https://github.com/edx/ecommerce/pull/3586
RUN git fetch https://github.com/bloomedn/ecommerce 3f9af6ac48b26b579419fcdec2efb06aecc961eb && git cherry-pick 3f9af6ac48b26b579419fcdec2efb06aecc961eb
RUN git fetch https://github.com/bloomedn/ecommerce 5fcb85218a5f4b1d4bd413a40f0a40801685bece && git cherry-pick 5fcb85218a5f4b1d4bd413a40f0a40801685bece

# nodejs requirements (aka: "make requirements.js")
ARG NPM_REGISTRY=https://registry.npmjs.org/
RUN npm install --verbose --registry=$NPM_REGISTRY
RUN ./node_modules/.bin/bower install --allow-root

# python requirements
RUN pip install -r requirements.txt
RUN pip install uwsgi==2.0.19.1
RUN pip install uwsgi==2.0.20

# Install private requirements: this is useful for installing custom payment processors.
COPY --chown=app:app ./requirements/ /openedx/requirements
Expand Down