A small recap of the steps I followed to update my forgejo instance across several major versions in one go.
If you read my prior post about reinstalling my web server, you may remember I finished it by mentioning that version 14.0.2 of forgejo was already out and so my next step should be to upgrade the instance to it. Well, some time has passed - and more importantly, some (major(!)) versions of forgejo have as well. At the time of this writing, the latest official version of forgejo available as a rootless container is 17.0.1.
v13.x to v14.xThe steps for this version increase were very simple:
Image value of the forgejo.container file:[Container]
# ...
- Image=codeberg.org/forgejo:13-rootless
+ Image=codeberg.org/forgejo:14-rootless
# ...
systemd regenerate the service file that lets it run the instance container by running:systemctl --user daemon-reloadsystemd pull (and use) the correct image version by running:systemctl --user restart forgejov14.x to v15.xThe steps for this version increase are basically the same as for the previous increase, with 15 instead of 14:
Image value of the forgejo.container file:[Container]
# ...
- Image=codeberg.org/forgejo:14-rootless
+ Image=codeberg.org/forgejo:15-rootless
# ...
systemd regenerate the service file that lets it run the instance container by running:systemctl --user daemon-reloadsystemd pull (and use) the correct image version by running:systemctl --user restart forgejov15.x to v16.xThe upgrade guide has specific sections that address this version increment and the next. For incrementing from before 16.0 to 16.0 or greater there is just an optional cleanup operation - deleting a handful of server-side git hooks. While the actual file size is almost negligeable, I didn't want to be holding on to a handful of extra files for each of the thirty-odd existing repositories tracked by my instance.
First, I repeated the same steps as for the previous version increments:
Image value of the forgejo.container file:[Container]
# ...
- Image=codeberg.org/forgejo:15-rootless
+ Image=codeberg.org/forgejo:16-rootless
# ...
systemd regenerate the service file that lets it run the instance container by running:systemctl --user daemon-reloadsystemd pull (and use) the correct image version by running:systemctl --user restart forgejoThe upgrade guide provides a single bash/shell command that would do the cleanup for me, I just needed to feed it the correct directory. Since the instance is run as a container + data volume pair, the "correct directory" is inside of that data-volume.
debian@hostname$ podman exec -it forgejo /bin/bash
5054265fc0f7:/var/lib/gitea$
find "$REPO_PATH" -mindepth 3 -maxdepth 3 -name hooks -exec rm -rf {} \;. I found it simpler to define the REPO_PATH variable first, and then paste the command and press enter:5054265fc0f7:/var/lib/gitea$ export REPO_PATH="./git/repositories"
5054265fc0f7:/var/lib/gitea$ find "$REPO_PATH" -mindepth 3 -maxdepth 3 -name hooks -exec rm -rf {} \;
(output omitted)
v16.x to v17.0.1The specific section for this version upgrade has another optional cleanup step. This time it's deleting .patch files that forgejo used to download for pull requests migrated from other software forges. According to the upgrade guide, these files were unnecessary and not used by forgejo and can be deleted to free up disk space.
The guide, again, provides a single bash/shell command that takes care of the cleanup:
find "$REPO_PATH" -mindepth 3 -maxdepth 3 -name pulls -exec rm -rf {} \;
Just like the previous increment, I found it simpler to open a shell inside of my instance's container, define the $REPO_PATH variable, and then run the find command.
First, I repeated the same steps as for the previous version increments:
Image value of the forgejo.container file:[Container]
# ...
- Image=codeberg.org/forgejo:16-rootless
+ Image=codeberg.org/forgejo:17-rootless
# ...
systemd regenerate the service file that lets it run the instance container by running:systemctl --user daemon-reloadsystemd pull (and use) the correct image version by running:systemctl --user restart forgejoREPO_PATH variable, and finally ran the find command:debian@hostname$ podman exec -it forgejo /bin/bash
5054265fc0f7:/var/lib/gitea$ export REPO_PATH="./git/repositories"
5054265fc0f7:/var/lib/gitea$ find "$REPO_PATH" -mindepth 3 -maxdepth 3 -name pulls -exec rm -rf {} \;
(output omitted)
At the end of all of this, viewing one of the instance's pages in my preferred web browser showed me a small Powered by Forgejo Version: 17.0.1
in that page's footer; confirmation that the instance was now running on the latest version of forgejo.
I really should have done this sooner; the fuss it took me to get the instance back up and running overly discouraged me from even trying the updates - which themselves turned out to be rather painless.