Skip to content

Commit bf201ae

Browse files
committed
feat: wordpress instance management
1 parent 50a87a7 commit bf201ae

File tree

19 files changed

+524
-51
lines changed

19 files changed

+524
-51
lines changed

.github/workflows/test.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
python-version: ['3.8', '3.12']
12+
python-version: ['3.7', '3.12']
1313
steps:
1414
- uses: actions/checkout@v4
1515
- name: Set up Python ${{ matrix.python-version }}
@@ -20,6 +20,17 @@ jobs:
2020
run: python -m pip install --upgrade pip
2121
- name: Install dependencies
2222
run: |
23-
pip install .[dev]
23+
if [ "${{ matrix.python-version }}" = "3.7" ]; then
24+
pip install "tutor==15.0.0"
25+
else
26+
pip install -U tutor
27+
fi
28+
# Install dev dependencies for testing
29+
pip install pylint mypy black types-setuptools importlib-resources
30+
echo "Installing tutor-contrib-wordpress"
31+
pip install -e .
32+
echo "Enable wordpress plugin and save configuration"
33+
tutor plugins enable wordpress
34+
tutor config save
2435
- name: Test lint, types, and format
2536
run: make test

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.rulers": [120]
3+
}

README.rst

Lines changed: 107 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ WordPress Plugin for `Tutor`_
1010
:target: https://www.gnu.org/licenses/agpl-3.0.en.html
1111

1212
Overview
13-
--------
13+
********
1414

15-
This is a `Tutor`_ plugin for integrating the `Open edX Commerce WordPress Plugin`_ with your Open edX instance.
16-
The plugin allows seamless synchronization and interaction between your WordPress site and Open edX platform,
17-
providing a cohesive e-commerce experience. If you don't know how to install the WordPress plugin, check out
18-
this `installation guide`_.
15+
This is a `Tutor`_ plugin that provides complete WordPress integration with your Open edX instance. It includes:
16+
17+
- Full WordPress installation and management
18+
- Integration with the `Open edX Commerce WordPress Plugin`_
19+
- Built-in phpMyAdmin for database management (optional)
20+
21+
If you need help installing the WordPress plugin, check out this `installation guide`_.
1922

2023
Before you start
2124
----------------
@@ -25,13 +28,13 @@ configuration and integration of the Open edX platform with an existing WordPres
2528
feel free to open an issue or better yet, a PR.
2629

2730
Prerequisites
28-
-------------
31+
*************
2932

30-
- A running WordPress site with the `Open edX Commerce WordPress Plugin`_ installed.
31-
- Installation of Tutor version >= 15.0.0.
33+
- Installation of Tutor version >= 15.0.0
34+
- MySQL database (can use the same one as Open edX)
3235

3336
Installation
34-
------------
37+
************
3538

3639
Ensure you are using Tutor v15+ (Olive onwards). First, install the plugin by running:
3740

@@ -51,55 +54,132 @@ Alternatively, if you already have a running Open edX instance, just run the nec
5154
.. code-block:: bash
5255
5356
tutor dev|local|k8s do init --limit=wordpress
57+
tutor dev|local|k8s start wordpress
58+
59+
phpMyAdmin
60+
**********
61+
62+
The plugin includes optional phpMyAdmin support for managing your WordPress database. To enable it:
63+
64+
1. Set ``RUN_PHPMYADMIN: true`` in your ``config.yml`` by running:
65+
66+
.. code-block:: bash
67+
68+
tutor config save -s RUN_PHPMYADMIN=true
69+
70+
2. Start phpMyAdmin by running:
71+
72+
.. code-block:: bash
73+
74+
tutor dev|local|k8s launch
75+
# or
76+
tutor dev|local|k8s start phpmyadmin
77+
78+
3. Access phpMyAdmin at: http://phpmyadmin.local.edly.io:8081 (local) or https://phpmyadmin.yourdomain.com (production)
79+
80+
**Important**
5481

55-
Configuration
56-
-------------
82+
Enabling phpMyAdmin can be useful for managing your WordPress database directly. However, please be aware that exposing
83+
phpMyAdmin can pose security risks if not properly secured. Ensure that you have strong passwords, and consider
84+
restricting access to phpMyAdmin to trusted IP addresses only.
5785

58-
Inside your WordPress admin panel, you will need to configure the following values:
86+
WordPress Configuration
87+
***********************
88+
89+
The plugin automatically installs WordPress with the Open edX Commerce and Woocommerce plugins. Inside your WordPress
90+
admin panel, go to Settings -> Open edX Sync plugin, and configure:
5991

6092
- **Open edX Domain**
6193
- **Client ID**
6294
- **Client Secret**
6395

96+
To verify the connection, click on "Generate JWT Token". If the process is successful, a new token will be generated.
97+
6498
.. image:: https://raw.githubusercontent.com/codewithemad/tutor-contrib-wordpress/master/images/openedx-sync-plugin-settings.png
6599
:alt: Open edX Sync Plugin Settings in your WordPress Settings
66100

67-
68101
You can retrieve these configuration values by running:
69102

70103
.. code-block:: bash
71104
72105
tutor wordpress config
73106
107+
This command will output the current configurations, including the Client ID, Client Secret, Open edX Domain,
108+
WordPress Domain, and phpMyAdmin Domain (if enabled). Here is an example of the output:
74109

75110
.. code-block:: text
76111
77112
===============================================
78-
WordPress Plugin Configurations
113+
WordPress Plugin Configurations
79114
===============================================
80115
81-
Open edX Domain: http://local.edly.io
82-
Client ID: qjCayDktffXrU09N17NrslKyWQ2EwzWn
83-
Client ID (dev): JDx6Uy0hN67VUfacxKcLyYQz7HK9liVx
84-
Client Secret: P4w82huaZQdyz4qolknsIHYneGEoIggc
116+
Client ID: vvpTamiepPwjZhr0uOQGr5PhYBzp2hQw
117+
Client ID (dev): MlbXk1V3wB7nWPAAyLF3McyfBBMqExa4
118+
Client Secret: MdrgbtU8Q94He3gejF6Zf5MDookoeozO
85119
120+
Open edX Domain: http://local.edly.io:8000
121+
Wordpress Domain: http://site.local.edly.io:8080
122+
phpMyAdmin Domain: http://phpmyadmin.local.edly.io:8081
86123
87-
Or by using Tutor to print them individually:
88124
89-
.. code-block:: bash
125+
Configuration Variables
126+
***********************
127+
128+
The plugin supports the following configuration variables:
129+
130+
WordPress Settings
131+
==================
132+
133+
- ``WORDPRESS_VERSION``: Plugin version
134+
- ``WORDPRESS_HOST``: WordPress site hostname
135+
- ``WORDPRESS_PORT``: WordPress port (default: 8080)
136+
- ``WORDPRESS_DEBUG``: Enable WordPress debug mode (default: false)
137+
- ``WORDPRESS_DOCKER_IMAGE``: Docker image for WordPress
138+
- ``WORDPRESS_OPENEDX_PLUGIN``: URL to the Open edX Commerce plugin
139+
- ``WORDPRESS_WOOCOMMERCE_PLUGIN``: (default: "https://downloads.wordpress.org/plugin/woocommerce.9.4.2.zip")
140+
The WooCommerce plugin zip file URL. You can specify a different version if needed.
141+
- ``WORDPRESS_OFFICIAL_IMAGE``: (default: "wordpress:6.7.1-php8.1")
142+
The official WordPress Docker image used as the base for building the plugin's custom image.
143+
This image includes PHP and Apache server. You can specify a different version or PHP variant
144+
if needed.
145+
146+
Database Settings
147+
=================
148+
149+
- ``WORDPRESS_MYSQL_HOST``: MySQL host
150+
- ``WORDPRESS_MYSQL_PORT``: MySQL port
151+
- ``WORDPRESS_MYSQL_DATABASE``: Database name (default: wordpress)
152+
- ``WORDPRESS_MYSQL_USERNAME``: Database username
153+
- ``WORDPRESS_MYSQL_PASSWORD``: Database password (auto-generated)
154+
- ``WORDPRESS_TABLE_PREFIX``: Table prefix (default: wp_)
155+
156+
Storage Settings
157+
================
158+
159+
- ``WORDPRESS_DATA_VOLUME_SIZE``: Size of WordPress persistent volume (default: 5Gi)
160+
161+
OAuth2 Settings
162+
===============
163+
164+
- ``WORDPRESS_OAUTH2_SECRET``: OAuth2 secret key (auto-generated)
165+
- ``WORDPRESS_OAUTH2_KEY_SSO``: OAuth2 client ID (auto-generated)
166+
- ``WORDPRESS_OAUTH2_KEY_SSO_DEV``: OAuth2 development client ID (auto-generated)
167+
168+
phpMyAdmin Settings
169+
===================
90170

91-
tutor config printvalue LMS_HOST
92-
tutor config printvalue WORDPRESS_OAUTH2_SECRET
93-
tutor config printvalue WORDPRESS_OAUTH2_KEY_SSO
94-
tutor config printvalue WORDPRESS_OAUTH2_KEY_SSO_DEV
171+
- ``RUN_PHPMYADMIN``: Enable/disable phpMyAdmin (default: false)
172+
- ``PHPMYADMIN_HOST``: phpMyAdmin hostname
173+
- ``PHPMYADMIN_PORT``: phpMyAdmin port (default: 8081)
174+
- ``PHPMYADMIN_DOCKER_IMAGE``: Docker image for phpMyAdmin
95175

96176
Contributing
97-
------------
177+
************
98178

99-
We welcome all contributions! Feel free to open a Pull Request.
179+
We welcome all contributions! Feel free to open a Pull Request or an Issue.
100180

101181
License
102-
-------
182+
*******
103183

104184
This software is licensed under the terms of the `AGPLv3`_.
105185

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- [Feature] Now you can manage and deploy a real wordpress instance (by @CodeWithEmad)
2+
- [Feature] You can now access phpmyadmin (by @CodeWithEmad)
3+
736 Bytes
Loading

setup.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,21 @@ def load_about():
4141
long_description_content_type="text/x-rst",
4242
packages=find_packages(exclude=["tests*"]),
4343
include_package_data=True,
44-
python_requires=">=3.8",
45-
install_requires=["tutor>=14.0.0,<19.0.0"],
44+
python_requires=">=3.7",
45+
install_requires=["tutor>=15.0.0,<19.0.0", "importlib_resources", "pylint"],
4646
extras_require={
4747
"dev": [
48-
"tutor[dev]>=14.0.0,<19.0.0",
49-
]
50-
},
51-
entry_points={
52-
"tutor.plugin.v1": [
53-
"wordpress = tutorwordpress.plugin"
48+
"tutor[dev]>=15.0.0,<19.0.0",
5449
]
5550
},
51+
entry_points={"tutor.plugin.v1": ["wordpress = tutorwordpress.plugin"]},
5652
classifiers=[
5753
"Development Status :: 3 - Alpha",
5854
"Intended Audience :: Developers",
5955
"License :: OSI Approved :: GNU Affero General Public License v3",
6056
"Operating System :: OS Independent",
6157
"Programming Language :: Python",
58+
"Programming Language :: Python :: 3.7",
6259
"Programming Language :: Python :: 3.8",
6360
"Programming Language :: Python :: 3.9",
6461
"Programming Language :: Python :: 3.10",

tutorwordpress/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.0.1"
1+
__version__ = "1.1.0"

tutorwordpress/patches/caddyfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# WordPress
2+
{{ WORDPRESS_HOST }}{$default_site_port} {
3+
4+
import proxy "wordpress:{{ WORDPRESS_PORT }}"
5+
}
6+
7+
# PHPMyAdmin
8+
{%- if RUN_PHPMYADMIN %}
9+
{{ PHPMYADMIN_HOST }}{$default_site_port} {
10+
import proxy "phpmyadmin:80"
11+
}
12+
{%- endif %}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: wordpress
6+
labels:
7+
app.kubernetes.io/name: wordpress
8+
spec:
9+
selector:
10+
matchLabels:
11+
app.kubernetes.io/name: wordpress
12+
template:
13+
metadata:
14+
labels:
15+
app.kubernetes.io/name: wordpress
16+
spec:
17+
initContainers:
18+
- name: init-wordpress
19+
image: {{ WORDPRESS_DOCKER_IMAGE }}
20+
command: ['sh', '-c', 'chown -R www-data:www-data /var/www/html/wp-content']
21+
volumeMounts:
22+
- name: wordpress-data
23+
mountPath: /var/www/html/wp-content
24+
securityContext:
25+
runAsUser: 0
26+
containers:
27+
- name: wordpress
28+
image: {{ WORDPRESS_DOCKER_IMAGE }}
29+
ports:
30+
- containerPort: 8080
31+
env:
32+
- name: WORDPRESS_DB_HOST
33+
value: {{ WORDPRESS_MYSQL_HOST }}
34+
- name: WORDPRESS_DB_USER
35+
value: {{ WORDPRESS_MYSQL_USERNAME }}
36+
- name: WORDPRESS_DB_PASSWORD
37+
value: {{ WORDPRESS_MYSQL_PASSWORD }}
38+
- name: WORDPRESS_DB_NAME
39+
value: {{ WORDPRESS_MYSQL_DATABASE }}
40+
- name: WORDPRESS_TABLE_PREFIX
41+
value: {{ WORDPRESS_TABLE_PREFIX }}
42+
volumeMounts:
43+
- name: wordpress-data
44+
mountPath: /var/www/html/wp-content
45+
securityContext:
46+
runAsUser: 33
47+
runAsGroup: 33
48+
volumes:
49+
- name: wordpress-data
50+
persistentVolumeClaim:
51+
claimName: wordpress-data
52+
53+
{% if RUN_PHPMYADMIN %}
54+
---
55+
apiVersion: apps/v1
56+
kind: Deployment
57+
metadata:
58+
name: phpmyadmin
59+
labels:
60+
app.kubernetes.io/name: phpmyadmin
61+
spec:
62+
selector:
63+
matchLabels:
64+
app.kubernetes.io/name: phpmyadmin
65+
template:
66+
metadata:
67+
labels:
68+
app.kubernetes.io/name: phpmyadmin
69+
spec:
70+
containers:
71+
- name: phpmyadmin
72+
image: {{ PHPMYADMIN_DOCKER_IMAGE }}
73+
ports:
74+
- containerPort: 80
75+
env:
76+
- name: PMA_HOST
77+
value: {{ WORDPRESS_MYSQL_HOST }}
78+
- name: PMA_PORT
79+
value: "{{ WORDPRESS_MYSQL_PORT }}"
80+
{% endif %}

tutorwordpress/patches/k8s-jobs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
apiVersion: batch/v1
3+
kind: Job
4+
metadata:
5+
name: wordpress-job
6+
labels:
7+
app.kubernetes.io/component: job
8+
spec:
9+
template:
10+
spec:
11+
restartPolicy: Never
12+
containers:
13+
- name: wordpress
14+
image: {{ WORDPRESS_DOCKER_IMAGE }}
15+
volumeMounts:
16+
- name: wordpress-data
17+
mountPath: /var/www/html/wp-content
18+
volumes:
19+
- name: wordpress-data
20+
persistentVolumeClaim:
21+
claimName: wordpress-data

0 commit comments

Comments
 (0)