Host your Git on Glitch with Gogs

Melissa McEwen - Jan 22 '20 - - Dev Community

Can it run on Glitch? That’s the question I ask myself every time I see someone mention a cool open source software project. A month or so I saw some discussion of Gogs, a self-hosted git service. It's basically a DIY version of GitLab, Bitbucket, or Github.

The catch? Gogs runs in Go. While Glitch can support almost any language, most of our features are tailored for Node.js. So I was really curious if I could get it to run. We have a couple of sample Go projects like go-example and go-glitch-sample. To make a Glitch app use Go, you put in a special file called glitch.json. It tells Glitch that instead of running the default “npm start” when you open your project, to run whatever is defined as “start” in glitch.json

TFW errors 😱

I installed Gogs from binary1. And it seemed to work ok. But I hit a snag. There were so many directories in the project that they made the Glitch editor load much slower. So I hid them. To do this I moved to directories with a dot prefix like like “.scripts”. Voila, my Glitch project was much faster.

Then I tried installing and I got a weird error message “Run user isn't the current user: app ->” which didn’t give me much to go on. I tried a lot of random things and nothing worked. I finally went into the gogs codebase and found the line that error came from. It expected an environment variable called USER. I changed my start command in glitch.json to set that.

Our shiny new Gogs ✨

Gogs has many of my fav git hosting features like pull request reviewing and a visual interface for exploring the code and commits.

exploring the features of gogs

It has some great features including:

  • pull requests with a visual interface
  • issues
  • wikis
  • forking

Try it yourself? 🌠

I wanted to make this easy to “remix” which is a Glitch term for getting your own copy. So I added some files and directories to a file called .gitignore, so you won’t get my repositories when you get your own copy. I haven’t gotten email notifications working yet, but I might try Sendgrid for that.

If you try it out let us know what you think in the comments!


Footnotes:

  1. I had to extract the binary on my own computer because it took up a lot of space. I used the 64 bit Linux one from here.. Then uploaded to Glitch. Because binaries end up in the assets section on Glitch, I got the URL from the assets. Then I used wget asset-url. Finally I ran chmod +x asset-file
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .