Guide to Self-built Moodle Docker Testing Environments by Alexander Dominicus

Slide Note
Embed
Share

Dive into the world of self-built Moodle Docker testing environments with insights shared by Alexander Dominicus. Understand the significance of Docker containers in ensuring software portability, encapsulating dependencies, and resolving bugs. Explore the choice between pre-built and self-built setups, and learn how to start creating your own environment using Docker and Compose. Follow detailed steps to create a compose file and establish essential services like databases and web servers. This comprehensive guide offers a structured approach to building a tailored and efficient testing environment for your Moodle projects.


Uploaded on May 15, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.



Presentation Transcript


  1. Self-built Moodle Docker testing environments Alexander Dominicus #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  2. Why Docker containers? Make Software portable and self-contained Encapsulations of applications dependencies configurations Local running identically regardless of the host system isolated instances of an OS Whole class of bugs and errors solved #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  3. Pre-built or self-built? Pre-built easy configuration can be use instantly custom modification maybe difficult Self-built perfectly adapted to your needs perfectly known add, modify and remove services make data persistent you have to learn Docker beforehand Examples moodle-docker (moodlehq) bitnami moodle #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  4. Self-built! How to start? Install Docker and Compose See Moodle system requirements Think about your needs Create a compose file #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  5. Self-built! How to start? Install Docker and Compose See Moodle system requirements Think about your needs Create a compose file +web server! #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  6. Create a compose file #docker-compose.yml version: "2" services: #DB service docker_moodle-db: #PHP service docker_moodle-app: #web server docker_moodle-web: networks: docker_moodle: external: false docker_moodle-db: image: wodby/mariadb:10.4 restart: always container_name: docker_moodle-db environment: - MYSQL_USER=moodleuser - MYSQL_PASSWORD=mysecretpassword - MYSQL_DATABASE=moodle - MYSQL_ALLOW_EMPTY_PASSWORD=true volumes: - ./dbdata:/var/lib/mysql - ./conf/mycustom.cnf:/etc/mysql/conf.d/custom.cnf expose: - "3306" networks: - docker_moodle [....] [....] [....] #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  7. Create a compose file #docker-compose.yml version: "2" services: #DB service docker_moodle-db: #PHP service docker_moodle-app: #web server docker_moodle-web: networks: docker_moodle: external: false docker_moodle-app: build: context: PHP/ dockerfile: PHP.Dockerfile restart: always container_name: docker_moodle-app volumes: - ./moodle:/var/www/html - ./moodledata:/var/www/moodledata - ./conf/local.ini:/usr/local/etc/php/php.ini networks: - docker_moodle depends_on: - docker_moodle-db [....] [....] [....] #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  8. Environment #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  9. Environment #PHP.Dockerfile FROM php:7.4-fpm RUN apt-get update && apt-get\ install -y zip [...] RUN docker-php-ext-install zip [...] #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  10. Create a compose file #docker-compose.yml version: "2" services: #DB service docker_moodle-db: #PHP service docker_moodle-app: #web server docker_moodle-web: networks: docker_moodle: external: false docker_moodle-web: image: nginx restart: always container_name: docker_moodle-web volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro volumes_from: - docker_moodle-app ports: - "8088:8088" networks: - docker_moodle [....] [....] [....] #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  11. #Start Container docker-compose up -d Network docker_moodle Container docker_moodle-db Container docker_moodle-app Container docker_moodle-web Created Startet Startet Startet #Check if http://localhost:8088 is available #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  12. Moodle at http://localhost:8088 #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  13. Next Step: Customisation phpMyAdmin Cron Setup a reverse-proxy (traefik) #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  14. phpMyAdmin 1. Shutdown containers if running 2. Modify docker-compose.yml 3. Start containers docker_moodle-pma: container_name: docker_moodle-pma image: phpmyadmin/phpmyadmin restart: always ports: - "8089:80" environment: PMA_HOST: docker_moodle-db networks: - docker_moodle depends_on: - docker_moodle-db #docker-compose.yml version: "2" services: docker_moodle-app: docker_moodle-web: docker_moodle-db: #phpMyAdmin docker_moodle-pma: networks: docker_moodle: external: false [....] [....] [....] [....] #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  15. phpMyAdmin at http://localhost:8089 #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  16. Cron 1.) shutdown containers 2.) modify docker-compose.yml #cron service docker_moodle-cron: container_name: docker_moodle-cron build: context: . dockerfile: Cron.Dockerfile volumes_from: - docker_moodle-app restart: always volumes: - ./log/cron:/var/log/cron networks: - docker_moodlefault depends_on: - docker_moodle-db #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  17. Cron 1.) shutdown containers 2.) modify docker-compose.yml #Cron.Dockerfile FROM php:7.4-fpm RUN apt-get update && apt-get install y\ cron [...] #cron service docker_moodle-cron: container_name: docker_moodle-cron build: context: . dockerfile: Cron.Dockerfile volumes_from: - docker_moodle-app restart: always volumes: - ./log/cron:/var/log/cron networks: - docker_moodlefault depends_on: - docker_moodle-db # Copy cron file to the cron.d directory COPY crontab /etc/cron.d/cron # Apply cron job RUN crontab /etc/cron.d/cron # Run the command on container startup CMD cron [...] #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  18. #Start Container docker-compose up -d Network docker_moodle Container docker_moodle-db Container docker_moodle-app Container docker_moodle-web Container docker_moodle-pma Container docker_moodle-cron Created Startet Startet Startet Startet Startet #Check if Cron is running docker logs docker_moodle-cron #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  19. #cron logs Execute scheduled task: task1 (path/to/task1) ... started 07:06:04. Current memory use 33.4MB. some information... ... used 1 dbqueries ... used 0.039605140686035 seconds Scheduled task complete: task1 (path/to/task1) Execute scheduled task: task2 (path/to/task2) ... started 07:06:04. Current memory use 33.4MB. ... used 0 dbqueries ... used 0.00094699859619141 seconds Scheduled task complete: task2 (path/to/task2) ... #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  20. Reverse-Proxy Make docker apps accessible via URL Only necessary ports exposed Simplify SSL implementation (if needed) After moodle.example.com: moodle pma.example.com: phpMyAdmin Before port 8088: moodle port 8089: phpMyAdmin #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  21. Reverse-Proxy Make docker apps accessible via URL Only necessary ports exposed Simplify SSL implementation (if needed) Docker moodle moodle.localhost pma.localhost Traefik Docker pma moodle.example.com Docker moodle 2 #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  22. Reverse-Proxy 1.) shutdown containers 2.) setup Traefik 3.) modify docker-compose.yml #Webserver docker_moodle-web: image: nginx restart: always container_name: docker_moodle-web: volumes: - ./nginx.conf:/etc/nginx/nginx.conf:ro volumes_from: - docker_moodle-app # ports: labels: - "traefik.enable=true" # enables the service - "traefik.http.routers.moodle.rule=Host(`moodle.localhost`)" #exposed domain networks: - reverse-proxy-network - docker_moodle #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  23. Moodle available at http://moodle.localhost #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

  24. Thank you for your attention! Any questions? alexander.dominicus@hs-bochum.de https://github.com/Dmfama20/docker_moodle_minimal https://github.com/Dmfama20/docker_moodle_full #mootglobal22 | Alexander Dominicus - Self-built M. Docker testing env.

Related


More Related Content