Solved is_feature_enabled bug and implemented Dockerfile for moodle

This commit is contained in:
Kevin Veen-Birkenbach 2025-05-16 10:22:54 +02:00
parent 52ba4dc3a1
commit 8ffb6a9cee
No known key found for this signature in database
GPG Key ID: 44D8F11FD62F878E
5 changed files with 26 additions and 12 deletions

View File

@ -835,7 +835,7 @@
"secret": "{{oidc.client.secret}}",
{%- set redirect_uris = [] %}
{%- for application, domain in domains.items() %}
{%- if applications[application] is defined and (applications | is_feature_enabled('oauth2',application) or applications | is_feature_enabled('oidc',application)) %}
{%- if applications[application] is defined and (applications | is_feature_enabled('oauth2',application) or applications | is_feature_enabled('oidc',application_id)) %}
{%- if domain is string %}
{%- set _ = redirect_uris.append(web_protocol ~ '://' ~ domain ~ '/*') %}
{%- else %}

View File

@ -10,9 +10,15 @@
domain: "{{ domains[application_id] }}"
http_port: "{{ ports.localhost.http[application_id] }}"
- name: "Transfer Dockerfile to {{ docker_compose.directories.instance }}"
copy:
src: Dockerfile.j2
dest: "{{ docker_compose.directories.instance }}Dockerfile"
notify: docker compose project build and setup
- name: "copy docker-compose.yml and env file"
include_tasks: copy-docker-compose-and-env.yml
- name: "Configure OIDC login for Moodle if enabled"
include_tasks: oidc.yml
when: applications | is_feature_enabled('oidc',application)
when: applications | is_feature_enabled('oidc',application_id)

View File

@ -1,13 +1,4 @@
---
- name: "Ensure OIDC plugin is installed inside container"
command: >
docker exec {{ container_name }} bash -c '
set -e;
cd /bitnami/moodle;
if [ ! -d "auth/oidc" ]; then
git clone https://github.com/microsoft/moodle-auth_oidc.git auth/oidc;
fi'
- name: "Upgrade Moodle to apply OIDC plugin"
command: "docker exec {{ container_name }} php admin/cli/upgrade.php --non-interactive"

View File

@ -0,0 +1,14 @@
FROM bitnami/moodle:{{ applications[application_id].version }}
{% if applications | is_feature_enabled('oidc',application_id) %}
# Install git (required to clone the OIDC plugin)
USER root
RUN install_packages git unzip
# Clone the Microsoft OIDC plugin into Moodle's auth directory
RUN git clone https://github.com/microsoft/moodle-auth_oidc.git \
/opt/bitnami/moodle/auth/oidc && \
chown -R www-data:www-data /opt/bitnami/moodle/auth/oidc
USER 1001
{% endif %}

View File

@ -3,7 +3,10 @@ services:
{% include 'roles/docker-central-database/templates/services/' + database_type + '.yml.j2' %}
moodle:
container_name: {{ container_name }}
image: docker.io/bitnami/moodle:{{applications.moodle.version}}
build:
context: .
dockerfile: Dockerfile
image: moodle_custom
ports:
- 127.0.0.1:{{ports.localhost.http[application_id]}}:8080
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}