{"id":1455,"date":"2024-05-15T10:26:26","date_gmt":"2024-05-15T08:26:26","guid":{"rendered":"https:\/\/wpethzprd.ethz.ch\/isgdmath\/?p=1455"},"modified":"2024-06-20T14:25:07","modified_gmt":"2024-06-20T12:25:07","slug":"moodle-development-environment","status":"publish","type":"post","link":"https:\/\/blogs.ethz.ch\/isgdmath\/moodle-development-environment\/","title":{"rendered":"Moodle Development Environment"},"content":{"rendered":"<ul>\n<li><a href=\"https:\/\/github.com\/moodlehq\">https:\/\/github.com\/moodlehq<\/a><\/li>\n<li><a href=\"https:\/\/hub.docker.com\/r\/moodlehq\/moodle-php-apache\">https:\/\/hub.docker.com\/r\/moodlehq\/moodle-php-apache<\/a><\/li>\n<\/ul>\n<h2 id=\"develop-moodle\">Develop moodle<\/h2>\n<ul>\n<li><a href=\"https:\/\/github.com\/moodlehq\/moodle-docker\">https:\/\/github.com\/moodlehq\/moodle-docker<\/a><\/li>\n<\/ul>\n<p>The following setup can be used to setup a moodle development environment, with rootless podman:<\/p>\n<pre><code class=\"lang-bash\"><span class=\"hljs-comment\"># D-MATH link podman-compose<\/span>\nln <span class=\"hljs-_\">-s<\/span> \/usr\/bin\/podman-compose ~\/bin\/docker-compose\n\n<span class=\"hljs-comment\"># D-MATH clone moodle-docker repo<\/span>\ngit <span class=\"hljs-built_in\">clone<\/span> https:\/\/github.com\/moodlehq\/moodle-docker.git\n<span class=\"hljs-built_in\">cd<\/span> moodle-docker\n\n<span class=\"hljs-comment\"># D-MATH set variables<\/span>\n<span class=\"hljs-built_in\">export<\/span> MOODLE_DOCKER_DB_PORT=15432\n<span class=\"hljs-built_in\">export<\/span> MOODLE_DOCKER_APP_VERSION=18080\n<span class=\"hljs-built_in\">export<\/span> MOODLE_DOCKER_SELENIUM_VNC_PORT=15900\n<span class=\"hljs-built_in\">export<\/span> MOODLE_DOCKER_WEB_PORT=18000\n\n<span class=\"hljs-comment\"># Change .\/moodle to your \/path\/to\/moodle if you already have it checked out<\/span>\n<span class=\"hljs-built_in\">export<\/span> MOODLE_DOCKER_WWWROOT=.\/moodle\n\n<span class=\"hljs-comment\"># D-MATH add custom configuration<\/span>\ncat &lt;&lt;EOF &gt; local.yml\nservices:\n  webserver:\n    volumes:\n      - <span class=\"hljs-string\">\"<span class=\"hljs-variable\">${MOODLE_DOCKER_WWWROOT}<\/span>\/..\/moodledata:\/var\/www\/moodledata\"<\/span>\n  db:\n    environment:\n      PGDATA: \/var\/lib\/postgresql\/data\/pgdata\n    volumes:\n      - <span class=\"hljs-string\">\"<span class=\"hljs-variable\">${MOODLE_DOCKER_WWWROOT}<\/span>\/..\/database:\/var\/lib\/postgresql\/data\"<\/span>\nEOF\n\n<span class=\"hljs-comment\"># Choose a db server (Currently supported: pgsql, mariadb, mysql, mssql, oracle)<\/span>\n<span class=\"hljs-built_in\">export<\/span> MOODLE_DOCKER_DB=pgsql\n\n<span class=\"hljs-comment\"># D-MATH creating files with group access for moodle code<\/span>\n<span class=\"hljs-built_in\">umask<\/span> 007\n\n<span class=\"hljs-comment\"># Get Moodle code, you could select another version branch (skip this if you already got the code)<\/span>\ngit <span class=\"hljs-built_in\">clone<\/span> -b MOODLE_404_STABLE git:\/\/git.moodle.org\/moodle.git <span class=\"hljs-variable\">$MOODLE_DOCKER_WWWROOT<\/span>\n\n<span class=\"hljs-comment\"># D-MATH add folder for moodle data<\/span>\nmkdir moodledata\nmkdir database\n\n<span class=\"hljs-comment\"># D-MATH setgid for automatic setting group permission<\/span>\nchmod 2770 moodle\nchmod 2770 moodledata\nchmod 2770 database\n\n<span class=\"hljs-comment\"># Ensure customized config.php for the Docker containers is in place<\/span>\ncp config.docker-template.php <span class=\"hljs-variable\">$MOODLE_DOCKER_WWWROOT<\/span>\/config.php\n\n<span class=\"hljs-comment\"># D-MATH set the permission to 33 inside the container for moodle code<\/span>\npodman unshare chown 33 -R moodle\npodman unshare chown 33 -R moodledata\npodman unshare chown 999 -R database\n\n<span class=\"hljs-comment\"># Start up containers, choose docker.io to download the images<\/span>\nbin\/moodle-docker-compose up <span class=\"hljs-_\">-d<\/span>\n\n<span class=\"hljs-comment\"># Shut down and destroy containers<\/span>\n<span class=\"hljs-comment\">#bin\/moodle-docker-compose down<\/span>\n<\/code><\/pre>\n<p>Above we set the webserver port to <code class=\"lang-bash\">18000<\/code> so this means you now need connect to http:\/\/localhost:18000 in your browser to see the application.<\/p>\n<h2 id=\"volume-permissions\">Volume Permissions<\/h2>\n<p>If you have added new files from outside the container, you need to re-apply the correct permissions. Let&#8217;s say you have added files inside the moodle folder, then you need to run the following command:<\/p>\n<pre><code class=\"lang-bash\"># <span class=\"hljs-keyword\">set<\/span> the <span class=\"hljs-comment\">permission to 33<\/span> \npodman <span class=\"hljs-comment\">unshare chown 33 -R moodle<\/span>\n<\/code><\/pre>\n<h2 id=\"visual-studio-code\">Visual Studio Code<\/h2>\n<p>To prevent the above Volume Permission problem, you can connect your locally installed Visual Studio Code to the running container:<\/p>\n<ul>\n<li><a href=\"https:\/\/code.visualstudio.com\/docs\/devcontainers\/attach-container\">https:\/\/code.visualstudio.com\/docs\/devcontainers\/attach-container<\/a><\/li>\n<\/ul>\n<ul>\n<li>Open Visual Studio Code<\/li>\n<li>Hit <code>F1<\/code><\/li>\n<li>Search for <code>Attach to Running Container<\/code><\/li>\n<li>Choose the <code>webserver<\/code> container<\/li>\n<li>Now open the folder <code>\/var\/www\/html<\/code><\/li>\n<\/ul>\n<p>If you need to run some commands in the container:<\/p>\n<ul>\n<li>After being connected to the container<\/li>\n<li>Hit <code>Ctrl+` <\/code><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/github.com\/moodlehq https:\/\/hub.docker.com\/r\/moodlehq\/moodle-php-apache Develop moodle https:\/\/github.com\/moodlehq\/moodle-docker The following setup can be used to setup a moodle development environment, with rootless podman: # D-MATH link podman-compose ln -s \/usr\/bin\/podman-compose ~\/bin\/docker-compose # D-MATH clone moodle-docker repo git clone https:\/\/github.com\/moodlehq\/moodle-docker.git cd moodle-docker # D-MATH set variables export MOODLE_DOCKER_DB_PORT=15432 export MOODLE_DOCKER_APP_VERSION=18080 export MOODLE_DOCKER_SELENIUM_VNC_PORT=15900 export MOODLE_DOCKER_WEB_PORT=18000 # Change .\/moodle to your [&hellip;]<\/p>\n","protected":false},"author":43853,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[542,759],"tags":[198240,198238,198239],"class_list":["post-1455","post","type-post","status-publish","format-standard","hentry","category-general-information","category-linux","tag-development","tag-moodle","tag-podman"],"_links":{"self":[{"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/posts\/1455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/users\/43853"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/comments?post=1455"}],"version-history":[{"count":0,"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/posts\/1455\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/media?parent=1455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/categories?post=1455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.ethz.ch\/isgdmath\/wp-json\/wp\/v2\/tags?post=1455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}