sourcegraph / sourcegraph-public-snapshot

Code AI platform with Code Search & Cody
https://sourcegraph.com
Other
10.11k stars 1.27k forks source link

`src-expose` - support sharing read-only repositories #11707

Open abitrolly opened 4 years ago

abitrolly commented 4 years ago

Looks like src-expose is unable to share repo that it can not write to.

Steps to reproduce:

  1. podman run -v "${PWD}:/var/opt/localrepo":Z,ro sourcegraph/src-expose:latest serve /var/opt/localrepo

Expected behavior:

See repo served with some defaults.

Actual behavior:

serve: 2020/06/25 07:50:42 listening on http://[::]:3434
serve: 2020/06/25 07:50:42 serving git repositories from /var/opt/localrepo
serve: 2020/06/25 07:50:42 configuring repo at /var/opt/localrepo/.git: updating server info: error: unable to update info/refs: Read-only file system
error: unable to update objects/info/packs: Read-only file system
warning: unable to unlink 'info/rev-cache': Read-only file system
: exit status 1
serve: 2020/06/25 07:50:42 error encountered on /var/opt/localrepo/.sourcegraph/data/cache: open /var/opt/localrepo/.sourcegraph/data/cache: permission denied
serve: 2020/06/25 07:50:42 error encountered on /var/opt/localrepo/.sourcegraph/data/grafana/png: open /var/opt/localrepo/.sourcegraph/data/grafana/png: permission denied
serve: 2020/06/25 07:50:42 error encountered on /var/opt/localrepo/.sourcegraph/data/postgresql: open /var/opt/localrepo/.sourcegraph/data/postgresql: permission denied
serve: 2020/06/25 07:50:42 error encountered on /var/opt/localrepo/.sourcegraph/data/zoekt/index/.indexserver.tmp/tmpfriend-30-968347374: open /var/opt/localrepo/.sourcegraph/data/zoekt/index/.indexserver.tmp/tmpfriend-30-968347374: permission denied
abitrolly commented 4 years ago

Looks like serve was not needed. Maybe rename that to serve-bares? This seems to work.

podman run --rm -p 127.0.0.1:3434:3434 -v "${PWD}:/var/opt/localrepo":Z,ro sourcegraph/src-expose:latest /var/opt/localrepo
abitrolly commented 4 years ago

Without serve it doesn't serve anything. =/

keegancsmith commented 4 years ago

We rely on a RW filesystem since we currently rely on git's "dumb" server via git update-server-info.

However, we should really be using a smarter protocol and gain other benefits (like protocol v2/etc). This will require additional feature work (I think we may have looked into it slightly with some work in #10045).

cc @unknwon @tsenart

abitrolly commented 4 years ago

Something like https://git-scm.com/docs/git-daemon or https://gitlab.com/gitlab-org/gitaly?

keegancsmith commented 4 years ago

I am porting src-expose serve to the src-cli. There is a PR out which fixes this issue https://github.com/sourcegraph/src-cli/pull/251

Once we tag a release of src-cli supporting this feature I'll comment back here and close this out.