-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added dockerfiles to create container for moodle. #130
base: master
Are you sure you want to change the base?
Added dockerfiles to create container for moodle. #130
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mohammedzee1000,
great that you're working w/ introducing Moodle here, openshift-wise: is there any particular target e.g. for personal use?
Some refs among the ones you probably got in touch with:
- https://github.com/rajeshtaneja/docker/, for running Behat tests (BDD)
- https://moodle.org/mod/forum/discuss.php?d=349797 for an interesting starting point about thinking at a composition to run Moodle on
- https://moodle.org/mod/forum/discuss.php?d=278759, some other examples
HTH,
Matteo
moodle/centos7/install.sh
Outdated
HTTPD_WELCOME="/etc/httpd/conf.d/welcome.conf" | ||
INSTALL_PKGS2="httpd nss_wrapper gettext"; | ||
PHP_REQUIRED="php php-mysql php-pgsql php-xml php-xmlrpc php-gd" | ||
PHP_GOOD_TO_HAVE="php-xcache php-intl php-soap php-xmlrpc php-mbstring" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for xcache: we should play with opcache only since Moodle supports it e.g. in terms of some invalidations during updates (not available for other opcode cachers).
moodle/centos7/run.sh
Outdated
MOODLE_HOST="`hostname -i`"; | ||
fi | ||
|
||
if [ $1 == "moodle" ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moodle could play w/ other services too, starting from an "external" DB then with an unoconv listener and could benefit from memcached, redis and other services including mail services.
What should be the goal of this docker file? Something to be used within a compose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say get it functional with openshift as well as compose and i have succeeded in this to a good extent.
I used following template for this
apiVersion: v1
items:
- apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
service: moodle
name: moodle
spec:
ports:
- name: "8080"
port: 8080
targetPort: 8080
- name: "8443"
port: 8443
targetPort: 8443
selector:
service: moodle
status:
loadBalancer: {}
- apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
service: postgres
name: postgres
spec:
clusterIP: None
ports:
- name: headless
port: 55555
targetPort: 0
selector:
service: postgres
status:
loadBalancer: {}
- apiVersion: v1
kind: DeploymentConfig
metadata:
creationTimestamp: null
labels:
service: moodle
name: moodle
spec:
replicas: 1
selector:
service: moodle
strategy:
resources: {}
template:
metadata:
creationTimestamp: null
labels:
service: moodle
spec:
containers:
- env:
- name: DB_HOST
value: postgres
- name: DB_TYPE
value: pgsql
- MOODLE_HOST
value: "URL_FROM_ROUTE"
- MOODLE_HOST_NOPORT
value: "True"
image: ' '
name: moodle
ports:
- containerPort: 8080
- containerPort: 8443
resources: {}
restartPolicy: Always
test: false
triggers:
- type: ConfigChange
- imageChangeParams:
automatic: true
containerNames:
- moodle
from:
kind: ImageStreamTag
name: moodle:latest
type: ImageChange
status: {}
- apiVersion: v1
kind: ImageStream
metadata:
creationTimestamp: null
name: moodle
spec:
tags:
- annotations: null
from:
kind: DockerImage
name: mohammedzee1000/testc
generation: null
importPolicy: {}
name: latest
status:
dockerImageRepository: ""
- apiVersion: v1
kind: DeploymentConfig
metadata:
creationTimestamp: null
labels:
service: postgres
name: postgres
spec:
replicas: 1
selector:
service: postgres
strategy:
resources: {}
template:
metadata:
creationTimestamp: null
labels:
service: postgres
spec:
containers:
- env:
- name: POSTGRESQL_DATABASE
value: moodle
- name: POSTGRESQL_PASSWORD
value: moodle
- name: POSTGRESQL_USER
value: moodle
image: ' '
name: postgres
resources: {}
restartPolicy: Always
test: false
triggers:
- type: ConfigChange
- imageChangeParams:
automatic: true
containerNames:
- postgres
from:
kind: ImageStreamTag
name: postgres:9.6
type: ImageChange
status: {}
- apiVersion: v1
kind: ImageStream
metadata:
creationTimestamp: null
name: postgres
spec:
tags:
- annotations: null
from:
kind: DockerImage
name: registry.centos.org/postgresql/postgresql:9.6
generation: null
importPolicy: {}
name: "9.6"
status:
dockerImageRepository: ""
kind: List
metadata: {}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TNX for your comments and your example, appreciated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: mohammedzee1000/testc is a namespace where i house any container i am testing. Currently thats moodle. Once i am done here, and this container is added. The container will get proper name which will be published on https://wiki.centos.org/ContainerPipeline
moodle/centos7/install.sh
Outdated
# Install moodle | ||
pushd /var/www; | ||
wget ${MOODLE_DOWNLOAD_URL} && tar zxvf ${MOODLE_TAR} && mv /var/www/${MOODLE}/* /var/www/html; | ||
mkdir -p /var/moodledata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moodledata must be persistent (VOLUME
): it contains caching files and the deduplicated (at file level) storage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks i will see if i can make it a VOLUME but generally i have noticed this plays havoc with permission fixes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok i tried making it a volume as in VOLUME /var/moodledata in dockerfile i got
"Fatal error: $CFG->dataroot is not writable, admin has to fix directory permissions! Exiting."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mohammedzee1000,
the user, under which the Moodle instance runs on, should have rwx
rights there since it must write on it folders and files during the installation and the life cycle of the instance.
Could we run kind of fix-permissions.sh
(e.g. chown -R
on run.sh
) or should we add a requirement when using an "external" volume to fix the permission (not sure how to automate it in case of a dynamic uid
as in openshift
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea that is always a problem. I had this issue with other containers as well. As soon as i added VOLUME /somepath, anywhere in dockerfile. Then any fix-permissions that i ran on /somepath broke on openshift. But as soon as i removed that the fix-permissions took affect properly and it worked fine on openshift.
I will attempt what you said with run.sh however, lets see if it works.
As far as why moodle, its one of things we plan to bring onto Container Pipeline Service (https://wiki.centos.org/ContainerPipeline) |
Hi @mohammedzee1000, Please note that for security reasons you should download the latest weekly when packaging the image and not just the initial release: this is due to the way Moodle is used to release upgrades (and security updates!) within a supported release (like 3.1, which is LTS: https://docs.moodle.org/dev/Releases#Version_support). HTH, |
moodle/centos7/install.sh
Outdated
@@ -8,22 +8,28 @@ HTTPD_WELCOME="/etc/httpd/conf.d/welcome.conf" | |||
|
|||
INSTALL_PKGS1="wget"; | |||
INSTALL_PKGS2="httpd nss_wrapper gettext"; | |||
REMI_REPO="http://rpms.famillecollet.com/enterprise/remi-release-7.rpm" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use proper URL, which is https://rpms.remirepo.net/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok thanks
moodle/centos7/install.sh
Outdated
PHP4="${PHP_REMI_VERSION}-php-pecl-apcu-bc ${PHP_REMI_VERSION}-php-pecl-redis ${PHP_REMI_VERSION}-php-phpiredis" | ||
PHP5="${PHP_REMI_VERSION}-php-opcache ${PHP_REMI_VERSION}-php-pecl-memcache ${PHP_REMI_VERSION}-php-pecl-memcached" | ||
PHP6="${PHP_REMI_VERSION}-php-intl ${PHP_REMI_VERSION}-php-mbstring ${PHP_REMI_VERSION}-php-pecl-solr2" | ||
PHP7="${PHP_REMI_VERSION}-php-pecl-zip ${PHP_REMI_VERSION}-php-soap" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice than using php71-php from "remi-safe" repository (SCL package) is very different from using php from "remi-php71" repository (base package).
BTW, if SCL packages are installed in a different path (/opt) they are smaller, so perhaps more suitable for Docker image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, could not catch that. Am i doing something wrong?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing wrong, just a different set of packages. Both work, only files locations differ.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HI @mohammedzee1000,
that's probably means: PHP as module via SCL requires an adjustment in the Apache conf files.
HTH,
Matteo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@scara cool. I was able to get the container running based on current changes in source through docker compose
@remicollet thanks
@remicollet do you have a package for sqlsrv |
@remicollet thanks well then i can avoid most of those steps then, most. |
Using php-sqlsrv, you don't need freetds ;) |
@remicollet ok so one more package and mssql is solved does the same apply to oci just install php-oci8 and im good from that side? |
For this one, you also need the Oracle client library (which can't be in my repository because of License issues, not even redistributable), and some tuning to ensure the lib are found in the library path (and because their RPM sucks), such as
|
So i guess il skip oracle for now and add a warning for the same. Is that ok with you @scara? |
35ce799
to
1356b17
Compare
Hi @mohammedzee1000, Thanks to @remicollet for stepping into too, appreciated 😉. |
@scara @remicollet Thanks for all the help. I have pushed in couple of last fixed here for MOODLE_URL as its passed to @kbsingh @jimperrin i think we should be good here. |
@kbsingh i have updated the information for tracking updates. |
Hi @mohammedzee1000, TIA, |
@scara no, i cant seem to be able to find the coment either. Do you remember what they were? Or if you could point it out, i will fix it. |
A couple of typos around https://github.com/CentOS/CentOS-Dockerfiles/pull/130/files#diff-2f7a31c9e648aff543a099083dff59e4R32:
HTH, |
@scara thanks, il fix them right away :) |
Updated |
CentOS/container-index#146 |
Container now available on registry.centos.org as registry.centos.org/centos/moodle:3.1 |
@scara thanks i will take a look at this possibility EDIT: |
@scara updated |
OK HTH, |
Which should be fine. A lot people already are using some sort of log aggregation with containers. Infact it's not recommended to have file based logs in containers. |
@scara Thanks i will look into it. I am planning to try to get sclo rpms in there. But the image is already building and available on r.c.o. |
Will continue to add as i keep figuring things out.
Need to figure out how to factor this in.
This is due to licensing issues with oracle client.
Fixed the spacing.
The MOODLE_URL is passed to a sed in run and hence a user must be aware that he must escape appropriate characters such as http:// which should actually be http:\/\/.
8073221
to
18e2972
Compare
No description provided.