I am working with a model on the docker
I want to create a dockerfile in which I write the list of plugins that I use in the system.
So that when running the Docker image, the plugins I wrote for my model system will be loaded directly for me.
Hi Roni, There are several approaches you could take here, using git, moosh, composer, or other methods. What do you have so far?
Git offers several different methods of doing what you suggest. You could commit all of your plugin code to same repository as your core Moodle code, or you could define each plugin as a git submodule.
Then you can either clone the repository (and initialise the submodules if you're using them) on your build machine and use COPY in your dockerfile to copy the files into the container, or you could use RUN in your dockerfile to do the git commands within the build.
You could also keep the plugin repositories completely separate, and use RUN in your dockerfile to execute a series of git commands, cloning each plugin into the appropriate place. This would mean more code to maintain in the dockerfile than the options above, but less complex git setup.
Thank you very much for the answer
I want to download the plugins directly from their website without the need to download in advance and save in a certain place
That is, adding a line in the dockerfile to download the plugin from the plugins site
And in addition a row that installs the actual plugins on the moodle website
I would love to receive an example of a dockerfile that matches the requirement
(After all, on the plugins website there is an option to download manually, there must be an option to download from there also through a line of code).
That is possible, but you'd end up with quite a verbose dockerfile. I haven't seen or written any examples that do this, but you'd need something like:
RUN wget https://plugin/download/url/plugin.zip && \
unzip -d /path/to/plugindir plugin.zip && \
rm plugin.zip
For each plugin that you want to include. Actually installing the plugin to the moodle site isn't something that would happen in your dockerfile, that will happen when you run the install/upgrade from a running container.
You may be misunderstanding how docker volumes work. Volumes are a persistent directories on the host that are mounted into a container at runtime. You cannot write into a volume from your dockerfile, at build time. I don't know exactly what will happen if your dockerfile does write to a location where you then mount a volume (if this is even possible), but my guess is that the container will see the contents of the volume, and not the files written at build time.
In the example I shared above in your dockerfile, docker will download plugin.zip to /
, then unzip its contents into /path/to/plugindir
, which should be the path to that plugin type's directory within your moodle codebase. You will already need to have copied your moodle codebase to this location, earlier in the dockerfile. This will load all of the PHP into the container's filesystem, meaning it will exist as soon as the container starts up without having to mount a volume from the host, and any changes to those files will be lost when the container shuts down. If you need to update the files, you will need to rebuild the container and redeploy it.
An alternative approach using volumes would be to manage all your moodle codebase in a directory on the host, then mount that directory onto your container at runtime. This will mean any changes made to the code are reflected "live".
The former approach is more appropriate for production deployment, while the latter is better suited to a development environment.
Maybe I don't understand how volumes work in Docker.
But still this is my demand and I have to carry it out
by the commands:
RUN wget https://moodle.org/plugins/download.php/30209/report_growth_moodle43_2023101400.zip -P /bitnami/moodledata && \
cd /bitnami/moodledata && \
unzip report_growth_moodle43_2023101400.zip
I managed to download the plug-in from the internet.
My problem is that when it goes down to volume - moodledata
Everything works fine!!
But when I download the plug-in to its appropriate place in the moodle volume
He can't get off
I have no idea what the difference is between the volumes
Why does it manage to go down for one volume and not for the other????
I'm not really clear on what you mean here. Maybe if you can share your dockerfile (don't post it here, perhaps link to it on GitHub Gist/Pastebin or similar) so we can have a more complete picture of what you're doing, it will be easier make suggestions.
When you say "But for some reason I can't download the plug-in into the volume of moodle", what actually happens? Does the build fail? Is there any output from the wget command?
Also, can you share the portion of your docker-compose file that runs the moodle container?
Can you just confirm what command you ran that produced those "mariadb" output lines?
From the look of that you are mounting the host directory moodle_data as a volume on /bitnami/moodle. You should either be managing the code directly in there from the host and not try putting stuff there from the dockerfile, or you should not be mounting a volume there and only put code in /bitnami/moodle from the dockerfile. Trying to do both is probably the source of confusion here.
The best I can suggest is that you check the permissions of the download directory a) in the container and b) on the host. Also, as a test try removing the volumes from the docker compose file and see if you get the same results.
Some things to check:
moodle_data
and moodledata_data
directories. Use your file manager, or ln -la
in the terminaldocker exec -it container_name /bin/bash
to get a shell inside the container):
ln -la
againtouch /bitnami/moodle/test.txt
and touch /bitnami/moodledata/test.txt
) and see if you get any errors.I don't think there's much more help I can offer here, sorry.
Moodle HQ publishes its own container based on this dockerfile: https://github.com/moodlehq/moodle-php-apache/blob/master/Dockerfile. It is used by https://github.com/moodlehq/moodle-docker to create a development environment with docker-compose. These should be useful references for how to create a basic Moodle docker container.
The docker project has very good and extensive documentation about writing Dockerfiles https://docs.docker.com/engine/reference/builder/.
I ran into a very similar problem!
I will be happy to answer!
I read the post to the end and I want to clarify a few things:
Rony, you cannot execute the COPY or RUN commands in the same Dockerfile that executes FROM moodle because you are trying to copy/download the files to the bitnami/moodle routing that does not yet exist during the build. (created while running the container)
Hope I helped you, go ahead and succeed!
Now to my question:
like you said:
So when you run the Docker image, the plugins I wrote for my model system will be loaded directly for me.
I want to close a snapshot that contains my own plugins and installations.
My problem is, as I explained to you, that everything is done at the ENTRYPOINT - while the container is running, and now I don't have the option to add the plugins already when building the image.
I have been sitting on this for a long time!
Can someone help me??