Commit 0d664549 authored by Artem Baranovskyi's avatar Artem Baranovskyi
Browse files

Initial commit. Docker infrastructure with dummy moodle plugin.

parents
MARIADB_ROOT_PASSWORD=rootpassword
MARIADB_DATABASE=moodle
MARIADB_USER=moodleuser
MARIADB_PASSWORD=moodlepassword
MOODLE_DATABASE_ROOT_PASSWORD=rootpassword
MOODLE_DATABASE_HOST=localhost
#MOODLE_DATABASE_HOST=mariadb
MOODLE_DATABASE_NAME=moodle
MOODLE_DATABASE_USER=moodleuser
MOODLE_DATABASE_PASSWORD=moodlepassword
MOODLE_BASE_DIR=/var/www/html/moodle
MOODLE_BASE_DIR_DATA=/var/www/html/moodledata
\ No newline at end of file
FROM debian:trixie
ARG MOODLE_DATABASE_ROOT_PASSWORD
ARG MOODLE_DATABASE_NAME
ARG MOODLE_DATABASE_USER
ARG MOODLE_DATABASE_PASSWORD
ARG MOODLE_DATABASE_HOST
ARG MOODLE_BASE_DIR
ARG MOODLE_BASE_DIR_DATA
ENV MOODLE_DATABASE_ROOT_PASSWORD ${MOODLE_DATABASE_ROOT_PASSWORD}
ENV MOODLE_DATABASE_NAME ${MOODLE_DATABASE_NAME}
ENV MOODLE_DATABASE_USER ${MOODLE_DATABASE_USER}
ENV MOODLE_DATABASE_PASSWORD ${MOODLE_DATABASE_PASSWORD}
ENV MOODLE_DATABASE_HOST ${MOODLE_DATABASE_HOST}
ENV MOODLE_BASE_DIR ${MOODLE_BASE_DIR}
ENV MOODLE_BASE_DIR_DATA ${MOODLE_BASE_DIR_DATA}
# Installing necessary packages
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y apache2 php libapache2-mod-php php-mysqli php-mysql php-xml php-pdo php-pdo-mysql mariadb-client mariadb-server wget unzip python3 python3-pip iputils-ping curl php-mbstring graphviz aspell ghostscript clamav php8.2-pspell php8.2-curl php8.2-gd php8.2-intl php8.2-mysql php8.2-xml php8.2-xmlrpc php8.2-ldap php8.2-zip php8.2-soap php8.2-mbstring && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Setting necessary php params
RUN echo "mysql.default_socket=/run/mysqld/mysqld.sock" >> /etc/php/8.2/cli/php.ini
RUN echo "max_input_vars = 5000" >> /etc/php/8.2/cli/php.ini
# Starting Apache server
RUN systemctl start apache2
# Installing Moodle
RUN mkdir -p ${MOODLE_BASE_DIR} && \
wget -qO- https://packaging.moodle.org/stable403/moodle-4.3.4.tgz | tar xz -C ${MOODLE_BASE_DIR} --strip-components=1 \
# Setting correct acces rules
RUN chown -R www-data:www-data ${MOODLE_BASE_DIR} && \
chmod -R 755 ${MOODLE_BASE_DIR} && \
mkdir -p ${MOODLE_BASE_DIR_DATA} && \
chown -R www-data:www-data ${MOODLE_BASE_DIR_DATA} && \
chmod -R 755 ${MOODLE_BASE_DIR_DATA}
# Copying of beeing developed Plugin
COPY yourplugin ${MOODLE_BASE_DIR}/local/yourplugin
# Setting correct acces rules for Plugin
RUN chown -R www-data:www-data ${MOODLE_BASE_DIR}/local/yourplugin && \
chmod -R 755 ${MOODLE_BASE_DIR}/local/yourplugin
# Making Symlink for MariaDB Socket
RUN ln -s /run/mysqld/mysqld.sock /tmp/mysql.sock
#RUN php ${MOODLE_BASE_DIR}/admin/cli/install_database.php --adminpass=${MOODLE_DATABASE_ROOT_PASSWORD} --agree-license
# Apache Settings
RUN echo "<VirtualHost *:80>\n" \
"ServerName localhost\n" \
"ServerAlias www.moodle.loc\n" \
"DocumentRoot /var/www/html/moodle\n" \
"<Directory /var/www/html/moodle>\n" \
" Options +FollowSymlinks\n" \
" AllowOverride All\n" \
" Require all granted\n" \
"</Directory>\n" \
"ErrorLog \${APACHE_LOG_DIR}/error.log\n" \
"CustomLog \${APACHE_LOG_DIR}/access.log combined\n" \
"</VirtualHost>\n" \
> /etc/apache2/sites-enabled/000-default.conf
# Setting Apache
RUN a2enmod rewrite
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
# Installing Moodle non interactive
#RUN sleep 4 && php ${MOODLE_BASE_DIR}/admin/cli/install.php --wwwroot=http://0.0.0.0 --dataroot=${MOODLE_BASE_DIR_DATA} --dbtype=mariadb --dbname=${MOODLE_DATABASE_NAME} --dbuser=${MOODLE_DATABASE_USER} --dbpass=${MOODLE_DATABASE_PASSWORD} --dbhost=${MOODLE_DATABASE_HOST} --adminpass=${MOODLE_DATABASE_ROOT_PASSWORD} --fullname="Moodle Site" --shortname="Moodle" --agree-license --non-interactive
RUN chmod -R 755 /var/www/html/moodle
RUN chown -R www-data:www-data /var/www/html/moodle
#Opening ports
EXPOSE 80 443
# Команда запуска Apache
CMD ["apachectl", "-D", "FOREGROUND"]
version: '3.8'
services:
mariadb:
image: mariadb:11.3
env_file:
- ./.env
volumes:
- moodledata:${MOODLE_BASE_DIR_DATA}
- mariadb_data:/var/lib/mysql
ports:
- 3306:3306
networks:
- network # Добавление к сети
environment:
- MARIADB_ROOT_PASSWORD=${MARIADB_ROOT_PASSWORD}
- MOODLE_DATABASE_USER=${MOODLE_DATABASE_USER} # Пользователь базы данных
- MOODLE_DATABASE_PASSWORD=${MOODLE_DATABASE_PASSWORD} # Пароль пользователя базы данных
healthcheck:
test: [ "CMD", "mysqladmin", "ping", "-u", "root", "--password=${MARIADB_ROOT_PASSWORD}" ]
interval: 10s
timeout: 5s
retries: 5
moodle:
env_file:
- ./.env
build: # Собираем свой образ Moodle из Dockerfile+.
context: . # Контекст сборки (где находится Dockerfile+.)
dockerfile: Dockerfile
args:
- MOODLE_BASE_DIR=${MOODLE_BASE_DIR}
- MOODLE_BASE_DIR_DATA=${MOODLE_BASE_DIR_DATA}
- MOODLE_DATABASE_TYPE=mariadb
- MOODLE_DATABASE_HOST=${MOODLE_DATABASE_HOST}
- MOODLE_DATABASE_NAME=${MOODLE_DATABASE_NAME} # Имя базы данных
- MOODLE_DATABASE_USER=${MOODLE_DATABASE_USER} # Пользователь базы данных
- MOODLE_DATABASE_PASSWORD=${MOODLE_DATABASE_PASSWORD} # Пароль пользователя базы данных
ports:
- 80:80 # Порт на хосте:порт в контейнере
- 443:443 # Порт на хосте:порт в контейнере
# - 80:8080 # Порт на хосте:порт в контейнере
# - 443:8443 # Порт на хосте:порт в контейнере
depends_on: # Зависимость от сервиса MariaDB
- mariadb
volumes:
- ./yourplugin:${MOODLE_BASE_DIR}/local/yourplugin # Синхронизируем папку плагина с контейнером
- moodle_data:${MOODLE_BASE_DIR} # Том для данных Moodle
- moodledata:${MOODLE_BASE_DIR_DATA} # Том для данных Moodle
networks:
- network # Добавление к сети
healthcheck:
test: /bin/bash -c 'while ! nc -z mariadb 3306; do echo "Ждем подключения к базе данных..."; sleep 5; done'
interval: 10s
timeout: 5s
retries: 5
volumes:
moodledata:
driver: local # Локальный драйвер томов
mariadb_data:
driver: local
moodle_data:
driver: local
networks:
network: # Создание пользовательской сети
driver: bridge
\ No newline at end of file
How to run Moodle Server:
~~~bash
docker-compose exec moodle php /var/www/html/moodle/admin/cli/install.php --wwwroot=http://0.0.0.0 --dataroot=/var/www/html/moodledata --dbtype=mariadb --dbname=moodle --dbuser=moodleuser --dbpass=moodlepassword --dbhost=mariadb --adminpass=rootpassword --fullname="Moodle Site" --shortname="Moodle" --agree-license --non-interactive
docker-compose exec moodle chown -R www-data:www-data /var/www/html/moodle
docker-compose exec moodle chmod -R 755 /var/www/html/moodle
~~~
defined('MOODLE_INTERNAL') || die();
$capabilities = array(
);
\ No newline at end of file
<?php
/**
* You may localized strings in your plugin
*
* @package local_yourplugin
* @copyright 2014 Surya Pratap
* @license http://www.gnu.org/copyleft/gpl.html gnu gpl v3 or later
*/
$string['pluginname'] = 'New local plugin';
\ No newline at end of file
<?php
/**
* You may have settings in your plugin
*
* @package local_yourplugin
* @copyright 2014 Surya Pratap
* @license http://www.gnu.org/copyleft/gpl.html gnu gpl v3 or later
*/
defined('MOODLE_INTERNAL') || die();
if ($ADMIN->fulltree) {
}
\ No newline at end of file
<?php
/**
* Version details.
*
* @package local_yourplugin
* @copyright 2014 Surya Pratap
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2014061101; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2014050800; // Requires this Moodle version.
$plugin->component = 'local_yourplugin';// Full name of the plugin (used for diagnostics).
$plugin->cron = 0;
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment