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

Docker setup fails with Git Error #42

Closed
belibug opened this issue May 28, 2022 · 17 comments
Closed

Docker setup fails with Git Error #42

belibug opened this issue May 28, 2022 · 17 comments

Comments

@belibug
Copy link

belibug commented May 28, 2022

Running wikmd as docker container with following error.

wikmd    | [2022-05-28 19:35:41,212] INFO in git_manager: Initializing existing repo >>> wiki ...
wikmd    | [2022-05-28 19:35:41,212] INFO in git_manager: Creating 'main' branch ...
wikmd    | [2022-05-28 19:35:41,216] ERROR in git_manager: Existing repo initialization failed >>> Cmd('git') failed due to: exit code(128)
wikmd    |   cmdline: git branch -M main
wikmd    |   stderr: 'fatal: unsafe repository ('/app/wikmd/wiki' is owned by someone else)
wikmd    | To add an exception for this directory, call:
wikmd    |
wikmd    |      git config --global --add safe.directory /app/wikmd/wiki'

Troubleshooting done,

  1. Configured PID GID to current user
  2. Ensured path/to/wiki has correct permission
@Linbreux
Copy link
Owner

Hi @belibug ,
the docker image has known issues. I'm working on it to resolve it. For now I would suggest running it native on your machine if possible to get the best experience.

@Waldorf3
Copy link

Waldorf3 commented Jun 4, 2022

Hi @belibug , the docker image has known issues. I'm working on it to resolve it. For now I would suggest running it native on your machine if possible to get the best experience.

I hope you'll be able to upload a working docker image soon. Wikmd seems to be exactly what I've been looking for - simple clean interface, no nonsense, not trying to be a lot of other things.

@Linbreux
Copy link
Owner

Linbreux commented Jun 4, 2022

Hi @Waldorf3, I tried looking for the problem, but I can't seem to find how to get the user permission to work. It seems like the docker/root/etc/cont-init.d/30-config file does not work.

I fixed it for now using the following method:

docker exec -it <container-id> bash
chown -R abc:abc wiki/ 
chown -R abc:abc wikmd

let me know if that worked ;)

@artivis Sorry for the inconvenience, your Dockerfiles worked like a charm. But do you know how to fix the permission issue here, I can't seem to find the problem?

@artivis
Copy link
Contributor

artivis commented Jun 4, 2022

Hey, no problem. A quick search seem to point to a recent change in git. It has affected a lot of other projects. I'm not at my computer so I can't debug that right now but the permissions are set here for new repo created from the example. I'll give it a look on Monday 👍.

@Linbreux
Copy link
Owner

Linbreux commented Jun 4, 2022

Alright, I'll look into it. Thanks for the quick response, appreciate it!

@Waldorf3
Copy link

Waldorf3 commented Jun 5, 2022

Hi @Waldorf3, I tried looking for the problem, but I can't seem to find how to get the user permission to work. It seems like the docker/root/etc/cont-init.d/30-config file does not work.

I fixed it for now using the following method:

docker exec -it <container-id> bash
chown -R abc:abc wiki/ 
chown -R abc:abc wikmd

let me know if that worked ;)

@artivis Sorry for the inconvenience, your Dockerfiles worked like a charm. But do you know how to fix the permission issue here, I can't seem to find the problem?

/wiki already is www-data.www-data (my preferred uid-gid)
There is no /wikmd. There is a /app/wikmd, and if i chown that as well it kinda works, but data is now stored under /app/wikmd/wiki - not /wiki . I guess the quick workaround would be to mount /app/wikmd/wiki in the docker-compose instead?

edit ... that kinda works, but then all the examples disappear...

@Linbreux
Copy link
Owner

Linbreux commented Jun 5, 2022

My excuses, I meant 'app/wikmd'. How does your docker-compose look like? I also tried to chown the mount folder on my host machine with the hosts user (even if it already was the same) and that also made it work.

If you don't specify a volume the files won't be stored in 'wiki'.

@Waldorf3
Copy link

Waldorf3 commented Jun 5, 2022

My docker-compose.yml is pretty much straight from the github:

version: "2.1"
services:
  wikmd:
    image: linbreux/wikmd:latest
    container_name: wikmd
    environment:
      - PUID=33
      - PGID=33
      - TZ=Europe/Brussels
#      - HOMEPAGE=homepage.md #optional
#      - HOMEPAGE_TITLE=homepage.md #optional
#      - WIKMD_LOGGING=1 #optional
    volumes:
      - /homes/me/wiki:/app/wikmd/wiki
    ports:
      - 8086:5000
    restart: unless-stopped

btw, would it not make sense to have a config folder on the host for whatever users might customize (template etc)

@Linbreux
Copy link
Owner

Linbreux commented Jun 5, 2022

Could you try:

---
version: "2.1"
services:
  wikmd:
    image: linbreux/wikmd:latest
    container_name: wikmd
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Paris
      - HOMEPAGE=homepage.md #optional
      - HOMEPAGE_TITLE=homepage.md #optional
      - WIKMD_LOGGING=1 #optional
      - WIKI_DIRECTORY=/wiki
    volumes:
      - /home/me/wiki:/wiki
    ports:
      - 8086:5000
    restart: unless-stopped

Make sure to specify the WIKI_DIRECTORY. Also try to chown /home/me/wiki again on the host.

EDIT: The customization in docker is done using the env variables. So currently there is no support for a config on the host.

@Waldorf3
Copy link

Waldorf3 commented Jun 5, 2022

Yes that worked, thanks!

The documentation files are no longer present though, the files under /app/wikmd/wiki in the container, also not when hitting list as before, is that on purpose?

I get your point about config through env variables, makes good sense, sorry I didn't think about that.

@Linbreux
Copy link
Owner

Linbreux commented Jun 5, 2022

Hi good to hear that, also make sure to create a img file in the wiki folder when you want to upload images through the webinterface.

The demo files are indeed not present, thats a problem I'll fix in the future. But for know everything should work.

@Waldorf3
Copy link

Waldorf3 commented Jun 6, 2022

I copied the content from /app/wikmd/wiki to /wiki, that seems to take are of it?

@artivis
Copy link
Contributor

artivis commented Jun 7, 2022

I couldn't reproduce the error described here (did find a couple other tho).
@belibug any chance you could provide a minimal reproducible example?

@belibug
Copy link
Author

belibug commented Jun 8, 2022

@artivis this is how you can reproduce the error.
I used below docker compose yaml file to build docker image.

version: "2.1"
services:
  wikmd:
    image: linbreux/wikmd:latest
    container_name: wikmd
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Paris
      - HOMEPAGE=homepage.md #optional
      - HOMEPAGE_TITLE=homepage.md #optional
      - WIKMD_LOGGING=1 #optional
    volumes:
      - ./wiki:/wiki
    ports:
      - 5000:5000
    restart: unless-stopped

As you can see I mapped local immediate path 'wiki' to 'wiki' and I get below error.

wikmd    | INFO in git_manager: Creating a new local repo >>> wiki ...
wikmd    | ERROR in git_manager: New local repo initialization failed >>> Cmd('git') failed due to: exit code(1)
wikmd    |  cmdline: git init
wikmd    |  stderr: '/app/wikmd/wiki/.git: Permission denied'

I have tried mapping volume as /wiki:/app/wikmd/wiki with no success. Like others I tried chown the folder and set to full open permission 777 which throws new error as below.

wikmd    | INFO in git_manager: Creating a new local repo >>> wiki ...
wikmd    |  INFO in git_manager: Creating 'main' branch ...
wikmd    |  ERROR in git_manager: New local repo initialization failed >>> Cmd('git') failed due to: exit code(128)
wikmd    |  cmdline: git branch -M main
wikmd    |  stderr: 'fatal: unsafe repository ('/app/wikmd/wiki' is owned by someone else)
wikmd    | To add an exception for this directory, call:
wikmd    |
wikmd    |   git config --global --add safe.directory /app/wikmd/wiki'
wikmd    |  * Serving Flask app "wiki" (lazy loading)

Thank you.

@artivis
Copy link
Contributor

artivis commented Jun 8, 2022

Hi @belibug,
Thanks for the detailed report. Could you try the fix I proposed in #45 :

  • build the image,
git clone https://github.com/Linbreux/wikmd.git
cd wikmd
docker build -t linbreux/wikmd:fix -f docker/Dockerfile .
  • launch the container,
docker run -d \
  --name wikmd \
  -e TZ=Europe/Paris \
  -e PUID=1000 \
  -e PGID=1000 \
  -e HOMEPAGE=homepage.md `#optional` \
  -e HOMEPAGE_TITLE=homepage.md `#optional` \
  -e WIKMD_LOGGING=1 `#optional` \
  -p 5000:5000 \
  -v ./wiki:/wiki \
  --restart unless-stopped \
  linbreux/wikmd:fix

Make sure that the permissions are correctly set, e.g. with,

$ id myuser
uid=1001(myuser) gid=1002(myuser) groups=1001(myuser)

then you should set PUID=1001 and PGID=1002.

@belibug
Copy link
Author

belibug commented Jun 9, 2022

@artivis I tried building from docker file, It worked for most part but failed to rename branch which is same as issue #44 which I see you opened.

wikmd    | [2022-06-09 03:37:18,438] INFO in git_manager: Initializing existing repo >>> /wiki ...
wikmd    | INFO in git_manager: Creating 'main' branch ...
wikmd    | ERROR in git_manager: Existing repo initialization failed >>> Cmd('git') failed due to: exit code(128)
wikmd    | cmdline: git branch -M main
wikmd    | stderr: 'error: refname refs/heads/master not found
wikmd    | fatal: Branch rename failed'

@Linbreux
Copy link
Owner

Linbreux commented Jun 9, 2022

hi @belibug

This problem should be solved in 4c659ca.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants