You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.2 KiB

  1. Environment To Ini
  2. ==================
  3. Multiple docker users have requested that the Gitea docker is changed
  4. to permit arbitrary configuration via environment variables.
  5. Gitea needs to use an ini file for configuration because the running
  6. environment that starts the docker may not be the same as that used
  7. by the hooks. An ini file also gives a good default and means that
  8. users do not have to completely provide a full environment.
  9. With those caveats above, this command provides a generic way of
  10. converting suitably structured environment variables into any ini
  11. value.
  12. To use the command is very simple just run it and the default gitea
  13. app.ini will be rewritten to take account of the variables provided,
  14. however there are various options to give slightly different
  15. behavior and these can be interrogated with the `-h` option.
  16. The environment variables should be of the form:
  17. GITEA__SECTION_NAME__KEY_NAME
  18. Environment variables are usually restricted to a reduced character
  19. set "0-9A-Z_" - in order to allow the setting of sections with
  20. characters outside of that set, they should be escaped as following:
  21. "_0X2E_" for ".". The entire section and key names can be escaped as
  22. a UTF8 byte string if necessary. E.g. to configure:
  23. """
  24. ...
  25. [log.console]
  26. COLORIZE=false
  27. STDERR=true
  28. ...
  29. """
  30. You would set the environment variables: "GITEA__LOG_0x2E_CONSOLE__COLORIZE=false"
  31. and "GITEA__LOG_0x2E_CONSOLE__STDERR=false". Other examples can be found
  32. on the configuration cheat sheet.
  33. To plug this command in to the docker, you simply compile the provided go file using:
  34. go build environment-to-ini.go
  35. And copy the resulting `environment-to-ini` command to /app/gitea in the docker.
  36. Apply the below patch to /etc/s6/gitea.setup to wire this in.
  37. If you find this useful please comment on #7287
  38. diff --git a/docker/root/etc/s6/gitea/setup b/docker/root/etc/s6/gitea/setup
  39. index f87ce9115..565bfcba9 100755
  40. --- a/docker/root/etc/s6/gitea/setup
  41. +++ b/docker/root/etc/s6/gitea/setup
  42. @@ -44,6 +44,8 @@ if [ ! -f ${GITEA_CUSTOM}/conf/app.ini ]; then
  43. SECRET_KEY=${SECRET_KEY:-""} \
  44. envsubst < /etc/templates/app.ini > ${GITEA_CUSTOM}/conf/app.ini
  45. + /app/gitea/environment-to-ini -c ${GITEA_CUSTOM}/conf/app.ini
  46. +
  47. chown ${USER}:git ${GITEA_CUSTOM}/conf/app.ini
  48. fi