This is very similar to Github or Gitlab, this is Gogs. Demo

Required:

  • A running raspberry Here
  • The internet box should seta static local IP for the Pi
  • The ports 3000 on your internet box should be opened and rooted to your Pi.
  • The public IP of your internet is probably dynamic... Solution

 

 

Install the database 

sudo apt-get install mariadb-server mariadb-client -y 

sudo systemctl stop mariadb.service 

sudo systemctl start mariadb.service 

sudo systemctl enable mariadb.service

Please feel all general infos for MariaDB configuration and don't forget the user and the password for root!! (press Y for all)

sudo mysql_secure_installation

Then restart:

sudo systemctl stop mariadb.service

sudo systemctl start mariadb.service

sudo systemctl enable mariadb.service

 

Install Git

sudo apt-get install git -y

Install Gogs

cd /opt

sudo wget https://dl.gogs.io/0.11.91/gogs_0.11.91_raspi_armv7.zip

sudo unzip -o gogs_0.11.91_raspi_armv7.zip

sudo rm gogs_0.11.91_raspi_armv7.zip

 

Configure Gogs

adduser --disabled-login --gecos 'Go Git Service' git

chown -R git:git /opt/gogs > nano /opt/gogs/scripts/systemd/gogs.service

In /opt/gogs/scripts/systemd/gogs.service, please remove the previous content and copy this one: 

[Unit] 

Description=Gogs 

After=syslog.target 

After=network.target 

[Service] 

Type=simple 

User=git 

Group=git 

WorkingDirectory=/home/git/gogs 

ExecStart=/opt/gogs/gogs web 

Restart=always 

Environment=USER=git HOME=/home/git 

[Install] 

WantedBy=multi-user.target

sudo -H -u git mkdir /home/git/gogs

 

Create the database

mysql -u root -p < /opt/gogs/scripts/mysql.sql

Connect to MariaDb: please provide the main mariaDb password !!!"

mysql -u root -p

And copy this (replace m_password by your database password):

SET GLOBAL innodb_file_per_table = ON;

CREATE DATABASE gogsdb;

CREATE USER 'gogsuser' IDENTIFIED BY 'm_password';

GRANT ALL ON gogsdb.* TO 'gogsuser'@'localhost' IDENTIFIED BY 'm_password' WITH GRANT OPTION;

ALTER DATABASE gogsdb CHARACTER SET = utf8mb4 COLLATE utf8mb4_unicode_ci;

FLUSH PRIVILEGES;

SHOW DATABASES;

select user, password, host from mysql.user; 

 

Start gogs service

sudo systemctl enable /opt/gogs/scripts/systemd/gogs.service

sudo systemctl start gogs.service

You can test it: http://localhost:3000

sudo systemctl status gogs.service