(updated: 2016-06-30)
Gogs is a github-like Git service built with Golang.
With Gogs, you can run your own Git service on Raspberry Pi very easily.
0. Prerequisite
A. Prepare a running Raspberry Pi (Raspbian)
You’ve already got one, haven’t you? :-)
B. Install Golang
You can install golang from source code with this script.
It checks out latest code from the repository, build, and install binaries for Raspberry Pi.
Whole processes will take about 1 hour or so.
After installation, add following to your rc file(eg. .zshrc
, .bashrc
, …):
Close your terminal and open a new one, then you will be able to run golang excutables.
You can check your installation with following command:
C. Install other requirements for Gogs
You’ll need to install some more packages before going to the next step.
D. Create a directory for repositories
1-A. Checkout and build latest Gogs source code
If you want to build Gogs from the source code, here is the way: Install From Source Code.
a. If you don’t need SQLite3/Redis/Memcache support,
In your terminal,
b. If you need to enable SQLite3/Redis/Memcache,
1-B. Or, you can download pre-built binary
Download pre-built binary (Linux arm for Raspberry Pi!) from this page: Download
and follow the installation instruction here.
Gogs is nearly ready to run!
But before that, you need to configure some more things up.
a. Setup database (MySQL)
Create a MySQL database for Gogs.
Grant some priviliges to the created database.
b. Edit configuration
Gogs needs some configuration before running.
It recommends (or forces? I’m not sure.) to keep custom config files rather than modifying the default ones directly.
So, duplicate the conf/app.ini
file first.
Now let’s edit the duplicated config file.
(1) user and repository path
Change ROOT to the path of the repository directory which you created above:
(2) database connection
Change username and password for database connection.
(3) run mode
If you want Gogs to be run in production mode, change it.
(4) server configuration
Change domain, port, or other values.
You may also have to generate certificate files as the comment says:
(5) secret key
Change the default secret key for security.
(6) app name
If you want to change the page titles…
(99) others
There are other useful settings like email, oauth, webhook, … etc.
I will try them out soon. :-)
3. Run Gogs
All things up, now Gogs is ready to run!
A. Run in the shell
Gogs can be started from the shell.
If nothing goes wrong, you can connect to Gogs with any web browser.
Connect to the address, eg: http://my-raspberrypi-domain.com:3000.
You’ll meet Install Steps For First-time Run page demanding some check-ups.
When you see complaints about your settings, do as the error message suggests.
If all things are OK, you can login with the username and password which were set in the previous page.
B. Run as a service
You cannot run Gogs from the shell manually everytime, so let’s try to run it as a service.
(1) For init.d
Copy an init.d script file from the source codes:
and edit WORKING_DIR and USER,
and make it run automatically on boot time:
Gogs can now be manually started with sudo service gogs start
and stopped with sudo service gogs stop
.
(2) For systemd
Copy an systemd service file from the source codes:
and edit/add corresponding values,
and make it run automatically on boot time:
Gogs can now be manually started with sudo systemctl start gogs.serivice
and stopped with sudo systemctl stop gogs.service
.
Well done! :-D
99. Wrap-up
Gogs is not only a useful application, but also good to run on Raspberry Pis.
I decided to learn Golang for further use on Raspberry Pi :-)