Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 of 8 tasks
Cyber1000 opened this issue Jul 21, 2018 · 2 comments
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@Cyber1000
Copy link

Cyber1000 commented Jul 21, 2018

  • Gitea version (or commit ref): fe78154
  • Operating system: docker (in ubuntu)
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
    • would need to change app.ini

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

@lafriks lafriks added the type/proposal The new feature has not been accepted yet but needs to be discussed first. label Jul 21, 2018
@Cyber1000
Copy link
Author

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

  • Adding following to volumes of docker-compose: ./data/etc/s6/chmodtmpdata/run:/etc/s6/chmodtmpdata/run
  • ./data/etc/s6/chmodtmpdata/run contains:
#!/bin/bash
if ! [[ $(ls -ld /tmpdata | awk '{print $3}') = ${USER} ]]; then chown -R ${USER}:git /tmpdata; fi

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
Copy link
Contributor

wxiaoguang commented May 13, 2022

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.

@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

No branches or pull requests

3 participants