go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
45.1k stars 5.49k forks source link

Proposal: Parse app.ini in entrypoint and create all necessary folders in docker entrypoint, even if they are different from /data/gitea #4491

Closed Cyber1000 closed 2 years ago

Cyber1000 commented 6 years ago

Description

gitea/docker/usr/bin/entrypoint does this: for FOLDER in /data/gitea/conf /data/gitea/log /data/git /data/ssh; do mkdir -p ${FOLDER} done So it creates the folders with root permissions (it changes user to git later on in docker/etc/s6/gitea/setup)

my log-location in app.ini:

[log] ROOT_PATH = /tmpdata/gitea/log MODE = file LEVEL = Info

"Normal" configs are still in /data-Folder

/tmpdata/gitea (or /tmpdata/gitea/log) is not there when starting gitea (and won't be created in entrypoint), when running it tries to create the folder, at least it seems so (but obviously with git-user) and dies:

/go/src/code.gitea.io/gitea/main.go:52 +0x40e 2018/07/21 04:02:03 [T] AppPath: /app/gitea/gitea 2018/07/21 04:02:03 [T] AppWorkPath: /app/gitea 2018/07/21 04:02:03 [T] Custom path: /data/gitea 2018/07/21 04:02:03 [T] Log path: /tmpdata/gitea/log panic: mkdir /tmpdata/gitea: permission denied

Problem: I have to manually chown tmpdata on my host, if tmpdata would be a normal mountpoint this wouldn't be a problem, but I have to do this on a named volume (and therefore /var/lib/docker/volumes/gitserver_tmpdata/_data), which is quite unusual

Proposal: parse app.ini in entrypoint and create all necessary folders in docker entrypoint (even if they are different from /data/gitea). May be done toghether with #4425

My user within container is (as stated in the docker-compose.yml examples) git, and I dared to change it (to root), cause I dind't know if any side effects could occur:

environment:

  • USER_UID=1000
  • USER_GID=1000
Cyber1000 commented 4 years ago

I found an easier solution than changing user of /var/lib/docker/volumes/gitserver_tmpdata/_data direct from outside the docker-container:

So more or less I'm adding a onetimejob which changes the dir from within the container. Maybe worth mentioning in docs, that you can use s6 for special tasks. A dedicated entry point for user initialisations at /etc/s6/gitea/run may be fine though

wxiaoguang commented 2 years ago

I think this proposal could be closed.

For docker image, it's not recommended to change the directory layout manually. If you need your own layout, you could build your own docker image.

And entrypoint doesn't know what directory is really needed when the docker container is starting. Even more, to be stable, an app shouldn't create too many non-existing directories unexpectedly, usually it's user's responsibility to prepare all parent directories.