diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..db92885 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,73 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team through GitHub. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..a123230 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,43 @@ +# Contributing + +Hello there! Glad you want to contribute to the Docker-Moodle project! This document will help answer common questions you may have during your first contribution. + +## Code of Conduct + +This repository adopts the Contributor Covenant Code of Conduct and should be reviewed before contributing. + +## Submitting Issues + +Not every contribution comes in the form of code. Submitting, confirming, and triaging issues is an important task for any project. + +Issues submitted to this repository are only for the docker image it represents. Issues for the underlying software `moodle` need to be submitted through the [Moodle Tracker.](https://tracker.moodle.org/secure/Dashboard.jspa) + +## Commit Signing Required + +This repository requires commits to be signed. For more informaiton on configuring your local client for this, please reference the following: + +1. [Git - Got-Tools-Signing-Your-Work](https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work) +2. [Github - Signing-Commits](https://help.github.com/articles/signing-commits/) +3. [Yubikey Git Signing](https://developers.yubico.com/PGP/Git_signing.html) + +## Contribution Process + +The following are the general steps for a contribution: + +1. Commit changes to a git branch, making sure to use commit signing. +2. Create a GitHub Pull Request for your change, following the instructions in the pull request template. + +### Pull Request Requirements + +The following requirements exist for pull requests: + +1. Commits are signed. +2. PR follows template. +3. CI build and tests pass. +4. Codacy Quality Review passes. + +### Code Review Process + +Code review takes place in GitHub pull requests. See [this article](https://help.github.com/articles/about-pull-requests/) if you're not familiar with GitHub Pull Requests. + +Once you open a pull request, a code review will take place within the files changed of your PR. An approval, comment, or request for changes will be responded on the PR to further the request. diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..7b68ca7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,24 @@ +**Describe the issue** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Docker Version (please complete the following information):** + - OS: [e.g. Ubuntu or Windows] + - OS Version [e.g. 22] + - Docker Version [e.g. 18.06.1-ce] + - Tag name of image if pulled from Docker Hub. [e.g. v3.1] + +**Additional context** +Add any other context about the problem here. +Production, or testing. +Deploying using an orchestrator? +Deploying behind a load balancer? +etc. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..f175d14 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,15 @@ +### Description + +[Please describe what this change achieves] + +### Issues Resolved + +[List any existing issues this PR resolves, link to appropriate issues or other sources.] + +### Check List + +- [ ] Image buildes successfully. +- [ ] Image runs and service can be opened successfully. +- [ ] All tests pass where applicable. +- [ ] README.md updated where appropriate. +- [ ] All commits have been signed. \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..02cd649 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: +- package-ecosystem: docker + directory: "/" + schedule: + interval: daily + time: "11:00" + open-pull-requests-limit: 10 +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" \ No newline at end of file diff --git a/.github/workflows/docker-buildtest.yml b/.github/workflows/docker-buildtest.yml new file mode 100644 index 0000000..cb826ae --- /dev/null +++ b/.github/workflows/docker-buildtest.yml @@ -0,0 +1,27 @@ +name: Docker PR Build and Test + +on: + pull_request: + branches: [ master ] + +jobs: + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build the Docker image + id: docker_build + uses: docker/build-push-action@v3 + with: + push: false + tags: moodle:latest + + - name: Run Snyk to check for vulnerabilities + uses: snyk/actions/docker@master + continue-on-error: true + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + with: + command: monitor + image: moodle:latest \ No newline at end of file diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml new file mode 100644 index 0000000..bda9f34 --- /dev/null +++ b/.github/workflows/docker-release.yml @@ -0,0 +1,44 @@ +name: Docker Release +on: + release: + types: [published] + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Log in to the Container registry + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@57396166ad8aefe6098280995947635806a0e6ea + with: + images: | + jhardison/moodle + ghcr.io/${{ github.repository }} + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index da431ec..f3762aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,13 @@ # Docker-Moodle # Dockerfile for moodle instance. more dockerish version of https://github.com/sergiogomez/docker-moodle -# Forked from Jon Auer's docker version. https://github.com/jda/docker-moodle -FROM ubuntu:16.04 -MAINTAINER Jonathan Hardison +# Forked from Jade Auer's docker version. https://github.com/jda/docker-moodle +FROM ubuntu:20.04 +LABEL maintainer="Jonathan Hardison " VOLUME ["/var/moodledata"] EXPOSE 80 443 COPY moodle-config.php /var/www/html/config.php -# Keep upstart from complaining -# RUN dpkg-divert --local --rename --add /sbin/initctl -# RUN ln -sf /bin/true /sbin/initctl - # Let the container know that there is no tty ENV DEBIAN_FRONTEND noninteractive @@ -19,14 +15,18 @@ ENV DEBIAN_FRONTEND noninteractive # Set ENV Variables externally Moodle_URL should be overridden. ENV MOODLE_URL http://127.0.0.1 -ADD ./foreground.sh /etc/apache2/foreground.sh +# Enable when using external SSL reverse proxy +# Default: false +ENV SSL_PROXY false + +COPY ./foreground.sh /etc/apache2/foreground.sh -RUN apt-get update && \ +RUN apt-get update && apt-get upgrade -y && \ apt-get -y install mysql-client pwgen python-setuptools curl git unzip apache2 php \ - php-gd libapache2-mod-php postfix wget supervisor php-pgsql curl libcurl3 \ - libcurl3-dev php-curl php-xmlrpc php-intl php-mysql git-core php-xml php-mbstring php-zip php-soap cron php7.0-ldap && \ + php-gd libapache2-mod-php postfix wget supervisor php-pgsql curl libcurl4 \ + libcurl3-dev php-curl php-xmlrpc php-intl php-mysql git-core php-xml php-mbstring php-zip php-soap cron php-ldap && \ cd /tmp && \ - git clone -b MOODLE_33_STABLE git://git.moodle.org/moodle.git --depth=1 && \ + git clone -b MOODLE_400_STABLE git://git.moodle.org/moodle.git --depth=1 && \ mv /tmp/moodle/* /var/www/html/ && \ rm /var/www/html/index.html && \ chown -R www-data:www-data /var/www/html && \ @@ -42,4 +42,4 @@ RUN a2enmod ssl && a2ensite default-ssl #if using proxy dont need actually secu # Cleanup, this is ran to reduce the resulting size of the image. RUN apt-get clean autoclean && apt-get autoremove -y && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/lib/dpkg/* /var/lib/cache/* /var/lib/log/* -CMD ["/etc/apache2/foreground.sh"] +ENTRYPOINT ["/etc/apache2/foreground.sh"] diff --git a/README.md b/README.md index 9dd7c68..ba99b5f 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,23 @@ docker-moodle ============= -[![](https://images.microbadger.com/badges/image/jhardison/moodle.svg)](https://microbadger.com/images/jhardison/moodle "Get your own image badge on microbadger.com") +[![Docker Release](https://github.com/jmhardison/docker-moodle/actions/workflows/docker-release.yml/badge.svg)](https://github.com/jmhardison/docker-moodle/actions/workflows/docker-release.yml) -A Dockerfile that installs and runs the latest Moodle 3.3 stable, with external MySQL Database. +Cross published at [github.](https://github.com/jmhardison/docker-moodle/pkgs/container/docker-moodle) + +A Dockerfile that installs and runs the latest Moodle stable, with external MySQL Database. + +`Note: DB Deployment uses version 5 of MySQL. MySQL:Latest is now v8.` Tags: -* latest - 3.3 stable +* latest - 4.0 stable +* v4.0 - 4.0 stable +* v3.11 - 3.11 stable +* v3.8 - 3.8 stable +* v3.7 - 3.7 stable +* v3.6 - 3.6 stable +* v3.5 - 3.5 stable +* v3.4 - 3.4 stable +* v3.3 - 3.3 stable * v3.2 - 3.2 stable * v3.1 - 3.1 stable @@ -26,7 +38,7 @@ When running locally or for a test deployment, use of localhost is acceptable. To spawn a new instance of Moodle: ``` -docker run -d --name DB -p 3306:3306 -e MYSQL_DATABASE=moodle -e MYSQL_ROOT_PASSWORD=moodle -e MYSQL_USER=moodle -e MYSQL_PASSWORD=moodle mysql +docker run -d --name DB -p 3306:3306 -e MYSQL_DATABASE=moodle -e MYSQL_ROOT_PASSWORD=moodle -e MYSQL_USER=moodle -e MYSQL_PASSWORD=moodle mysql:5 docker run -d -P --name moodle --link DB:DB -e MOODLE_URL=http://localhost:8080 -p 8080:80 jhardison/moodle ``` @@ -41,9 +53,11 @@ http://localhost:8080 For a production deployment of moodle, use of a FQDN is advised. This FQDN should be created in DNS for resolution to your host. For example, if your internal DNS is company.com, you could leverage moodle.company.com and have that record resolve to the host running your moodle container. The moodle url would then be, `MOODLE_URL=http://moodle.company.com` In the following steps, replace MOODLE_URL with your appropriate FQDN. +In some cases when you are using an external SSL reverse proxy, you should enable `SSL_PROXY=true` variable. + * Deploy With Docker ``` -docker run -d --name DB -p 3306:3306 -e MYSQL_DATABASE=moodle -e MYSQL_ROOT_PASSWORD=moodle -e MYSQL_USER=moodle -e MYSQL_PASSWORD=moodle mysql +docker run -d --name DB -p 3306:3306 -e MYSQL_DATABASE=moodle -e MYSQL_ROOT_PASSWORD=moodle -e MYSQL_USER=moodle -e MYSQL_PASSWORD=moodle mysql:5 docker run -d -P --name moodle --link DB:DB -e MOODLE_URL=http://moodle.company.com -p 80:80 jhardison/moodle ``` @@ -69,6 +83,5 @@ The following aren't handled, considered, or need work: ## Credits -This is a fork of [Jon Auer's](https://github.com/jda/docker-moodle) Dockerfile. +This is a fork of [Jade Auer's](https://github.com/jda/docker-moodle) Dockerfile. This is a reductionist take on [sergiogomez](https://github.com/sergiogomez/)'s docker-moodle Dockerfile. - diff --git a/docker-compose.yml b/docker-compose.yml index 7e09134..6b1fb1d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3' services: dbapp: - image: mysql:latest + image: mysql:5 restart: always volumes: - db-volume:/var/lib/mysql @@ -13,7 +13,7 @@ services: deploy: replicas: 1 restart_policy: - condition: any + condition: on-failure moodleapp: image: jhardison/moodle:latest links: @@ -34,7 +34,7 @@ services: deploy: replicas: 1 restart_policy: - condition: any + condition: on-failure volumes: db-volume: diff --git a/moodle-config.php b/moodle-config.php index cfbbe56..9045888 100644 --- a/moodle-config.php +++ b/moodle-config.php @@ -291,7 +291,9 @@ // // Enable when using external SSL appliance for performance reasons. // Please note that site may be accessible via https: or https:, but not both! -// $CFG->sslproxy = true; +if ( getenv('SSL_PROXY') == "true" ) { + $CFG->sslproxy = true; +} // // This setting will cause the userdate() function not to fix %d in // date strings, and just let them show with a zero prefix. @@ -769,4 +771,4 @@ require_once(dirname(__FILE__) . '/lib/setup.php'); // Do not edit // There is no php closing tag in this file, -// it is intentional because it prevents trailing whitespace problems! \ No newline at end of file +// it is intentional because it prevents trailing whitespace problems! diff --git a/moodle_variables.env b/moodle_variables.env index 9a74c79..7d54161 100644 --- a/moodle_variables.env +++ b/moodle_variables.env @@ -32,3 +32,6 @@ DB_PORT_3306_TCP_ADDR=DB MOODLE_URL=http://localhost #MOODLE_URL=http://moodle.company.com + +# Enable when using external SSL reverse proxy +SSL_PROXY=false