setting up moodle continued. now it is able to start up
This commit is contained in:
21
.env.sample
21
.env.sample
@ -6,13 +6,17 @@ DOMAIN=example.com
|
||||
LETS_ENCRYPT_ENV=production
|
||||
COMPOSE_FILE=compose.yml
|
||||
|
||||
ROOT_PATH=/var/www/html
|
||||
# environment (needed for PHP frameworks like laravel/symphony)
|
||||
APP_ENV=prod
|
||||
|
||||
## Optional: Specify alternative PHP version
|
||||
#COMPOSE_FILE=$COMPOSE_FILE:compose.version.yml
|
||||
#PHP_VERSION=7.4-fpm-alpine
|
||||
# moodle settings, set to override defaults
|
||||
#MOODLE_VERSION=stable501/moodle-latest-501
|
||||
#MOODLE_LANGUAGE=en
|
||||
#MOODLE_TIMEZONE=Europe/Berlin
|
||||
#MOODLE_FULLNAME=Moodle site
|
||||
#MOODLE_SHORTNAME=MS
|
||||
#MOODLE_ADMINNAME=admin
|
||||
#MOODLE_ADMINMAIL=mail@example.com
|
||||
#MOODLE_SUMMARY=site description...
|
||||
#MOODLE_SUPPORTMAIL=support@example.com
|
||||
SECRET_ADMIN_PASSWORD_VERSION=v1
|
||||
|
||||
## Extra extensions you need as a space separated list (run `abra app YOURAPPDOMAIN run app "php -m"` to see already active extensions)
|
||||
## Uncomment to install more PHP extensions or Linux packages
|
||||
@ -36,6 +40,3 @@ SECRET_DB_PASSWORD_VERSION=v1
|
||||
#SMTP_AUTH=on
|
||||
#SMTP_TLS=on
|
||||
#SECRET_SMTP_PASSWORD_VERSION=v1
|
||||
|
||||
# Use httpd instead of nginx
|
||||
#COMPOSE_FILE="$COMPOSE_FILE:compose.httpd.yml"
|
||||
|
||||
17
README.md
17
README.md
@ -1,18 +1,18 @@
|
||||
# moodle
|
||||
# Moodle
|
||||
|
||||
Coöp Cloud + [moodle](https://moodle.org/) + [PHP](https://php.org) + MariaDB (optional) + Nginx = 🥳
|
||||
Learning Management System (LMS)
|
||||
|
||||
<!-- metadata -->
|
||||
|
||||
* **Maintainer**: [@stevensting](https://git.coopcloud.tech/stevensting)
|
||||
* **Category**: Learning
|
||||
* **Status**: ..., development
|
||||
* **Status**: 0, development
|
||||
* **Image**: [`php`](https://hub.docker.com/_/php), 4, upstream
|
||||
* **Healthcheck**: ...
|
||||
* **Backups**: ...
|
||||
* **Email**: ...
|
||||
* **Tests**: ...
|
||||
* **SSO**: ...
|
||||
* **Healthcheck**: no
|
||||
* **Backups**: no
|
||||
* **Email**: no
|
||||
* **Tests**: no
|
||||
* **SSO**: no
|
||||
|
||||
<!-- endmetadata -->
|
||||
|
||||
@ -22,5 +22,6 @@ Coöp Cloud + [moodle](https://moodle.org/) + [PHP](https://php.org) + MariaDB (
|
||||
2. `abra app config YOURAPPDOMAIN`
|
||||
- be sure to change `$DOMAIN` to something that resolves to your Docker swarm box
|
||||
3. `abra app deploy YOURAPPDOMAIN`
|
||||
- attention: installing all packages and php extensions necessary can take a couple of minutes. check logs for progress
|
||||
|
||||
|
||||
|
||||
11
abra.sh
11
abra.sh
@ -1,11 +1,10 @@
|
||||
# export PHP_VERSION=7.4
|
||||
export NGINX_DEFAULT_CONF_VERSION=v7
|
||||
export PHP_UPLOADS_CONF_VERSION=v4
|
||||
export ENTRYPOINT_CONF_VERSION=v2
|
||||
export NGINX_DEFAULT_CONF_VERSION=v1
|
||||
export PHP_CONF_VERSION=v1
|
||||
export ENTRYPOINT_CONF_VERSION=v1
|
||||
export ENTRYPOINT_MAILRELAY_CONF_VERSION=v1
|
||||
export ENTRYPOINT_HTTPD_CONF_VERSION=v1
|
||||
export HTTPD_VHOSTS_CONF_VERSION=v1
|
||||
export MSMTP_CONF_VERSION=v3
|
||||
export MSMTP_CONF_VERSION=v1
|
||||
export MOODLE_CONF_VERSION=v1
|
||||
|
||||
abra_backup_app() {
|
||||
_abra_backup_dir "app:/var/www/html/"
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
version: "3.8"
|
||||
services:
|
||||
frontend:
|
||||
image: httpd:2.4.62
|
||||
networks:
|
||||
- proxy
|
||||
depends_on:
|
||||
- app
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.http.services.${STACK_NAME}.loadbalancer.server.port=80"
|
||||
- "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`${EXTRA_DOMAINS})"
|
||||
- "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"
|
||||
- "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}"
|
||||
# Redirect from EXTRA_DOMAINS to DOMAIN
|
||||
- "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect"
|
||||
- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLForceHost=true"
|
||||
- "traefik.http.middlewares.${STACK_NAME}-redirect.headers.SSLHost=${DOMAIN}"
|
||||
- coop-cloud.${STACK_NAME}.frontend.version=1.20-c628b67d
|
||||
volumes:
|
||||
- site_content:/var/www/html/
|
||||
entrypoint: "/docker-entrypoint.sh"
|
||||
|
||||
configs:
|
||||
- source: entrypoint_httpd_conf
|
||||
target: /docker-entrypoint.sh
|
||||
mode: 0555
|
||||
- source: httpd_vhosts_conf
|
||||
target: /usr/local/apache2/conf/extra/httpd-vhosts.conf
|
||||
|
||||
|
||||
configs:
|
||||
entrypoint_httpd_conf:
|
||||
name: ${STACK_NAME}_entrypoint_httpd_conf_${ENTRYPOINT_HTTPD_CONF_VERSION}
|
||||
file: entrypoint.httpd.sh
|
||||
httpd_vhosts_conf:
|
||||
name: ${STACK_NAME}_httpd_vhosts_conf_${HTTPD_VHOSTS_CONF_VERSION}
|
||||
file: httpd-vhosts.conf
|
||||
template_driver: golang
|
||||
@ -1,6 +0,0 @@
|
||||
---
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
app:
|
||||
image: php:${PHP_VERSION}
|
||||
38
compose.yml
38
compose.yml
@ -1,32 +1,46 @@
|
||||
version: "3.8"
|
||||
services:
|
||||
app:
|
||||
image: php:8.4.3-fpm-alpine3.20
|
||||
image: php:8.4-fpm-alpine3.22
|
||||
volumes:
|
||||
- "site_content:/var/www/html/"
|
||||
- site_content:/var/www/html/
|
||||
- moodledata:/var/www/moodledata
|
||||
networks:
|
||||
- backend
|
||||
- proxy
|
||||
environment:
|
||||
- PHP_EXTENSIONS
|
||||
- APP_ENV
|
||||
- MOODLE_LANGUAGE=${MOODLE_LANGUAGE:-en}
|
||||
- MOODLE_TIMEZONE=${MOODLE_TIMEZONE:-Europe/Berlin}
|
||||
- MOODLE_VERSION=${MOODLE_VERSION:-stable501/moodle-latest-501}
|
||||
- MOODLE_FULLNAME
|
||||
- MOODLE_SHORTNAME
|
||||
- MOODLE_ADMINNAME=${MOODLE_ADMINNAME:-admin}
|
||||
- MOODLE_ADMIN_PASSWORD_FILE=/run/secrets/admin_password
|
||||
- MOODLE_ADMINMAIL
|
||||
- MOODLE_SUMMARY
|
||||
- MOODLE_SUPPORTMAIL
|
||||
configs:
|
||||
- source: php_uploads_conf
|
||||
target: /usr/local/etc/php/conf.d/uploads.ini
|
||||
- source: php_conf
|
||||
target: /usr/local/etc/php/conf.d/php.ini
|
||||
- source: entrypoint_conf
|
||||
target: /docker-entrypoint.sh
|
||||
mode: 0555
|
||||
- source: moodle_conf
|
||||
target: /var/www/html/config.php
|
||||
entrypoint: /docker-entrypoint.sh
|
||||
deploy:
|
||||
update_config:
|
||||
failure_action: rollback
|
||||
order: start-first
|
||||
labels:
|
||||
- coop-cloud.${STACK_NAME}.app.version=2.0.0+8.4.3-fpm-alpine3.20
|
||||
- coop-cloud.${STACK_NAME}.app.version=0.0.1
|
||||
frontend:
|
||||
image: nginx:1.20-alpine
|
||||
networks:
|
||||
- proxy
|
||||
- backend
|
||||
depends_on:
|
||||
- app
|
||||
deploy:
|
||||
@ -50,7 +64,7 @@ services:
|
||||
target: /etc/nginx/conf.d/default.conf
|
||||
environment:
|
||||
- STACK_NAME
|
||||
- ROOT_PATH
|
||||
- ROOT_PATH=/var/www/html/public
|
||||
- DOMAIN
|
||||
# healthcheck:
|
||||
# test: ["CMD", "curl", "-f", "http://localhost"]
|
||||
@ -60,11 +74,11 @@ services:
|
||||
# start_period: 1m
|
||||
networks:
|
||||
backend:
|
||||
# internal: true
|
||||
proxy:
|
||||
external: true
|
||||
volumes:
|
||||
site_content:
|
||||
moodledata:
|
||||
configs:
|
||||
entrypoint_conf:
|
||||
name: ${STACK_NAME}_entrypoint_conf_${ENTRYPOINT_CONF_VERSION}
|
||||
@ -74,6 +88,10 @@ configs:
|
||||
name: ${STACK_NAME}_nginx_default_conf_${NGINX_DEFAULT_CONF_VERSION}
|
||||
file: nginx.conf
|
||||
template_driver: golang
|
||||
php_uploads_conf:
|
||||
name: ${STACK_NAME}_php_uploads_conf_${PHP_UPLOADS_CONF_VERSION}
|
||||
file: uploads.ini
|
||||
php_conf:
|
||||
name: ${STACK_NAME}_php_conf_${PHP_CONF_VERSION}
|
||||
file: php.ini
|
||||
moodle_conf:
|
||||
name: ${STACK_NAME}_moodle_conf_${MOODLE_CONF_VERSION}
|
||||
file: config-dist.php.tmpl
|
||||
template_driver: golang
|
||||
|
||||
1347
config-dist.php.tmpl
Normal file
1347
config-dist.php.tmpl
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
sed -i 's,#Include conf/extra/httpd-vhosts.conf,Include conf/extra/httpd-vhosts.conf,g' /usr/local/apache2/conf/httpd.conf
|
||||
|
||||
sed -i '/LoadModule rewrite_module/s/^#//g' /usr/local/apache2/conf/httpd.conf && \
|
||||
sed -i 's#AllowOverride [Nn]one#AllowOverride All#' /usr/local/apache2/conf/httpd.conf && \
|
||||
sed -i '/LoadModule proxy_module/s/^#//g' /usr/local/apache2/conf/httpd.conf
|
||||
sed -i '/LoadModule proxy_fcgi_module/s/^#//g' /usr/local/apache2/conf/httpd.conf
|
||||
|
||||
httpd-foreground
|
||||
@ -1,13 +1,47 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo Installing necessary packages...
|
||||
apk update
|
||||
apk add libzip-dev zip libpng-dev libxml2-dev icu-dev alpine-conf sudo
|
||||
{{ if (env "INSTALL_PACKAGES") }}
|
||||
apk add libzip-dev {{ env "INSTALL_PACKAGES" }}
|
||||
apk add {{ env "INSTALL_PACKAGES" }}
|
||||
{{ end }}
|
||||
# opcache is only available in the alpine community repo
|
||||
setup-apkrepos -c1
|
||||
apk add php84-opcache
|
||||
|
||||
echo Installing PHP extensions...
|
||||
docker-php-ext-install zip
|
||||
docker-php-ext-install pdo_mysql
|
||||
docker-php-ext-install mysqli
|
||||
docker-php-ext-install gd
|
||||
docker-php-ext-install intl
|
||||
docker-php-ext-install soap
|
||||
docker-php-ext-install exif
|
||||
docker-php-ext-install unicode
|
||||
{{ if (env "PHP_EXTENSIONS") }}
|
||||
docker-php-ext-install {{ env "PHP_EXTENSIONS" }}
|
||||
{{ end }}
|
||||
|
||||
{{ if (env "PHP_EXTENSIONS") }}
|
||||
echo Installing PHP extensions: pdo_mysql zip {{ env "PHP_EXTENSIONS" }}
|
||||
docker-php-ext-install pdo_mysql zip {{ env "PHP_EXTENSIONS" }}
|
||||
{{ end }}
|
||||
# todo: check if already installed
|
||||
echo "Installing..."
|
||||
cd /var/www
|
||||
curl "https://download.moodle.org/download.php/direct/{{ env "MOODLE_VERSION" }}.tgz" -L -o moodle.tgz
|
||||
tar xzf moodle.tgz --strip-components=1 -C /var/www/html
|
||||
chown -R root /var/www/html
|
||||
chmod -R 0755 /var/www/html
|
||||
mkdir moodledata
|
||||
chmod 0777 /var/www/moodledata
|
||||
|
||||
# run database installer with www user
|
||||
chown www-data /var/www/html/
|
||||
cd /var/www/html/admin/cli
|
||||
sudo -E -u www-data php install_database.php --agree-license --fullname="{{ env "MOODLE_FULLNAME" }}" \
|
||||
--shortname="{{ env "MOODLE_SHORTNAME" }}" --adminuser="{{ env "MOODLE_ADMINNAME" }}" --adminpass=$(cat /run/secrets/admin_password) --adminemail="{{ env "MOODLE_ADMINMAIL" }}" --summary="{{ env "MOODLE_SUMMARY" }}" --supportemail="{{ env "MOODLE_SUPPORTMAIL" }}"
|
||||
chown -R root /var/www/html/
|
||||
|
||||
echo "Installation finished..."
|
||||
#fi
|
||||
|
||||
exec "$@"
|
||||
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
<VirtualHost *:80>
|
||||
DocumentRoot /var/www/html/
|
||||
ServerName {{ env "DOMAIN" }}
|
||||
ErrorLog logs/{{ env "DOMAIN" }}-error_log
|
||||
CustomLog logs/{{ env "DOMAIN" }}-access_log common
|
||||
|
||||
<Directory /var/www/html/>
|
||||
AllowOverride All
|
||||
DirectoryIndex index.php index.php
|
||||
Options -Indexes
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
<FilesMatch \.php$>
|
||||
SetHandler "proxy:fcgi://{{ env "STACK_NAME" }}_app:9000"
|
||||
</FilesMatch>
|
||||
</VirtualHost>
|
||||
51
nginx.conf
51
nginx.conf
@ -12,7 +12,7 @@ server {
|
||||
location / {
|
||||
index index.html index.htm index.php;
|
||||
gzip_static on;
|
||||
try_files $uri $uri/ $uri.html $uri.php index.php?$query_string /index.php?$query_string;
|
||||
try_files $uri $uri/ /r.php$is_args$args;
|
||||
}
|
||||
|
||||
#error_page 404 /404.html;
|
||||
@ -32,18 +32,45 @@ server {
|
||||
|
||||
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
|
||||
#
|
||||
location ~ \.php$ {
|
||||
# try_files $uri /index.php =404;
|
||||
fastcgi_pass {{ env "STACK_NAME" }}_app:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_param REQUEST_URI $request_uri;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_read_timeout 600;
|
||||
fastcgi_buffers 16 16k;
|
||||
fastcgi_buffer_size 32k;
|
||||
location ~ \.php(/|$) {
|
||||
# Split the path info based on URI.
|
||||
fastcgi_split_path_info ^(.+\.php)(/.*)$;
|
||||
|
||||
# Note: Store the original path_info. It will be wiped out in a moment by try_files.
|
||||
set $path_info $fastcgi_path_info;
|
||||
|
||||
# Look for the php file, trying a trailing slash for directories if required.
|
||||
# Finally, send the request to the router - r.php - as a fallback.
|
||||
try_files $fastcgi_script_name $fastcgi_script_name/ /r.php$is_args$args;
|
||||
|
||||
# File was found - pass to fastcgi.
|
||||
fastcgi_pass {{ env "STACK_NAME" }}_app:9000;
|
||||
# Alternately, pass to unix socket (depends on pool listen configuration)
|
||||
# fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
|
||||
|
||||
include fastcgi_params;
|
||||
|
||||
# Re-apply the path_info after including fastcgi_params.
|
||||
fastcgi_param PATH_INFO $path_info;
|
||||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
||||
fastcgi_param DOCUMENT_ROOT $realpath_root;
|
||||
}
|
||||
|
||||
location /dataroot/ {
|
||||
internal;
|
||||
alias /var/www/moodledata/; # ensure the path ends with /
|
||||
}
|
||||
|
||||
# Hide all dot files but allow "Well-Known URIs" as per RFC 5785
|
||||
location ~ /\.(?!well-known).* {
|
||||
return 404;
|
||||
}
|
||||
|
||||
# This should be after the php fpm rule and very close to the last nginx ruleset.
|
||||
# Don't allow direct access to various internal files. See MDL-69333
|
||||
location ~ (/vendor/|/node_modules/|composer\.json|/readme|/README|readme\.txt|/upgrade\.txt|/UPGRADING\.md|db/install\.xml|/fixtures/|/behat/|phpunit\.xml|\.lock|environment\.xml) {
|
||||
deny all;
|
||||
return 404;
|
||||
}
|
||||
|
||||
# deny access to .htaccess files, if Apache's document root
|
||||
|
||||
17
php.ini
Normal file
17
php.ini
Normal file
@ -0,0 +1,17 @@
|
||||
; This is a subset of the php.ini-production template file: https://github.com/php/php-src/blob/master/php.ini-production
|
||||
; Extend as needed
|
||||
|
||||
; upload settings
|
||||
file_uploads = On
|
||||
upload_max_filesize = 256M
|
||||
post_max_size = 256M
|
||||
log_errors = On
|
||||
error_log = /dev/stderr
|
||||
|
||||
; opcache, configured according to https://docs.moodle.org/501/en/OPcache
|
||||
opcache.enable = 1
|
||||
opcache.revalidate_freq = 60
|
||||
opcache.enable_cli = 1
|
||||
|
||||
zend.exception_ignore_args = On
|
||||
max_input_vars = 5000
|
||||
@ -1,5 +0,0 @@
|
||||
file_uploads = On
|
||||
upload_max_filesize = 256M
|
||||
post_max_size = 256M
|
||||
log_errors = On
|
||||
error_log = /dev/stderr
|
||||
Reference in New Issue
Block a user