Closed jvinolas closed 3 years ago
Yes, you can, but remember to create the folder with the nobody user. Also remember to copy the isinstalled.php file in the www/html/admin/cli folder or the startup script won't work.
I prefer using data volumes instead of mounting folders, is faster for high volume sites or hosts with rare filesystems (macos, bsd...) And also easier to update.
Best!
I see your point. But we want to control where the storage is put by defining de volume mountpoint as moodle data will be on network storage.
Thanks, I'll try
Sorry to reopen again, I'm to able to create those folders (html and moodledata) as nobody user in the derivated Dockerfile neither at 02-configure-moodle.sh. Do you mean to change the owner at host side?
Don't worry, I will let it open until worked. You need to create the folder on the host side, please share your docker-compose and Dockerfile to check what is happening. Check also there is no problem with SELinux as you can read here: https://stackoverflow.com/questions/24288616/permission-denied-on-accessing-host-directory-in-docker
These are the relevant parts:
version: '3.7'
services:
isard-office-moodle:
#image: erseco/alpine-moodle
build:
context: ${BUILD_ROOT_PATH}/docker/moodle
dockerfile: Dockerfile.test
container_name: isard-office-moodle
restart: unless-stopped
volumes:
- /etc/localtime:/etc/localtime:ro
- ${DATA_FOLDER}/moodle/data:/var/www/moodledata:rw
- ${DATA_FOLDER}/moodle/html:/var/www/html:rw
And the Dockerfile.test:
FROM erseco/alpine-moodle
USER root
RUN chown -R nobody:nobody /var/www/html
RUN chown -R nobody:nobody /var/www/moodledata
USER nobody
COPY rootfs/docker-entrypoint-init.d/02-configure-moodle.sh /docker-entrypoint-init.d/02-configure-moodle.sh
COPY rootfs/isinstalled.php /
Also the relevant part of the modified 02-configure-moodle.sh:
# Check if the config.php file exists
if [ ! -f /var/www/html/config.php ]; then
echo "Downloading moodle src..."
curl --location $MOODLE_URL | tar xz --strip-components=1 -C /var/www/html/
cp /isinstalled.php /var/www/html/admin/cli/
sh /plugins.sh
chown -R nobody:root /var/www/html
echo "Generating config.php file..."
The host OS is Debian and I stopped apparmor also without success. With this configuration it says:
Starting startup scripts in /docker-entrypoint-init.d ...
*** Running: /docker-entrypoint-init.d/01-uname.sh
Linux c46d005c0e8a 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 Linux
*** Running: /docker-entrypoint-init.d/02-configure-moodle.sh
Waiting for isard-office-postgresql:5432 to be ready
is ready
Downloading moodle src...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 132 100 132 0 0 705 0 --:--:-- --:--:-- --:--:-- 709
tar: can't open '.eslintignore': Permission denied
100 42349 0 42349 0 0 80511 0 --:--:-- --:--:-- --:--:-- 80511
curl: (23) Failure writing output to destination
*** Failed with return value: 0
Thanks
You are downloading again the moodle source, maybe, in that case, will be easier to use my parent container alpine-php7-webserver and configure moodle by yourself using this container scripts or your own. It will be smaller and easier to maintain than overwriting this container moodle files.
I donwloaded as I couldn't mount path as volume over the existing one, but if there is a simpler way of doing it with you alpine-moodle image I will do it. But I don't know how.
For doing this using the alpine-moodle container but binding the files you first must copy the files in your folder, for doing that:
Run the container (just to copy files)
docker run --rm -it erseco/alpine-moodle
Copy files to your desired place (${DATA_FOLDER}/moodle/)
docker cp <container_id>:/var/www/moodledata ${DATA_FOLDER}/moodle/
docker cp <container_id>:/var/www/html ${DATA_FOLDER}/moodle/
Stop the container. It will be deleted (--rm) when stopped.
docker stop <container_id>
Run the whole system with docker-compose up
using a file similar to this:
version: '3.7'
services:
isard-office-moodle:
image: erseco/alpine-moodle
restart: unless-stopped
volumes:
- ${DATA_FOLDER}/moodle/moodledata:/var/www/moodledata:rw
- ${DATA_FOLDER}/moodle/html:/var/www/html:rw
environment:
- LANG=en_US.UTF-8
- LANGUAGE=en_US:en
- SITE_URL=http://localhost
- DB_TYPE=pgsql
- DB_HOST=postgres
- DB_PORT=5432
- DB_NAME=moodle
- DB_USER=moodle
- DB_PASS=moodle
- DB_PREFIX=mdl_
- SSLPROXY=false
- MOODLE_EMAIL=user@example.com
- MOODLE_LANGUAGE=en
- MOODLE_SITENAME=New-Site
- MOODLE_USERNAME=moodleuser
- MOODLE_PASSWORD=PLEASE_CHANGEME
- SMTP_HOST=smtp.gmail.com
- SMTP_PORT=587
- SMTP_USER=your_email@gmail.com
- SMTP_PASSWORD=your_password \
- SMTP_PROTOCOL=tls
- MOODLE_MAIL_NOREPLY_ADDRESS=noreply@localhost
- MOODLE_MAIL_PREFIX=[moodle]
ports:
- 80:8080
depends_on:
- postgres
postgres:
image: postgres:alpine
restart: unless-stopped
environment:
- POSTGRES_PASSWORD=moodle
- POSTGRES_USER=moodle
- POSTGRES_DB=moodle
volumes:
- postgres:/var/lib/postgresql/data
volumes:
postgres: null
Closing this due to inactivity. Let me know if you still experience this issue.
Is it possible to mount moodledata and html folders on a host path like this:
It says that the installer can't create the /var/www/moodledata/ folder.