Skip to content

Commit

Permalink
add user site and config for moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
slayer321 committed Oct 30, 2023
1 parent 30d4f34 commit f1875e1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 12 deletions.
45 changes: 34 additions & 11 deletions Acornfile
Original file line number Diff line number Diff line change
Expand Up @@ -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: "[email protected]"
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: {
Expand All @@ -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"
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

0 comments on commit f1875e1

Please sign in to comment.