MoodleNet: Difference between revisions
(Started V3 quickstart and config) |
No edit summary |
||
Line 9: | Line 9: | ||
* The MoodleNet release schedule is available on the [https://tracker.moodle.org/projects/MDLNET?selectedItem=com.atlassian.jira.jira-projects-plugin%3Arelease-page&status=unreleased MoodleNet Roadmap]. | * The MoodleNet release schedule is available on the [https://tracker.moodle.org/projects/MDLNET?selectedItem=com.atlassian.jira.jira-projects-plugin%3Arelease-page&status=unreleased MoodleNet Roadmap]. | ||
== Quick start guide == | == Quick start guide == | ||
====System Requirements==== | |||
==== System Requirements ==== | |||
MoodleNet requires the followings to be available on your system | MoodleNet requires the followings to be available on your system | ||
* NodeJs ^16 [https://nodejs.org] | *NodeJs ^16 [https://nodejs.org] | ||
* npm ^8 [https://nodejs.org/en/knowledge/getting-started/npm/what-is-npm/] | *npm ^8 [https://nodejs.org/en/knowledge/getting-started/npm/what-is-npm/] | ||
* ArangoDB [https://www.arangodb.com/] | *ArangoDB [https://www.arangodb.com/] | ||
Notice that the current nodejs LTSs frameworks are nodejs ^18 and npm ^9 | Notice that the current nodejs LTSs frameworks are nodejs ^18 and npm ^9 | ||
Line 20: | Line 19: | ||
Make sure to have nodejs ^16 installed and you should get npm ^8 as well | Make sure to have nodejs ^16 installed and you should get npm ^8 as well | ||
====Deploy an ArangoDB instance==== | |||
MoodleNet uses [https://www.arangodb.com/ ArangoDB] as main database | |||
You can choose how and where to deploy your ArangoDB, as long as it can be reached by MoodleNet process | You can choose how and where to deploy your ArangoDB, as long as it can be reached by MoodleNet process | ||
An easy way to install ArangDB locally as a service is by using Docker[https://hub.docker.com/_/arangodb] e.g. : | An easy way to install run ArangDB locally as a service is by using Docker[https://hub.docker.com/_/arangodb] e.g. : | ||
docker run -d --restart unless-stopped -e ARANGO_NO_AUTH=1 -p 8529:8529 --name=mn-3-db arangodb:3.10 | docker run -d --restart unless-stopped -e ARANGO_NO_AUTH=1 -p 8529:8529 --name=mn-3-db arangodb:3.10 | ||
Possibly tweaking some options as you like, | Possibly tweaking some options as you like, e.g. mounting a volume|directory for data or setting a password | ||
====Install MoodleNet==== | |||
==== Install MoodleNet ==== | Install Moodlenet by simply issueing the following npm command | ||
npm create @moodlenet@latest path/to/installation/folder | npm create @moodlenet@latest path/to/installation/folder | ||
That will install all MoodleNet core packages in the choosen folder | |||
==== Start MoodleNet process ==== | it will also create a default configuration file ('''default.config.json''') and a default cryptographic key-pair for the system ('''default.crypto.privateKey , default.crypto.publicKey''') | ||
====Start MoodleNet process ==== | |||
To start MoodleNet issue the following command from within the installation directory | To start MoodleNet issue the following command from within the installation directory | ||
npm start | npm start | ||
open your browser on http://localhost:8080 | open your browser on http://localhost:8080 | ||
''' | '''Notice:''' on the first run the system will have to compile the webapp, so you'll get a 404 until ready. It should take a few minutes | ||
====MoodleNet configuration file==== | |||
MoodleNet configuration file ('''default.config.json''') holds all static system configs. | |||
Here's how the default config looks like after install: | |||
{ | { | ||
"pkgs": { | "pkgs": { | ||
"@moodlenet/core": { | "@moodlenet/core": { | ||
"baseFsFolder": "/ | "baseFsFolder": "/path/to/installation/dir/fs", | ||
"instanceDomain": "<nowiki>http://localhost:8080</nowiki>", | "instanceDomain": "<nowiki>http://localhost:8080</nowiki>", | ||
"npmRegistry": "<nowiki>https://registry.npmjs.org</nowiki>", | "npmRegistry": "<nowiki>https://registry.npmjs.org</nowiki>", | ||
"mainLogger": { | "mainLogger": { | ||
"consoleLevel": " | "consoleLevel": "info", | ||
"file": { | "file": { | ||
"path": "./log/moodlenet.%DATE%.log", | "path": "./log/moodlenet.%DATE%.log", | ||
"level": " | "level": "info" | ||
} | } | ||
} | } | ||
Line 62: | Line 61: | ||
"alg": "RS256", | "alg": "RS256", | ||
"type": "PKCS8", | "type": "PKCS8", | ||
"private": "/ | "private": "/path/to/installation/dir/default.crypto.privateKey", | ||
"public": "/ | "public": "/path/to/installation/dir/default.crypto.publicKey" | ||
} | } | ||
}, | }, | ||
Line 87: | Line 86: | ||
}, | }, | ||
"@moodlenet/system-entities": { | "@moodlenet/system-entities": { | ||
"rootPassword": " | "rootPassword": "eqhb30x9iq5" | ||
}, | }, | ||
"@moodlenet/react-app": { | "@moodlenet/react-app": {} | ||
} | } | ||
here's some relevant configs you may want to check and tweak | here's some relevant configs you may want to check and tweak | ||
*'''@moodlenet/arangodb.connectionCfg.url''' : the default config assumes you installed ArangoDB without password with standard port on the same host | |||
*'''@moodlenet/core.baseFsFolder''' : path (better absolute path instead of relative to MoodleNet process cwd) to the system root folder for system filesystem persistency, if you want to change the system-filesystem-root after the system already run, move or clone the existing folder somewhere else and set this config properly to point to the new path | |||
*'''@moodlenet/core.instanceDomain''' : the public domain of your moodlenet instance (e.g. <nowiki>https://moodlenet.example.com</nowiki>) - the default one (<nowiki>http://localhost:8080</nowiki>) is ok for testing and dev | |||
*'''@moodlenet/email-service.nodemailerTransport''' : the [https://nodemailer.com/ nodemailer] [https://nodemailer.com/smtp/ transport configuration] for the system email service. It can be a simple smtp url string, or a [https://nodemailer.com/smtp/ nodemailer standard config object]. '''Notice''': with the default configuration '''{ "jsonTransport": true }''' the system won't send any email, it will simply log them) | |||
*'''@moodlenet/system-entities.rootPassword''' : a static root password for edge cases - you'll use it to give the first admin permission to a user (see below) - this property is optional, if not set the root user is disabled | |||
*'''@moodlenet/http-server.port''' : the HTTP server port to listen | |||
Moodlenet's HTTP service doesn't support HTTPS. | |||
It's always a good practice to back Moodlenet with a HTTP reverse proxy (e.g. nginx, Apache) and it is a must if you want to publish over HTTPS, configuring TLS on it | |||
====Default authentication system==== | |||
Moodlenet comes with a simple email+password authentication system (pkg @moodlenet/simple-email-auth) that lets users signup and login with a verified email | |||
Users can sign up with their email, receive in their inbox a confirmation link to click and create their user-account | |||
====Assign admin privileges to user==== | |||
As you deploy a new instance, no user is present in the system. | |||
Signup with your email and create your user. | |||
Test login, then logout and browse to the hidden page '''<nowiki>http://localhost:8080/login/root</nowiki>''', here you can type in the '''rootPassword''' (specified in config file) to login as root. | |||
Open the avatar menu on top right header, and click '''admin''' link | |||
Click on '''Users''' section on the left, and see your user listed there. Activate the '''admin''' icon to give your user admin privileges | |||
Now you can log out and login back with your email, see you gained the '''admin''' link in your avatar menu | |||
== Migrate from V2 == | |||
If you have a v2 running and want to migrate it to v3 , you can use the [https://www.npmjs.com/package/@moodlenet/v2-migrate-v3 @moodlenet/v2-migrate-v3] | |||
The v3 system must have access to Moodlenet-V2 persistencies: its running arangoDB instance and the MN2 filesystem as configured in [https://gitlab.com/moodlenet/moodlenet/-/tree/1c8c7eb9b9aa2a3ee912871c670480b3e5fa0f70/packages/ce-platform#set-environment-variables V2 env variable '''STATICASSETS_FS_ROOT_FOLDER'''] | |||
After installed Moodlenet, issue the following command from the installation folder | |||
npm install @moodlenet/v2-migrate-v3 | |||
Edit the '''default.config.json''' adding a '''@moodlenet/v2-migrate-v3''' section beside the others, it should look like that | |||
"@moodlenet/v2-migrate-v3": { | |||
"v2DbConnectionCfg": { | |||
"url": "<nowiki>http://your-mn-v2-arangodb-host:8529</nowiki>" | |||
}, | |||
"v2AssetFolder": "/path/to/v2/asset/folder" | |||
} | |||
re/start the system, all the services will start after the migration done | |||
== MoodleNet architecture == | ==MoodleNet architecture== | ||
MoodleNet is a full stack TypeScript/JavaScript system using: | MoodleNet is a full stack TypeScript/JavaScript system using: | ||
* NodeJs | *NodeJs | ||
** NPM Packages [https://nodejs.org/en/knowledge/getting-started/npm/what-is-npm/] | ** NPM Packages [https://nodejs.org/en/knowledge/getting-started/npm/what-is-npm/] | ||
** ESM Modules [https://nodejs.org/api/esm.html#introduction] | **ESM Modules [https://nodejs.org/api/esm.html#introduction] | ||
* Browsers | *Browsers | ||
** ReactJs 18 [https://reactjs.org/] | **ReactJs 18 [https://reactjs.org/] | ||
** HTML5 [https://html.spec.whatwg.org/multipage/] | **HTML5 [https://html.spec.whatwg.org/multipage/] | ||
** CSS3 [https://www.w3.org/Style/CSS/] | **CSS3 [https://www.w3.org/Style/CSS/] | ||
== MoodleNet development environment == | ==MoodleNet development environment== | ||
* NodeJs | *NodeJs ^16 https://nodejs.org/ | ||
* ArangoDB (we suggest using [https://www.docker.com/ Docker]) | * ArangoDB ^3 (we suggest using [https://www.docker.com/ Docker]) | ||
* We recommend the open source IDE Visual Studio Code https://code.visualstudio.com/ | *We recommend the open source IDE Visual Studio Code https://code.visualstudio.com/ | ||
=== Setup development environment === | === Setup development environment=== | ||
'''From the command line interface (CLI):''' | '''From the command line interface (CLI):''' | ||
Ensure ArangoDB is running on localhost. You may | Ensure ArangoDB is running on localhost. You may run it in a Docker container issueing a command as below: | ||
docker run -e ARANGO_NO_AUTH=1 -p 8529:8529 | docker run -e ARANGO_NO_AUTH=1 -p 8529:8529 --name=mn3-dev arangodb:3.10 | ||
Clone the repository, you may wish to fork it, but that's not required: | Clone the repository, you may wish to fork it, but that's not required: | ||
git clone <nowiki>https://gitlab.com/moodlenet/moodlenet.git</nowiki> | git clone <nowiki>https://gitlab.com/moodlenet/moodlenet.git</nowiki> | ||
Line 125: | Line 157: | ||
Install and initialize the project: | Install and initialize the project: | ||
npm install | npm install | ||
Install a development | Install a development server: | ||
npm run dev-install-backend | npm run dev-install-backend my-dev # <- my-dev: an arbitrary dev-installation name | ||
In the example we choosed '''my-dev''' as installation name, the tool will then setup a dev installation in '''./.dev-machines/my-dev''' | |||
You can create as many dev installations as you wish. | |||
Run development backend: | Run development backend: | ||
npm run dev-start-backend my-dev | npm run dev-start-backend my-dev # <- my-dev : the name you choosed when installed | ||
The first run of the system | The first run of the system may take some time to install. | ||
The default configuration for dev includes the config '''@moodlenet/react-app.noWebappServer: true''' that prevents the server to serve the webapp, so you won't access the webapp on <nowiki>http://localhost:8080</nowiki> | |||
Instead, you'll want to run a webpack+HMR serving the webapp issueing | |||
npm run dev-start-webapp my-dev # <- my-dev: the installaton server to point to | |||
Once all started, browse http://localhost:3000 | |||
===Mono-Repository management with Lerna.js=== | |||
// | |||
=== Mono-Repository management with Lerna.js === | |||
MoodleNet project takes leverages [https://lerna.js.org/ lerna.js] to manage multi-package mono-repository . | MoodleNet project takes leverages [https://lerna.js.org/ lerna.js] to manage multi-package mono-repository . | ||
Please refer to [https://lerna.js.org/ Lerna documentation] to understand how it manages mono-repo and project-packages dependency linking in the development environment. | Please refer to [https://lerna.js.org/ Lerna documentation] to understand how it manages mono-repo and project-packages dependency linking in the development environment. | ||
Questions? Please take a look in the [https://moodle.org/mod/forum/view.php?id=8726 MoodleNet Community] and [https://tracker.moodle.org/projects/MDLNET/summary Tracker] for answers or to ask for help. | Questions? Please take a look in the [https://moodle.org/mod/forum/view.php?id=8726 MoodleNet Community] and [https://tracker.moodle.org/projects/MDLNET/summary Tracker] for answers or to ask for help. | ||
*[https://moodledev.io/general/development/tracker Using Tracker] | |||
* [https://moodledev.io/general/development/tracker Using Tracker] | *[https://www.npmjs.com/package/@moodlenet/ce-platform Code repository] | ||
* [https://www.npmjs.com/package/@moodlenet/ce-platform Code repository] | *[https://docs.moodle.org/moodlenet/Main_Page MoodleNet user documentation] | ||
* [https://docs.moodle.org/moodlenet/Main_Page MoodleNet user documentation] | *[https://moodle.org/mod/forum/view.php?id=8726 MoodleNet news and discussion] | ||
* [https://moodle.org/mod/forum/view.php?id=8726 MoodleNet news and discussion] | *[https://tracker.moodle.org/secure/RapidBoard.jspa?rapidView=167&view=detail MoodleNet Issue Tracker] | ||
* [https://tracker.moodle.org/secure/RapidBoard.jspa?rapidView=167&view=detail MoodleNet Issue Tracker] | *[https://gitlab.com/moodlenet/moodlenet/-/issues MoodleNet Gitlab Issues] | ||
* [https://gitlab.com/moodlenet/moodlenet/-/issues MoodleNet Gitlab Issues] | |||
[[es:MoodleNet]] | [[es:MoodleNet]] |
Revision as of 13:10, 6 July 2023
What is MoodleNet?
MoodleNet is a flexible Open Education Technology platform for curating collections of the best known Open Educational (and other) Resources. You'll find more general information in the MoodleNet user documentation.
If you are looking to get started as a MoodleNet developer, we recommend taking the MoodleNet for Developers course with Moodle Academy.
Current status
Take a look at MoodleNet releases in our Tracker.
Roadmap
- The MoodleNet release schedule is available on the MoodleNet Roadmap.
Quick start guide
System Requirements
MoodleNet requires the followings to be available on your system
Notice that the current nodejs LTSs frameworks are nodejs ^18 and npm ^9
We tested so far with the previous LTSs nodejs ^16 and npm ^8
Make sure to have nodejs ^16 installed and you should get npm ^8 as well
Deploy an ArangoDB instance
MoodleNet uses ArangoDB as main database
You can choose how and where to deploy your ArangoDB, as long as it can be reached by MoodleNet process
An easy way to install run ArangDB locally as a service is by using Docker[4] e.g. :
docker run -d --restart unless-stopped -e ARANGO_NO_AUTH=1 -p 8529:8529 --name=mn-3-db arangodb:3.10
Possibly tweaking some options as you like, e.g. mounting a volume|directory for data or setting a password
Install MoodleNet
Install Moodlenet by simply issueing the following npm command
npm create @moodlenet@latest path/to/installation/folder
That will install all MoodleNet core packages in the choosen folder
it will also create a default configuration file (default.config.json) and a default cryptographic key-pair for the system (default.crypto.privateKey , default.crypto.publicKey)
Start MoodleNet process
To start MoodleNet issue the following command from within the installation directory
npm start
open your browser on http://localhost:8080
Notice: on the first run the system will have to compile the webapp, so you'll get a 404 until ready. It should take a few minutes
MoodleNet configuration file
MoodleNet configuration file (default.config.json) holds all static system configs.
Here's how the default config looks like after install:
{ "pkgs": { "@moodlenet/core": { "baseFsFolder": "/path/to/installation/dir/fs", "instanceDomain": "http://localhost:8080", "npmRegistry": "https://registry.npmjs.org", "mainLogger": { "consoleLevel": "info", "file": { "path": "./log/moodlenet.%DATE%.log", "level": "info" } } }, "@moodlenet/crypto": { "keys": { "alg": "RS256", "type": "PKCS8", "private": "/path/to/installation/dir/default.crypto.privateKey", "public": "/path/to/installation/dir/default.crypto.publicKey" } }, "@moodlenet/arangodb": { "connectionCfg": { "url": "http://localhost:8529" } }, "@moodlenet/http-server": { "port": 8080, "defaultRpcUploadMaxSize": "5MB" }, "@moodlenet/ed-resource": { "resourceUploadMaxSize": "1.2GB" }, "@moodlenet/simple-email-auth": { "newUserNotPublisher": false }, "@moodlenet/email-service": { "nodemailerTransport": { "jsonTransport": true } }, "@moodlenet/system-entities": { "rootPassword": "eqhb30x9iq5" }, "@moodlenet/react-app": {} }
here's some relevant configs you may want to check and tweak
- @moodlenet/arangodb.connectionCfg.url : the default config assumes you installed ArangoDB without password with standard port on the same host
- @moodlenet/core.baseFsFolder : path (better absolute path instead of relative to MoodleNet process cwd) to the system root folder for system filesystem persistency, if you want to change the system-filesystem-root after the system already run, move or clone the existing folder somewhere else and set this config properly to point to the new path
- @moodlenet/core.instanceDomain : the public domain of your moodlenet instance (e.g. https://moodlenet.example.com) - the default one (http://localhost:8080) is ok for testing and dev
- @moodlenet/email-service.nodemailerTransport : the nodemailer transport configuration for the system email service. It can be a simple smtp url string, or a nodemailer standard config object. Notice: with the default configuration { "jsonTransport": true } the system won't send any email, it will simply log them)
- @moodlenet/system-entities.rootPassword : a static root password for edge cases - you'll use it to give the first admin permission to a user (see below) - this property is optional, if not set the root user is disabled
- @moodlenet/http-server.port : the HTTP server port to listen
Moodlenet's HTTP service doesn't support HTTPS.
It's always a good practice to back Moodlenet with a HTTP reverse proxy (e.g. nginx, Apache) and it is a must if you want to publish over HTTPS, configuring TLS on it
Default authentication system
Moodlenet comes with a simple email+password authentication system (pkg @moodlenet/simple-email-auth) that lets users signup and login with a verified email
Users can sign up with their email, receive in their inbox a confirmation link to click and create their user-account
Assign admin privileges to user
As you deploy a new instance, no user is present in the system.
Signup with your email and create your user.
Test login, then logout and browse to the hidden page http://localhost:8080/login/root, here you can type in the rootPassword (specified in config file) to login as root.
Open the avatar menu on top right header, and click admin link
Click on Users section on the left, and see your user listed there. Activate the admin icon to give your user admin privileges
Now you can log out and login back with your email, see you gained the admin link in your avatar menu
Migrate from V2
If you have a v2 running and want to migrate it to v3 , you can use the @moodlenet/v2-migrate-v3
The v3 system must have access to Moodlenet-V2 persistencies: its running arangoDB instance and the MN2 filesystem as configured in V2 env variable STATICASSETS_FS_ROOT_FOLDER
After installed Moodlenet, issue the following command from the installation folder
npm install @moodlenet/v2-migrate-v3
Edit the default.config.json adding a @moodlenet/v2-migrate-v3 section beside the others, it should look like that
"@moodlenet/v2-migrate-v3": { "v2DbConnectionCfg": { "url": "http://your-mn-v2-arangodb-host:8529" }, "v2AssetFolder": "/path/to/v2/asset/folder" }
re/start the system, all the services will start after the migration done
MoodleNet architecture
MoodleNet is a full stack TypeScript/JavaScript system using:
MoodleNet development environment
- NodeJs ^16 https://nodejs.org/
- ArangoDB ^3 (we suggest using Docker)
- We recommend the open source IDE Visual Studio Code https://code.visualstudio.com/
Setup development environment
From the command line interface (CLI):
Ensure ArangoDB is running on localhost. You may run it in a Docker container issueing a command as below:
docker run -e ARANGO_NO_AUTH=1 -p 8529:8529 --name=mn3-dev arangodb:3.10
Clone the repository, you may wish to fork it, but that's not required:
git clone https://gitlab.com/moodlenet/moodlenet.git
Change to the project's folder:
cd moodlenet
Install and initialize the project:
npm install
Install a development server:
npm run dev-install-backend my-dev # <- my-dev: an arbitrary dev-installation name
In the example we choosed my-dev as installation name, the tool will then setup a dev installation in ./.dev-machines/my-dev
You can create as many dev installations as you wish.
Run development backend:
npm run dev-start-backend my-dev # <- my-dev : the name you choosed when installed
The first run of the system may take some time to install.
The default configuration for dev includes the config @moodlenet/react-app.noWebappServer: true that prevents the server to serve the webapp, so you won't access the webapp on http://localhost:8080
Instead, you'll want to run a webpack+HMR serving the webapp issueing
npm run dev-start-webapp my-dev # <- my-dev: the installaton server to point to
Once all started, browse http://localhost:3000
Mono-Repository management with Lerna.js
MoodleNet project takes leverages lerna.js to manage multi-package mono-repository .
Please refer to Lerna documentation to understand how it manages mono-repo and project-packages dependency linking in the development environment.
Questions? Please take a look in the MoodleNet Community and Tracker for answers or to ask for help.