Features & Development

Development in Docker - forked repo

Development in Docker - forked repo

by Sergio Chaves -
Number of replies: 6

Hello all,

I am trying to play around in WebWork making changes on my forked GitHub repository. I have followed the instructions in https://github.com/openwebwork/webwork2/wiki/Docker-newbie-instructions and I have WebWork working locally in my computer. However, I am still not able to figure out how to add my github repository and how to test the changes made into my local version of WebWork.

I have tried the steps in  https://github.com/openwebwork/webwork2/wiki/First-Time-Setup inside the remote directory /opt/webwork/webwork2 but the git commands seem not to work. Am I missing something out? or the git request must be done within the webwork_docker directory.

I am using Ubuntu 20.04. Thanks in advance!

In reply to Sergio Chaves

Re: Development in Docker - forked repo

by Murray Eisenberg -

I posted essentially the same question in the Main Forum (https://webwork.maa.org/moodle/mod/forum/discuss.php?d=4891#p14709) but have had no response in the 9 days since posting.

In reply to Sergio Chaves

Re: Development in Docker - forked repo

by Nathan Wallach -
Have a look at: https://github.com/openwebwork/webwork2/wiki/Docker---things-to-get-used-to-(and-avoid-surprises) to learn some more about how Docker handles files, etc.

You would typically not want to make changes or do "git work" in "/opt/webwork/webwork2" inside a Docker container. Overall, the data in a container reverts to the "fixed image" on each restart. I think that the manner in which webwork2 and pg are installed inside the Docker image totally removes all the "git data" (which wastes space in images) - which would explain the git commands failing inside the container. (If you are mounting webwork2 from outside the docker image, and the .git subdirectory exists there - it would probably work, but you might end up with all sorts of file ownership and permission problems.)

Instead you would probably want to edit the settings in docker-compose.yml to mount your external (on your hard disk) "webwork2" (or "pg") into the containers at start up time. Then the files on your local disk override what is fixed in the image, and you can make changes, use git, etc. in the relevant directory from outside the Docker container.

Warning: most webwork files are cached by Apache, so you need to restart Apache inside the Docker container (using "docker container exec -it webwork2_app_1 bash" and then running "apachectl graceful" in the container)  or just cycle the container: "docker-compose down; docker-compose up -d" after making changes.

You would add your GitHub form as a "git remote" using "git remote add NAME url-of-repo" (something like "git remote add personal https://github.com/taniwallach/webwork2.git"). If you are working with Docker, this would probably be done in "webwork_docker/webwork2" (outside the Docker container).
In reply to Nathan Wallach

Re: Development in Docker - forked repo

by Sergio Chaves -

Thanks for your answer. I have a better understanding now on how docker handles things. I still haven't figured out how to mount as a volume the modified files in the docker image.

I first tried to modify local files (language translation files to be precise), I uncommented the line

- ".:/opt/webwork/webwork2"

under the volumes section on the "docker-compose.yml" file. However, when doing the down/up cycle I can't connect to the webwork server anymore. I also tried to change the volume to the path where my personal webwork2 was pulled (outside the docker container) and still same issue.

I tried both the up/down cycle and the apache restart process without commenting the line in the .yml file; however, I still don't see the language changes in the webwork UI.

This is my first time playing around with docker, I'd really appreciate if you can point out what I am doing wrong when mounting the volume. Thanks in advance!


In reply to Sergio Chaves

Re: Development in Docker - forked repo

by Michael Gage -

I think you have to start from the

docker build .

command (which the up/down cycle automatically includes if it hasn't been used recently)

however there are cached versions of the dockerized webwork app.  I've found it necessary to remove those images before I do the build. Use docker container rm  and docker image rm (and look at the docker instructions on these commands briefly first). If the build is successful then I do docker-compose up.  I'm still a little vague on how many cached images I need to remove.  Definitely do not remove images associated with mariadb

Hope this helps a little.


Take care,

Mike

In reply to Sergio Chaves

Re: Development in Docker - forked repo

by Nathan Wallach -
1. The server not coming up probably indicated that something is sufficiently broken to prevent Apache from starting.

Running "docker-compose up" without the "-d" shows what is happening and usually when something in the Perl code is broken an error message will show up.

You may need to use both a local PG and a local webwork2 if using develop, as there are changes which can be interdependent, in which case a develop version of one and master of the other might not be compatible and prevent the Docker container from starting.

2. Try starting small and mounting a single file from outside to the container. (examples below) Then use "docker container exec -it webwork2_app_1 bash" and check that you see the local file, and then try to see the expect change in the running system.

Here are some sample mounts from a production machine I run using Docker.

- "/nfs/webwork1_local_config/webwork2/conf/authen_LTI.conf:/opt/webwork/webwork2/conf/authen_LTI.conf"
- "/nfs/webwork1_local_config/webwork2/conf/localOverrides.conf:/opt/webwork/webwork2/conf/localOverrides.conf"
- "/nfs/webwork1_local_config/webwork2/conf/site.conf:/opt/webwork/webwork2/conf/site.conf"
- "/nfs/webwork1_data/webwork2/lib/WeBWorK/Localize/heb.po:/opt/webwork/webwork2/lib/WeBWorK/Localize/heb.po"
- "/nfs/webwork1_local_config/webwork2/lib/WeBWorK.pm:/opt/webwork/webwork2/lib/WeBWorK.pm"

3. About language changes - changing existing "translations" in a PO file should "just work". Adding new translations depends on using maketext calls, etc.
In reply to Nathan Wallach

Re: Development in Docker - forked repo

by Sergio Chaves -
Thank you everyone. I was able to push the local changes up by doing the "docker build ." command and also Nathan's examples of the mounted files were really helpful!