[FEAT] Update user directories properly after an upgrade of base image

Open Beginner friendly
#92 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
bash, docker
Domain
devops

Research direction

The change belongs in the s6 init script at root/etc/s6-overlay/s6-rc.d/init-dokuwiki-config/run, where the loop over USER_DIRECTORY currently copies default folders only when /config/dokuwiki/<dir> does not exist. Read that loop first, then decide how to copy on every start without overwriting user-created files, and check the proposed snippet against the two existing comments. Done means the image's default user folders are refreshed on container start while user data is left intact, verified by running the container with an upgraded base image.

Written by the indexing model from the issue text.

Description

enhancement
Is this a new feature request?
  • I have searched the existing issues
Wanted change

As mentioned by @splitbrain in #90, newer files from the base image are not updated in the user folders:

... it does not update DokuWiki's default files when updating the image and people will run into this problem again in the future.

As background... Although the image moves the user folders from inside the container (/app/www/public) to outside (/config/dokuwiki): https://github.com/linuxserver/docker-dokuwiki/blob/b9a777eafc944052bab4d87c3abeb6a640811b9c/root/etc/s6-overlay/s6-rc.d/init-dokuwiki-config/run#L33-L38

This is however only done when the folder not already exists (! -d /config/dokuwiki/"${i}"). That makes sense: after a user starts using the wiki the user folder will probably contain user files and we do not want to overwrite those. The problem however: when the container is updated the newer version will never reach the user folder.

To fix this we should ALWAYS copy files from the container to the user folders (where applicable). This should be safe because a DokuWiki upgrade is (https://www.dokuwiki.org/install:upgrade) "...Step 4: Unpack the distribution tarball and upload/copy the files over your previous installation...". In other words: the container should not contain files that are modified by the user.

Reason for change

Updates to the image are not properly propagated leading to (potential) errors after a newer version of DokuWiki is released. See #90 for an example of such a case.

Proposed code change

Replace this: https://github.com/linuxserver/docker-dokuwiki/blob/b9a777eafc944052bab4d87c3abeb6a640811b9c/root/etc/s6-overlay/s6-rc.d/init-dokuwiki-config/run#L33-L38

With:

## Sync user folders to persistent storage
for i in "${USER_DIRECTORY[@]}"; do
    if [[ -d /app/www/public/"${i}" ]]; then
        mkdir -p /config/dokuwiki/"${i}"
        cp -a /app/www/public/"${i}" /config/dokuwiki/
    fi
done
Dominant language
Dockerfile
Stars
125
Forks
24
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from linuxserver/docker-dokuwiki

All issues in linuxserver/docker-dokuwiki

Similar issues

More DevOps issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.