this post was submitted on 11 Aug 2023
109 points (94.3% liked)

Selfhosted

37924 readers
620 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS
 

Folks,

I'm looking for a self-hosted GitHub alternative that I can just plop into Portainer as a docker-compose and get working.

My main interest is in something that sort of works with GitHub - if there's a way I can pull repos from GitHub into this self-hosted git using a webUI and maybe even push my changes to repos on GitHub, that would be nice. I'm not hard-and-fast on this though as this is mostly an experiment right now and I don't know why I need this.

What are you folks using to host your super secret local code and why?

top 49 comments
sorted by: hot top controversial new old
[–] Anafroj@sh.itjust.works 58 points 11 months ago* (last edited 11 months ago) (1 children)

Obligatory check : are you sure you really need a forge? (that's the name we use to designate tools like Github/Gitlab/Gitea/etc). You can do a lot with git alone : you can host repositories on your server, clone them through ssh (or even http with git http-backend, although it requires a bit of setup), push, pull, create branches, create notes, etc. And the best of it : you can even have CI/CD scripts as post-receive hooks that will run your tests, deploy your app, or reject the changes if something is not right.

The only thing you have to do is to create the repos on your server with the --bare flag, as in git init --bare, this will create a repos that is basically only what you usually have in the .git directory, and will avoid having errors because you pushed to a branch that is not the currently one checked. It will also keep the repos clean, without artifacts (provided you run your build tasks elsewhere, obviously), so it will make all your sources really easy to backup.

And to discuss issues and changes, there is always email. :) There is also this, a code review tool that just pop up on HN.

And it works with Github! :) Just add a git remote to Github, and you can push to it or fetch from it. You can even setup hooks to sync with it. I publish my FOSS projects both on Github and Gitlab, and the only thing I do to propagate changes is to push to my local bare repos that I use for easy backups, they each have a post-update hook which propagates the change everywhere it needs to be (on Github, Gitlab, various machines in my local network, which then have their own post-update hooks to deploy the app/lib). The final touch to that : having this ~/git/ directory that contains all my bare repos (which are only a few hundred MB so fit perfectly in my backups) allowed me to create a git_grep_all script to do code search in all my repos at once (who needs elasticsearch anyway :D ) :

#!/usr/bin/env bash
# grep recursively bare repos

INITIAL_DIR=$(pwd)
for dir in $(find . -name HEAD -exec dirname '{}' \;); do
  pushd $dir > /dev/null
  git grep "$*" HEAD > /dev/null
  if [[ "$?" = "0" ]]; then
    pwd
    git grep "$*" HEAD
    echo
  fi

  popd > /dev/null
done

(note that it uses pushd and popd, which are bash builtins, other shells should use other ways to change directories)

The reason why you may still want a forge is if you have non tech people who should be able to work on issues/epics/documentation/etc.

[–] otl@lemmy.sdf.org 2 points 11 months ago

And sharing changes can be done with just email and regular git! https://git-send-email.io

[–] Dirk@lemmy.ml 54 points 11 months ago (3 children)

Have a look at Forgejo which is a soft fork run by a nonprofit organization of Gitea which is owned by a for-profit company.

https://forgejo.org/

It need very little system resources and still gives you all the common features you know from commercial Git hosting providers.

And yes, you can mirror existing Git repos using a web UI.

[–] thecam@lemmy.world 12 points 11 months ago (2 children)

I also recommend forgejo. They are also working on adding a federation feature to forgejo just like Lemmy has!

[–] Anafroj@sh.itjust.works 2 points 11 months ago

It's coming to Gitlab too! (although, this will take quite some time)

[–] lambda@programming.dev 1 points 11 months ago (1 children)

What does federation do here? Will it sync repos? Or just users and comments?

[–] thecam@lemmy.world 0 points 11 months ago

I imagine users, comments and perhaps pull requests.

[–] pe1uca@lemmy.pe1uca.dev 9 points 11 months ago

And forgejo runner is basically github actions, I just started automating a lot of my personal projects. (it's in alpha state, but my basic actions haven't had any problems)

[–] onelikeandidie@lemmy.world 4 points 11 months ago

I also recommend forgejo, I've been using it for a while for my personal projects and the ui is still beautiful while being a simple git server at the same time.

[–] ratz@chatsubo.hiteklolife.net 46 points 11 months ago (1 children)

What? Gitea. Gitlab is a complete devops platform. Awesome, but complete overkill.

Why? Because I regularly commit code atrocities and have a hard enough time dealing with imposter syndrome, I don't need to add public shaming on top of it (And just data sovereignty I guess)

[–] ErwinLottemann@feddit.de 4 points 11 months ago (2 children)

Gitlab can be registration only, so noone else can see your code crimes (when self-hosted)

[–] Bakkoda@sh.itjust.works 4 points 11 months ago (1 children)

Code crimes. It's kind of a weird feeling to not know you are guilty of something until you see a name for it.

[–] ErwinLottemann@feddit.de 3 points 11 months ago

No worries! I wasn't judging 😬

[–] misterzero@lemmy.world 2 points 11 months ago (1 children)

If people could see my code crimes, I would be in code jail for life.

[–] ShunkW@lemmy.world 1 points 11 months ago

I'm sure I've committed many code crimes. But the one that should send someone to jail that I've personally seen was when I found an eval in production code that was actively being exploited. Put up a PR to fix it and was given a very hush hush meeting that it was there intentionally to fix production data issues secretly because the bureaucracy made it hard to do lol. I just kept my mouth shut and eventually used it once myself.

[–] cancanman@lemmy.world 26 points 11 months ago (1 children)

I'm using GItea and it's been working great. Very easy to set up in docker.

[–] Rearsays@lemmy.ml 4 points 11 months ago (2 children)
[–] nebs@lemm.ee 1 points 11 months ago

Why instead of gitea though? I thought the “for profit” stuff was only to provide the original developers of gitea the ability to provide paid support to commercial clients.

[–] fnv@lemmy.ml 0 points 11 months ago (1 children)

Unfortunately not available on TrueNAS

[–] Rearsays@lemmy.ml 3 points 11 months ago (1 children)

Everything is you just must first learn docker

[–] fnv@lemmy.ml 1 points 11 months ago* (last edited 11 months ago)

Heh, I was running linux with docker on top of Trunas for several months because of Jellyfin was not available to run in jail. I was not happy because it wasted the server resources and also my resources to maintain it. I don’t want go such way again.
Happy running gitea in jail and when forgejo will be also available in jail I will probably move to its.

[–] Vilian@lemmy.ca 21 points 11 months ago (1 children)
[–] herrvogel@lemmy.world 6 points 11 months ago* (last edited 11 months ago) (1 children)

And is hilariously overkill for what OP seems to want. It's a pretty large and heavy package that comes with a whole lot of (for OP unnecessary) features.

[–] andrew@lemmy.stuart.fun 3 points 11 months ago

My experience was that they were definitely overkill until they weren't, and I was glad to be comfortable in the UI when I wanted to start playing with more advanced features. Something like the sameersbn/gitlab docker image can get you started and grow with you a ton.

[–] OddFed@feddit.de 17 points 11 months ago
[–] newIdentity@sh.itjust.works 16 points 11 months ago

GitLab or GitTea

[–] dandroid@dandroid.app 15 points 11 months ago

What are you folks using to host your super secret local code and why?

This obviously doesn't help for the rest of your question, but for anything that I don't want to open source for whatever reason, I just make a bare repo and push it to a folder on my server that has all my bare repos. Literally just git server on my LAN. Nothing fancy. No UI or anything, but I don't use a UI for git anyway.

If you don't have a server at home, you could do the same thing but to a folder on your local machine. That obviously means you will have no backup. But you will still have version control in case you want to revert something you did or refer back to an old version.

[–] russjr08@outpost.zeuslink.net 13 points 11 months ago (2 children)

I currently use GitLab, but if I were doing things from the start I'd go with Gitea or Forgejo since its lighter. Though I do quite like GitLab CI (which is why I didn't go with the other initially) but these days I hear Gitea has Actions support built in.

[–] domi@lemmy.secnd.me 3 points 11 months ago

I'm in the same boat. GitLab CI is so nice that I still host it, even if everything else is overkill.

[–] ErwinLottemann@feddit.de 2 points 11 months ago

Gitlab also has issues, error tracking via sentry and much more. If you want only something nice to host your code go with Gitea, if you also want to manage your project or do auto releases, use gitlab.

[–] 520@kbin.social 13 points 11 months ago (1 children)

Gitlab can do what you need

[–] krnl386@lemmy.ca 9 points 11 months ago

That’s a pretty hefty solution. Gitlab is a monster nowadays…

GOGS, Gitea/Forgejo can do 90% of what Gitlab does and are much lighter.

[–] nimmo@lem.nimmog.uk 11 points 11 months ago

I personally use gitea but there is also a community version of gitlab that has way more power than I need.

Gitea can import a repo from GitHub but I don't know whether it can also push updates out as one never tried to do that.

I picked gitea as I didn't need all of the extra power of gitlab and they were the first two options I found. I don't deploy it using portainer but all of my stacks are set up as git repos in portainer and using the webhook feature it'll auto pull and redeploy whenever I push to it

[–] mariom@lemmy.world 11 points 11 months ago

Forgejo. Gitlab will be overkill probably.

[–] mholiv@lemmy.world 9 points 11 months ago

+1 For Gitea. Works really well for me. It recently added GitHub style actors so you can use GitHub style CI/CD too!

[–] philuk@discuss.tchncs.de 9 points 11 months ago (1 children)

https://about.gitea.com/ is a great lightweight alternative that’s heavily inspired by GitHub.

[–] melchiorbv@lemm.ee 2 points 11 months ago

I self-host Gitea and is pretty lightweight and low maintenance. Great solution!

[–] unscholarly_source@lemmy.ca 9 points 11 months ago (1 children)

Gogs and Gitea are git alternatives that offers GitLab features with less system resource demands.

Though, it would be good to understand your use case, whereby a GitHub private repository would not be suitable...

[–] schmurian@lsmu.schmurian.xyz 7 points 11 months ago (1 children)

It now also comes with Gitea Actions and the Act Runner - in case this feature is relevant to you.

[–] damnthefilibuster@lemmy.world 2 points 11 months ago (1 children)

Wow, no one till now mentioned Gitea has a runner and actions. Thanks!

[–] schmurian@lsmu.schmurian.xyz 2 points 11 months ago* (last edited 11 months ago)

Yeah, I don‘t know if they have finally anounced it officially, but they mentioned it in their blog post in March. I‘ve installed it, and it works quite well for my usecase.

[–] anzo@programming.dev 9 points 11 months ago (1 children)

onedev.io wasn't mentioned.

Also, be aware that gitea was forked by the community into forgejo because of reasons.

[–] wer2@lemm.ee 1 points 11 months ago

I have liked onedev so far.

[–] liliumstar@lemmy.dbzer0.com 8 points 11 months ago

Another +1 for gitea. It works quite well and is easy to setup.

[–] blackbarn@lemm.ee 8 points 11 months ago

I'm using Gitea. Pretty simple and a decent feature set.

[–] mhzawadi@lemmy.horwood.cloud 3 points 11 months ago

Without knowing why you need a local GitHub like tool is almost impossible to suggest, but I know Gogo's can keep a remote in sync if you need. Also there is a python tool to backup your GitHub account and or organisation

[–] nbafantest@lemmy.world 3 points 11 months ago

I'd probably just run gitlab and use the gitlab images, as that's one of the solutions git recommends

[–] Aux@lemmy.world 3 points 11 months ago

Why do you want that? Plain git can do everything you actually need.

[–] skimm@lemmy.sdf.org 2 points 11 months ago

Since I haven't seen it mentioned yet, I've been using Soft Serve on my server. Just a git server with terminal UI and easy to manage.