From 9e84dd9a8218f845e8f8407419762579da3582d9 Mon Sep 17 00:00:00 2001 From: slayer321 Date: Thu, 26 Oct 2023 10:15:07 +0530 Subject: [PATCH 1/6] moodle acornfile --- Acornfile | 37 +++++++++++++++++++++++++++++++++++++ docker-compose.yaml | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 Acornfile create mode 100644 docker-compose.yaml diff --git a/Acornfile b/Acornfile new file mode 100644 index 0000000..1cac116 --- /dev/null +++ b/Acornfile @@ -0,0 +1,37 @@ +services: db: image: "ghcr.io/acorn-io/mariadb:v10.11.5-1" + + +containers: { + web: { + image: "docker.io/bitnami/moodle:4.3" + scale: 2 + ports: publish: "8080:8080/http" + env: { + MOODLE_DATABASE_USER: "@{service.db.secrets.admin.username}" + MOODLE_DATABASE_PASSWORD: "@{service.db.secrets.admin.password}" + MOODLE_DATABASE_HOST: "@{service.db.address}" + MOODLE_DATABASE_PORT_NUMBER: "@{service.db.port.3306}" + MOODLE_DATABASE_NAME: "@{service.db.data.dbName}" + // //ALLOW_EMPTY_PASSWORD: "yes" + // BITNAMI_DEBUG: "true" + // MOODLE_SKIP_BOOTSTRAP: "yes" + } + dirs: { + "/bitnami/moodle": "volume://moodle" + "/bitnami/moodledata": "volume://moodledata" + + } + } +} + +volumes: { + moodle: { + size: 2 + accessModes: ["readWriteMany"] + + } + moodledata:{ + size: 2 + accessModes: ["readWriteMany"] + } +} \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..4d868ab --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,42 @@ +# Copyright VMware, Inc. +# SPDX-License-Identifier: APACHE-2.0 +# username: user +# password: bitnami +version: '2' +services: + mariadb: + image: docker.io/bitnami/mariadb:11.1 + environment: + # ALLOW_EMPTY_PASSWORD is recommended only for development. + - ALLOW_EMPTY_PASSWORD=yes + - MARIADB_USER=bn_moodle + - MARIADB_DATABASE=bitnami_moodle + - MARIADB_CHARACTER_SET=utf8mb4 + - MARIADB_COLLATE=utf8mb4_unicode_ci + volumes: + - 'mariadb_data:/bitnami/mariadb' + moodle: + image: docker.io/bitnami/moodle:4.3 + ports: + - '8080:8080' + #- '443:8443' + environment: + - MOODLE_DATABASE_HOST=mariadb + - MOODLE_DATABASE_PORT_NUMBER=3306 + - MOODLE_DATABASE_USER=bn_moodle + - MOODLE_DATABASE_NAME=bitnami_moodle + # ALLOW_EMPTY_PASSWORD is recommended only for development. + - ALLOW_EMPTY_PASSWORD=yes + - DEBUG=true + volumes: + - 'moodle_data:/bitnami/moodle' + - 'moodledata_data:/bitnami/moodledata' + depends_on: + - mariadb +volumes: + mariadb_data: + driver: local + moodle_data: + driver: local + moodledata_data: + driver: local \ No newline at end of file From dc5daba9dd1ae4f0d9d0c717a2078318ec7331dc Mon Sep 17 00:00:00 2001 From: slayer321 Date: Thu, 26 Oct 2023 17:13:41 +0530 Subject: [PATCH 2/6] prefix image size for volume --- Acornfile | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Acornfile b/Acornfile index 1cac116..95590ff 100644 --- a/Acornfile +++ b/Acornfile @@ -4,7 +4,6 @@ services: db: image: "ghcr.io/acorn-io/mariadb:v10.11.5-1" containers: { web: { image: "docker.io/bitnami/moodle:4.3" - scale: 2 ports: publish: "8080:8080/http" env: { MOODLE_DATABASE_USER: "@{service.db.secrets.admin.username}" @@ -13,7 +12,7 @@ containers: { MOODLE_DATABASE_PORT_NUMBER: "@{service.db.port.3306}" MOODLE_DATABASE_NAME: "@{service.db.data.dbName}" // //ALLOW_EMPTY_PASSWORD: "yes" - // BITNAMI_DEBUG: "true" + //BITNAMI_DEBUG: "true" // MOODLE_SKIP_BOOTSTRAP: "yes" } dirs: { @@ -26,12 +25,9 @@ containers: { volumes: { moodle: { - size: 2 - accessModes: ["readWriteMany"] - + size: "2G" } moodledata:{ - size: 2 - accessModes: ["readWriteMany"] + size: "2G" } } \ No newline at end of file From 67f838ddc3dde19e7bd553f86e9b60cffb675a58 Mon Sep 17 00:00:00 2001 From: slayer321 Date: Thu, 26 Oct 2023 17:14:40 +0530 Subject: [PATCH 3/6] remove docker compose file --- docker-compose.yaml | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 docker-compose.yaml diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index 4d868ab..0000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright VMware, Inc. -# SPDX-License-Identifier: APACHE-2.0 -# username: user -# password: bitnami -version: '2' -services: - mariadb: - image: docker.io/bitnami/mariadb:11.1 - environment: - # ALLOW_EMPTY_PASSWORD is recommended only for development. - - ALLOW_EMPTY_PASSWORD=yes - - MARIADB_USER=bn_moodle - - MARIADB_DATABASE=bitnami_moodle - - MARIADB_CHARACTER_SET=utf8mb4 - - MARIADB_COLLATE=utf8mb4_unicode_ci - volumes: - - 'mariadb_data:/bitnami/mariadb' - moodle: - image: docker.io/bitnami/moodle:4.3 - ports: - - '8080:8080' - #- '443:8443' - environment: - - MOODLE_DATABASE_HOST=mariadb - - MOODLE_DATABASE_PORT_NUMBER=3306 - - MOODLE_DATABASE_USER=bn_moodle - - MOODLE_DATABASE_NAME=bitnami_moodle - # ALLOW_EMPTY_PASSWORD is recommended only for development. - - ALLOW_EMPTY_PASSWORD=yes - - DEBUG=true - volumes: - - 'moodle_data:/bitnami/moodle' - - 'moodledata_data:/bitnami/moodledata' - depends_on: - - mariadb -volumes: - mariadb_data: - driver: local - moodle_data: - driver: local - moodledata_data: - driver: local \ No newline at end of file From 62b33bd224adcfae31677ee9acd36d6ceaad98be Mon Sep 17 00:00:00 2001 From: slayer321 Date: Thu, 26 Oct 2023 17:30:32 +0530 Subject: [PATCH 4/6] moodle workflow --- .github/workflows/publish.yaml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/publish.yaml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..9008ccc --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,29 @@ +name: Publish Acorn image +on: + workflow_dispatch: + push: + tags: + - "v[0-9]*" + +jobs: + publish: + name: Publish + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: acorn-io/actions-setup@v2 + with: + acorn-version: "main" + - name: Login to GHCR + uses: acorn-io/actions-login@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and Publish with signature + run: | + TAG=${GITHUB_REF#refs/*/} + acorn build --platform linux/amd64 --platform linux/arm64 --push -t ghcr.io/infracloudio/moodle-acorn:${TAG} . \ No newline at end of file From 30d4f344827b768f665e23b57762a0a2db5f8d5e Mon Sep 17 00:00:00 2001 From: slayer321 Date: Mon, 30 Oct 2023 13:00:59 +0530 Subject: [PATCH 5/6] add the suggested changes --- Acornfile | 26 +++++++++++++++++++++----- README.md | 9 +++++++++ moodle.svg | 1 + 3 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 README.md create mode 100644 moodle.svg diff --git a/Acornfile b/Acornfile index 95590ff..2d82cc4 100644 --- a/Acornfile +++ b/Acornfile @@ -1,19 +1,35 @@ -services: db: image: "ghcr.io/acorn-io/mariadb:v10.11.5-1" +name: "Moodle Acorn" +description: "Acorn running Moodle" +readme: "./README.md" +icon: "./moodle.svg" +args: { + moodledbname: "moodledb" + moodle_username: "user" + moodle_password: "bitnami" +} + +services: db: { + image: "ghcr.io/acorn-io/mariadb:v10.11.5-1" + serviceArgs: { + dbName: args.moodledbname + } +} containers: { web: { image: "docker.io/bitnami/moodle:4.3" - ports: publish: "8080:8080/http" + ports: { + publish: "80:8080/http" + } env: { MOODLE_DATABASE_USER: "@{service.db.secrets.admin.username}" MOODLE_DATABASE_PASSWORD: "@{service.db.secrets.admin.password}" MOODLE_DATABASE_HOST: "@{service.db.address}" MOODLE_DATABASE_PORT_NUMBER: "@{service.db.port.3306}" MOODLE_DATABASE_NAME: "@{service.db.data.dbName}" - // //ALLOW_EMPTY_PASSWORD: "yes" - //BITNAMI_DEBUG: "true" - // MOODLE_SKIP_BOOTSTRAP: "yes" + MOODLE_USERNAME: args.moodle_username + MOODLE_PASSWORD: args.moodle_password } dirs: { "/bitnami/moodle": "volume://moodle" diff --git a/README.md b/README.md new file mode 100644 index 0000000..db7fa01 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Acorn for Moodle +====== + +Moodle™ LMS is an open source online Learning Management System widely used at universities, schools, and corporations. It is modular and highly adaptable to any type of online learning. + +## Configure the Moodle + +Moodle uses mariadb as the database and it is been used as the [services](https://docs.acorn.io/reference/acornfile#services-consuming) . If you are using Advanace Options on Acorn Platform you can provide the `moodledbname`. By default it will be named as `moodledb`. +By default username and password for moodle is `username: user` `password: bitnami`. You can changes it using `moodle_username` and `moodle_password` field. diff --git a/moodle.svg b/moodle.svg new file mode 100644 index 0000000..35718fb --- /dev/null +++ b/moodle.svg @@ -0,0 +1 @@ + \ No newline at end of file From f1875e1ff8b0e2bcc5e094415185b14160426b7a Mon Sep 17 00:00:00 2001 From: slayer321 Date: Mon, 30 Oct 2023 16:36:51 +0530 Subject: [PATCH 6/6] add user site and config for moodle --- Acornfile | 45 ++++++++++++++++++++++++++++++++++----------- README.md | 13 ++++++++++++- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/Acornfile b/Acornfile index 2d82cc4..5cf076a 100644 --- a/Acornfile +++ b/Acornfile @@ -4,17 +4,36 @@ readme: "./README.md" icon: "./moodle.svg" args: { - moodledbname: "moodledb" + database_type: "mariadb" + mariadbname: "moodledb" + postgresdbname: "postgresdb" moodle_username: "user" moodle_password: "bitnami" + moodle_email: "user@example.com" + moodle_site_name: "New Site" + moodle_lang: "en" } -services: db: { - image: "ghcr.io/acorn-io/mariadb:v10.11.5-1" - serviceArgs: { - dbName: args.moodledbname - } +localData: { + mariadb: { + services: mariadb: { + image: "ghcr.io/acorn-io/mariadb:v#.#.#-#" + serviceArgs: { + dbName: args.mariadbname + } + } + }, + postgres: { + services: postgres:{ + image: "ghcr.io/acorn-io/postgres:v#.#-#" + serviceArgs: { + dbName: args.postgresdbname + } + } + + } } +std.ifelse(args.database_type == "mariadb",localData.mariadb,localData.postgres) containers: { web: { @@ -23,13 +42,17 @@ containers: { publish: "80:8080/http" } env: { - MOODLE_DATABASE_USER: "@{service.db.secrets.admin.username}" - MOODLE_DATABASE_PASSWORD: "@{service.db.secrets.admin.password}" - MOODLE_DATABASE_HOST: "@{service.db.address}" - MOODLE_DATABASE_PORT_NUMBER: "@{service.db.port.3306}" - MOODLE_DATABASE_NAME: "@{service.db.data.dbName}" + MOODLE_DATABASE_TYPE: std.ifelse(args.database_type == "mariadb", "mariadb", "pgsql") + MOODLE_DATABASE_USER: std.ifelse(args.database_type == "mariadb", "@{service.mariadb.secrets.admin.username}","@{service.postgres.secrets.admin.username}" ) + MOODLE_DATABASE_PASSWORD: std.ifelse(args.database_type == "mariadb", "@{service.mariadb.secrets.admin.password}", "@{service.postgres.secrets.admin.password}") + MOODLE_DATABASE_HOST: std.ifelse(args.database_type == "mariadb", "@{service.mariadb.address}", "@{service.postgres.address}") + MOODLE_DATABASE_PORT_NUMBER: std.ifelse(args.database_type == "mariadb", "@{service.mariadb.port.3306}", "@{service.postgres.port.5432}") + MOODLE_DATABASE_NAME: std.ifelse(args.database_type == "mariadb", "@{service.mariadb.data.dbName}", "@{service.postgres.data.dbName}") MOODLE_USERNAME: args.moodle_username MOODLE_PASSWORD: args.moodle_password + MOODLE_EMAIL: args.moodle_email + MOODLE_SITE_NAME: args.moodle_site_name + MOODLE_LANG: args.moodle_lang } dirs: { "/bitnami/moodle": "volume://moodle" diff --git a/README.md b/README.md index db7fa01..57d9143 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,15 @@ Moodle™ LMS is an open source online Learning Management System widely used at ## Configure the Moodle Moodle uses mariadb as the database and it is been used as the [services](https://docs.acorn.io/reference/acornfile#services-consuming) . If you are using Advanace Options on Acorn Platform you can provide the `moodledbname`. By default it will be named as `moodledb`. -By default username and password for moodle is `username: user` `password: bitnami`. You can changes it using `moodle_username` and `moodle_password` field. +There are some field which have default values set by can be easily configured. + +By default username and password for moodle is `username: user` `password: bitnami`. You can changes it using `moodle_username` and `moodle_password` field. Site Name, Email and Lang can also be changed using `moodle_site_name`, `moodle_email` and `moodle_lang` field respectively. + +##### Databases +Currently moodle supports two databases. +1. Mariadb +2. Postgress + +By default it will use `mariadb` as the database. If you want to use postgres. You can use `database_type` field and provide `pgsql` as the value. + +You can read more about it [here](https://github.com/bitnami/containers/tree/main/bitnami/moodle#configuration).