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

Update Docker instructions to include user permissions #19

Merged
merged 2 commits into from
Aug 30, 2023
Merged

Update Docker instructions to include user permissions #19

merged 2 commits into from
Aug 30, 2023

Conversation

graskaas
Copy link
Contributor

This is a fix for #10

@stappersg
Copy link
Contributor

Time will tell when @orzklv, reporter of issue #10, got time to provide feedback.

@orzklv
Copy link

orzklv commented Aug 29, 2023

Ok, after redeploying website using my old command with this addition, rgit... kinda... stopped showing whatever on website. For the development of this project, I deployed it here: 46.4.100.41:6666

image
image

curl is hanging on waiting for response...
image

maybe i'm missing something, please correct me if i'm doing not right.

@orzklv
Copy link

orzklv commented Aug 29, 2023

Now, it keeps indexing...
image
but website is still not responsive.
image

@graskaas
Copy link
Contributor Author

Since the errors with permissions have stopped, I think you're missing the setup for repos. Are they cloned to /srv/repos with --bare?

I just tried going to the ip:port you listed and Firefox gives me an error:

This address is restricted

This address uses a network port which is normally used for purposes other than Web browsing. Firefox has canceled the request for your protection.

When I try it with curl, I get a response, so it is responsive, just not showing repos.

~ ❯ curl 46.4.100.41:6666                                              07:57:55
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width">
    <title>rgit</title>
    <link rel="stylesheet" type="text/css" href="/style.css" />
</head>

<body>
<header>
    <h1>
        <a href="/" class="no-hover">🏡</a>
        Git repository browser
    </h1>
</header><nav>
    <a href="/" class="active">index</a>
</nav><main>
    <table class="repositories">
        <thead>
        <tr>
            <th>Name</th>
            <th>Description</th>
            <th>Owner</th>
            <th>Idle</th>
        </tr>
        </thead>

        <tbody>
        </tbody>
    </table>
</main>

<footer>
    generated by <a href="https://git.inept.dev/~doyle/rgit.git/about" target="_blank">rgit</a> v0.1.0 at 2023-08-29 5:57:59.644854694 +00:00:00
</footer>
</body>

Can you paste here the exact command you entered to bring up the container?
Can you also you paste the output of ls -l /srv/repos?

For more testing:

docker exec -it 30af494feac7 /bin/bash
ls -l /git

Also paste the output. The contents should be identical to /srv/repos

In my testing I've done the following steps:

docker host as user gituser with uid and gid of 1001

mkdir -p /mnt/data/rgit/repos
cd /mnt/data/rgit/repos
git clone --bare https://github.com/w4/rgit.git
git clone --bare https://github.com/graskaas/slabs-from-wood.git
git clone --bare https://github.com/iv-org/invidious.git

Note that I only own one of those repos.

Result:

repos ls -la
total 20
drwxr-xr-x 5 gituser gituser 4096 Aug 29 08:29 .
drwxr-xr-x 4 gituser gituser 4096 Aug 28 16:16 ..
drwxr-xr-x 7 gituser gituser 4096 Aug 29 08:29 invidious.git
drwxr-xr-x 7 gituser gituser 4096 Aug 29 08:29 rgit.git
drwxr-xr-x 7 gituser gituser 4096 Aug 29 08:29 slabs-from-wood.git

docker host as user holly gid and uid 1000 in docker group

docker run --mount type=bind,source=/mnt/data/rgit/repos,target=/git \
  --user 1001:1001 -p 3333:8000 \
  -it ghcr.io/w4/rgit:main

Result:

➜  ~ whoami
holly
➜  ~ docker run --mount type=bind,source=/mnt/data/rgit/repos,target=/git \
  --user 1001:1001 -p 3333:8000 \
  -it ghcr.io/w4/rgit:main

2023-08-29T06:35:07.311639Z  INFO rgit: Running periodic index
2023-08-29T06:35:07.311703Z  INFO index_update: rgit::database::indexer: Starting index update
2023-08-29T06:35:07.320607Z  INFO index_update:branch_index_update{reference="refs/heads/add-404-status-code" repository="invidious.git"}: rgit::database::indexer: Refreshing indexes
2023-08-29T06:35:07.458678Z  INFO index_update:branch_index_update{reference="refs/heads/add-proxy" repository="invidious.git"}: rgit::database::indexer: Refreshing indexes
2023-08-29T06:35:07.519018Z  INFO index_update:branch_index_update{reference="refs/heads/disable-notifications" repository="invidious.git"}: rgit::database::indexer: Refreshing indexes
2023-08-29T06:35:07.654417Z  INFO index_update:branch_index_update{reference="refs/heads/limit-feeds-materialized-views" repository="invidious.git"}: rgit::database::indexer: Refreshing indexes
2023-08-29T06:35:07.840310Z  INFO index_update:branch_index_update{reference="refs/heads/master" repository="invidious.git"}: rgit::database::indexer: Refreshing indexes
2023-08-29T06:35:08.028539Z  INFO index_update:branch_index_update{reference="refs/heads/throw-error-wrong-video" repository="invidious.git"}: rgit::database::indexer: Refreshing indexes
2023-08-29T06:35:08.193732Z  INFO index_update:branch_index_update{reference="refs/heads/main" repository="rgit.git"}: rgit::database::indexer: Refreshing indexes
2023-08-29T06:35:08.198637Z  INFO index_update:branch_index_update{reference="refs/heads/master" repository="slabs-from-wood.git"}: rgit::database::indexer: Refreshing indexes
2023-08-29T06:35:08.203797Z  INFO index_update:tag_index_update{reference="refs/tags/0.1.0" repository="rgit.git"}: rgit::database::indexer: Inserting newly discovered tag to index
2023-08-29T06:35:08.204202Z  INFO index_update: rgit::database::indexer: Flushing to disk
2023-08-29T06:35:08.204338Z  INFO index_update: rgit::database::indexer: Finished index update
2023-08-29T06:35:08.204347Z  INFO rgit: Finished periodic index

Screenshot 2023-08-29 at 08-35-45 rgit

Thinking more on this, what user does your docker run under?

@orzklv
Copy link

orzklv commented Aug 29, 2023

@graskaas

Can you paste here the exact command you entered to bring up the container?

docker run --mount type=bind,source=/srv/repos,target=/git -it -d --restart always --user $UID:$GID -p 6666:8000 ghcr.io/w4/rgit:main

Can you also you paste the output of ls -l /srv/repos?

image

docker exec -it 30af494feac7 /bin/bash && ls -l /git

image

Thinking more on this, what user does your docker run under?

it's arch and docker is running via systemd service whereas user has access to it via group

i'll try to change a few commands and test little bit and share with feedbacks for sure...

@orzklv
Copy link

orzklv commented Aug 29, 2023

moved server from 6666 to 3001, it's working... buuut no repos (

@orzklv
Copy link

orzklv commented Aug 29, 2023

hold on, i know what't wrong. it's just my stupidity. let me put that config into repo.

@orzklv
Copy link

orzklv commented Aug 29, 2023

nope, still not showing... maybe config isn't correct?
i created a bare repo and stored that config:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = true
[gitweb]
        owner = "Sokhibjon Orzikulov"

@graskaas
Copy link
Contributor Author

I see that the server is working, however your directory structure is incorrect. The listing of /srv/repos needs to be a list of repo directories.

I have also noticed that repos without commits do not show up, so simply git init --bare myrepo.git does not work.

If you remove the contents of /srv/repos/ and then do git clone --bare https://github.com/w4/rgit.git inside of /srv/repos does it work then?

Your directory structure should look like

/srv/repos
...rgit.git

@orzklv
Copy link

orzklv commented Aug 29, 2023

I did the following:

  • Deleted the example git repo form bare init
  • Cloned my own repo and pasted config
  • Cloned rgit repo
  • Nope...
    image
    image

@graskaas
Copy link
Contributor Author

Those directories are owned by root is there a reason for that? Can you chown -R the repos to the user that is running the docker command?

What do the logs say when scanning?

@orzklv
Copy link

orzklv commented Aug 29, 2023

chown -R

ladies and gentlemen, it's officially cooking!
image

@orzklv
Copy link

orzklv commented Aug 29, 2023

thank you all very much for support! ❤️ i guess we need to cover all those on readme docker guide imo.

@stappersg
Copy link
Contributor

stappersg commented Aug 29, 2023

Not yet seen that something like

docker run --mount type=bind,source=/srv/repos,target=/git \
  --user 1000:101 \
  -it -d --restart always -p 3001:8000 ghcr.io/w4/rgit:main

is a known good example.

Neither seen that ( removed --user UID:GID )

docker run --mount type=bind,source=/srv/repos,target=/git \
  -it -d --restart always -p 3001:8000 ghcr.io/w4/rgit:main

shows the error that triggered this merge request ( #10 ).

Now waiting for a docker user to be explicit about it.

@w4
Copy link
Owner

w4 commented Aug 30, 2023

Awesome work, thanks guys!

@w4 w4 merged commit f539ac9 into w4:main Aug 30, 2023
4 checks passed
@stappersg
Copy link
Contributor

stappersg commented Aug 30, 2023 via email

@orzklv
Copy link

orzklv commented Sep 4, 2023

I'm sorry for late response. The current readme seems fine, tried it again and works fine. Closing the issue.

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

Successfully merging this pull request may close these issues.

4 participants