I want to have a local mirror/proxy for some repos I’m using.

The idea is having something I can point my reads to so that I’m free to migrate my upstream repositories whenever I want and also so that my stuff doesn’t stop working if some of the jankiest third-party repos I use disappears.

I know the various forjego/gitea/gitlab/… (well, at least some of them - I didn’t check the specifics) have pull mirroring, but I’m looking for something simpler… ideally something with a single config file where I list what to mirror and how often to update and which then allows anonymous read access over the network.

Does anything come to mind?

  • Björn Tantau@swg-empire.de
    link
    fedilink
    English
    arrow-up
    21
    ·
    edit-2
    3 months ago

    A bash script would probably be easiest to write and pluck into cron.

    Edit: Clone all repos you want into one directory and then loop with a script over all cloned dirs and issue git fetch. Done. If you want to add a repo you clone another.

    • shnizmuffin@lemmy.inbutts.lol
      link
      fedilink
      English
      arrow-up
      13
      ·
      edit-2
      3 months ago

      This can be made even simpler by installing all the repos you want to mirror as submodules of the parent directory’s git repository. Instead of many git pull or git fetch, you blast a single git submodule update --recursive --remote and go about your day.


      Bonus: This has the added benefit of generating a git history for your automated process if you script in a commit message with a timestamp, making your mirrors reversible.

  • i_uuuh_what@lemmy.world
    link
    fedilink
    English
    arrow-up
    9
    ·
    3 months ago

    Hey, that’s almost what I made Gire for. It doesn’t support completely anonymous reads though (requires SSH keys for auth).

  • Eskuero@lemmy.fromshado.ws
    link
    fedilink
    English
    arrow-up
    7
    ·
    edit-2
    3 months ago

    Assuming you have all of them under a folder, I just run this lol

    for f in *; do
        echo "$f";
        git -C "$f" pull;
        git -C "$f" submodule update --recursive --remote;
        echo "";
        echo "#########################################################################";
        echo "";
    done
    
  • butitsnotme@lemmy.world
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    3 months ago

    Bash and a dedicated user should work with very little effort. Basically, create a user on your VM (maybe called git), set up passwordless (and keyless) ssh for this user but force the command to be the git-shell. Next a simple bash script which iterates directories in this user’s home directory and runs git fetchall. Set cron to run this script periodically (every hour?). To add a new repository, just ssh as your regular user and su to the git user, then clone the new repository into the home directory. To change the upstream, do the same but simply update the remote.

    This could probably be packaged as a dockerfile pretty easily, if you don’t mind either needing to specify the port, or losing the machine’s port 22.

    EDIT: I found this after posting, might be the easiest way to serve the repositories, in combination with the update script. There’s a bunch more info in the Git Book too, the next section covers setting up HTTP…