From dad16cd5895a945c067ec6a2dacdac67afc8aa04 Mon Sep 17 00:00:00 2001 From: Gerard Salvatella Date: Mon, 22 Apr 2024 04:53:04 +0200 Subject: [PATCH] fix(Dockerfile.rootless): revert to default path for `app.ini` The current path of the `$GITEA_APP_INI` configuration file makes the forgejo application reset every time the container is restarted, unless a specific volume for this file is created. Consider the following: * This quirk is not documented * All configuration data resides in `/var/lib/gitea` * The custom configuration path defaults to `/var/lib/gitea/custom/conf` (see `forgejo -h`) * Containers mounting the volume `-v /foo/bar:/var/lib/gitea` already have this file available to modify. Another volume shouldn't be required * Containers using named volumes can use `docker cp` to modify the file inside the volume, if desired For these reasons, it makes more sense to use the default path for `$GITEA_APP_INI` rather than require users to create a dedicated volume for the file. Revert it back to its default while maintaining backwards compatibility (users can update by simply moving the file to the new path). --- Dockerfile.rootless | 7 +++++-- docker/rootless/usr/local/bin/docker-entrypoint.sh | 5 +++++ docker/rootless/usr/local/bin/docker-setup.sh | 12 ++++++++++++ release-notes/8.0.0/fix/3363.md | 6 ++++++ 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 release-notes/8.0.0/fix/3363.md diff --git a/Dockerfile.rootless b/Dockerfile.rootless index 3f4cba955a..6d1503f034 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -100,8 +100,11 @@ ENV GITEA_CUSTOM /var/lib/gitea/custom ENV GITEA_TEMP /tmp/gitea ENV TMPDIR /tmp/gitea -#TODO add to docs the ability to define the ini to load (useful to test and revert a config) -ENV GITEA_APP_INI /etc/gitea/app.ini +# Legacy config file for backwards compatibility +# TODO: remove on next major version release +ENV GITEA_APP_INI_LEGACY /etc/gitea/app.ini + +ENV GITEA_APP_INI ${GITEA_CUSTOM}/conf/app.ini ENV HOME "/var/lib/gitea/git" VOLUME ["/var/lib/gitea", "/etc/gitea"] WORKDIR /var/lib/gitea diff --git a/docker/rootless/usr/local/bin/docker-entrypoint.sh b/docker/rootless/usr/local/bin/docker-entrypoint.sh index ca509214bf..e5fa41cc78 100755 --- a/docker/rootless/usr/local/bin/docker-entrypoint.sh +++ b/docker/rootless/usr/local/bin/docker-entrypoint.sh @@ -13,5 +13,10 @@ fi if [ $# -gt 0 ]; then exec "$@" else + # TODO: remove on next major version release + # Honour legacy config file if existing + if [ -f ${GITEA_APP_INI_LEGACY} ]; then + GITEA_APP_INI=${GITEA_APP_INI_LEGACY} + fi exec /usr/local/bin/gitea -c ${GITEA_APP_INI} web fi diff --git a/docker/rootless/usr/local/bin/docker-setup.sh b/docker/rootless/usr/local/bin/docker-setup.sh index b480685863..09bbeabc63 100755 --- a/docker/rootless/usr/local/bin/docker-setup.sh +++ b/docker/rootless/usr/local/bin/docker-setup.sh @@ -11,6 +11,18 @@ mkdir -p ${GITEA_CUSTOM} && chmod 0700 ${GITEA_CUSTOM} mkdir -p ${GITEA_TEMP} && chmod 0700 ${GITEA_TEMP} if [ ! -w ${GITEA_TEMP} ]; then echo "${GITEA_TEMP} is not writable"; exit 1; fi +# TODO: remove on next major version release +# Honour legacy config file if existing, but inform the user +if [ -f ${GITEA_APP_INI_LEGACY} ] && [ ${GITEA_APP_INI} != ${GITEA_APP_INI_LEGACY} ]; then + GITEA_APP_INI_DEFAULT=/var/lib/gitea/custom/conf/app.ini + echo -e \ + "\033[33mWARNING\033[0m: detected configuration file in deprecated default path ${GITEA_APP_INI_LEGACY}." \ + "The new default is ${GITEA_APP_INI_DEFAULT}. To remove this warning, choose one of the options:\n" \ + "* Move ${GITEA_APP_INI_LEGACY} to ${GITEA_APP_INI_DEFAULT} (or to \$GITEA_APP_INI if you want to override this variable)\n" \ + "* Explicitly override GITEA_APP_INI=${GITEA_APP_INI_LEGACY} in the container environment" + GITEA_APP_INI=${GITEA_APP_INI_LEGACY} +fi + #Prepare config file if [ ! -f ${GITEA_APP_INI} ]; then diff --git a/release-notes/8.0.0/fix/3363.md b/release-notes/8.0.0/fix/3363.md new file mode 100644 index 0000000000..65b516cabc --- /dev/null +++ b/release-notes/8.0.0/fix/3363.md @@ -0,0 +1,6 @@ +Reverted the rootless container image path in `GITEA_APP_INI` from +`/etc/gitea/app.ini` to its default value of +`/var/lib/gitea/custom/conf/app.ini`. This allows container users to not have +to mount two separate volumes (one for the configuration data and one for the +configuration `.ini` file). A warning is issued for users with the legacy +configuration on how to update to the new path.