Synology Diskstation Self-hosted Git: Migrate From GitLab to Gitea Setup
Articles,  Blog

Synology Diskstation Self-hosted Git: Migrate From GitLab to Gitea Setup


Welcome to the Grok Shop! In this video
I’ll show how to deploy Gitea on your Synology Disk Station. In addition, if you
run the prepackaged GitLab or the manual GitLab in order to get a more
recent version of GitLab I’ll show how to migrate from that. So, why not use GitLab?
well take a look: the resource usage of GitLab lab is pretty much horrendous.
It’s based on Ruby and unfortunately it’s a very inefficiently written
package. It’s beautiful; it looks great; but as you probably know, it can be very
slow; uses loads and loads of RAM and a good bit of CPU as well. So, for these
reasons I decided I needed to move to something more lightweight as opposed to
upgrading my RAM. Of course, you can always upgrade your RAM. But I might save
that for later. But for now I’m just going to fix the root cause of my memory
shortage. I have the DS 1815+, which comes with 2 gigabytes of RAM. And, as you
can see it’s getting taxed pretty hard; mainly from Gitlab. when it gets like
this, you’re gonna be getting into swap and you’ll see your drives thrashing
around and everything just pretty much grinds to a halt. So let’s get right to
it. I’ll put all the pertinent links below for you. “flipswitchingmonkey” is
the Github we want to hit up. Go there, copy the link. Since Synology doesn’t provide a package for Gitea, we’ll be building our own. so
using the link we just copied we’ll go ahead and clone that repository okay next we’re going to hit up the
Synology architecture GetHub on here we can figure out what the architecture
is for our CPU see 1815 for me is an avatar which is amd64 architecture
should be pretty obvious for you to figure it out from here what your
architecture is and of course we’re building for Linux so if you’re looking
for the Linux amd64 latest Gitea ok go ahead and copy that link and head to
your gatita spk folder and to a double you get on that binary get that to the
local folder we’re gonna create our sbk package around this binary if you happen
to download the wrong binary it may fail if you get the one for the wrong OS it
may not fail if you get the one for the wrong architecture but you’ll find out
when you try to install it on the Synology it’ll fail at that time anyway
and if you do download the wrong one remove the old one and then run the
create under spk shell script and should be good to go since I’m doing this on a
box separate from my Synology box I’ll just need to make the package available
in a folder that I can get to from the browser okay so now we want to open up
the package center and go to the manual install button click that now just
browse to the folder where your package is and select the package we just built never hurts to have more logs okay with the install done you should
see your Gitea icon in your packages area so you go ahead and click the icon
it should send you to your browser and port 3000 which is the default port
everything should just fire right up now for everything to work right you need
Git server and a database mariya DB is really the only package databases that
Synology supports so i’ll go ahead and try to get this going for it as you’ll
see there are some problems with Maria DB depending on what kind of collation
you use if you’re a Postgres fan I got good news for you just keep watching
that’s what I’ll end up using after I go through this big rig Moreau
for an initial Maria DB setup we need to set the default password okay now circularly optional you can use
phpMyAdmin to connect to the database I’ll use the root account admin and
password I just created it’s now we need to set up a database
called Gitea you need to select the coalition I need utf-8 now I’m Maria DB
and MySQL the thing about it is utf-8 is not really utf-8 to use real utf-8 we
need to use utf-8 MB for in the collation and this is where the problems
began so before going on I want to point out that Synology supports Maria DB 10
and Maria DB 5 Maria DB 10 is generally better overall and I would recommend
using that if you’re going to use Maria DB and to be clear you can use Maria DB
it’s only really a problem if you use the collation that I was just showing
you and I’ll explain that more here in a minute so even though Synology tends to have
sort of outdated packages definitely go ahead and update whatever packages you
are going to be using so the reason I had deployed both Maria db5 and Randy be
tennis because I just wanted to see that this problem existed in both and go
ahead and select which database you want to use with your PHP my I’m in I got to
go ahead and switch over to ten here and just go right back through the database
creation process here’s the SQL to get the port number for Maria DB I can see
is three three oh seven now we need to create the Gitea user okay back in the browser if you click on
register’ it’ll take you to the initial configuration data injuries you can set
up the database here remember we’re on port 3 307 Maria DB is a MySQL database
type be sure to enter in your username and whatever passwords you set up in here you can also set up the site
title repo path SSH port HTTP port for the website and lock path etc when
you’re ready click install gattie and basically it’s going to try to set up
the database and here you can see there’s a failure the database settings
are invalid the specified key was too long max key length to 767 bikes so with
a little digging I was able to find out what’s going on if you look at the
second paragraph grew up again it’s a 767 byte limit and divided by 4 if
you’re using utf-8 and before is a hundred and ninety-one characters per
field and apparently that’s not enough for Katti now with newer versions of
MySQL 5.7 and higher and 10.2 and higher for Maria DB the max has been increased
but unfortunately Synology does not support the latest I did open a ticket
on this maybe they’ll be updating their Maria DB version soon but who knows how
long that might take right so you may have noticed Synology does not have a
close grass package the reason for that is they use Postgres for their own
system but there’s a way around that and that’s to use docker if you use the
manual Gitlab you may have already played around with this some now the
Synology GitLab package will run against Maria DB whereas the manual GitLab
will typically run against Postgres and a docker so here you can see I had
the manual GitLab package all set up it runs GitLab Postgres and Redis all
inside Dockers how if you watch the resource monitor when I turn GitLab off
you’ll see huge drops in the amount of RAM and CPU used so now if you want to run Postgres and
docker you need to make sure you don’t conflict with Postgres outside of the
docker and mainly you want to make sure you have separate ports here you can see
the built in Postgres is on port five four three two and it’s Postgres 9.3 dot
twenty two so the manual Gitlab is set up with a composer or yamo file what I’m
gonna do now is I’m going to adjust CD into the folder where that composer file
is and manually edit that to remove GitLab and Redis and leave the Postgres
behind so here you can see the before and the
after the DB username and password are all masked out no a for stalker to rien
Heil that Yemen now I could see only the post grass docker is running now note
the port map which follows the ammo config you can see with the Redis and
GitLab containers removed even though I have Maria DB still going it’s looking a
little better already we can get to the Postgres command line like so
and just a quick check of the version here says it’s a 9.6 dot one the Linux
box I’m running here is Debbie an 8-hour Jessie and PG admin for doesn’t install
on that d strove release so installed PG admin 3 an updated version which will
talk to this version of Postgres of course you don’t need PG admin you can
do it all from the command line if you want it’s just nice to have that tool
available now we’ll go ahead and set up the Gitea user and database in the
containerized version of Postgres connecting and PG admin can see the new
database as well as the old Gitlab database and notice that there’s no
tables yet in the Gitea database whereas of course the tables from the Gitlab
database are there so the way post Chris does correlations a little different
from Maria DB it’s actually based on the operating system that you’re in in this
case the docker container and there’s no languages set up are there’s no locale
set up right now to collate against you can just see it’s defaulted to C which
is the ANSI C standard byte order collation which is fine for me for now
now in Postgres when you say utf-8 it’s really UTF a and it’s not like Maria DB
but you do need to set the collation up when the DB is a knitted in this case it
was already a knitted so you could always export read and it the DB and
then import your database if you want to change the default collation or you can
just do your collation on per query basis after you have your locale set up
and your coalitions set up against those locales
so notice I set the port up on the web page per the port mapping I set in the
animal file 54:33 and now we can just plug in our password for the T user in
the database and after clicking the button finally no more errors and the
tables are all built out so now go ahead and register a new
account in Gitea then I’ll just sign in with that same account the first account
that you register is by default the admin account of course you can upgrade
other accounts to admin status after that and it looks like our resource
needs are staying nice and low I don’t know how y’all roll but I like to do
SSH when I do Git so I’m just gonna go grab a key that I already have in my .
ssh folder and i’m going to put that key into the manage key area so I’m gonna go ahead and set up my
repository labels these are repositories of course that exist on my local machine
I just need to set up a label and basically a container to push the
repository into this will be this is a website that I built for my wife and
it’s called good morning Vietnam and we’ll see how we can get this set up
here if you’re gonna be creating a new local repository you can use these
commands that they give you of course since mine exists already they
won’t really be all that useful you could take the URL that they give you
and run the git remote set URL origin giving it the URL that they provide
there and that will set it up and your Git file but since I’ll be using SSH
that’s not really the right format for me anyway so I’m gonna go in and edit my
Git config here and manually change it to the SSH format like so you do need to
edit the app dot ini which is in this path shown here to contain the right SSH
config parameters like the port the the server start SSH server to true and the
listen port and the domain set them all up like so once you’ve got all those set
up you can just restart the Katti server after the server restarts you should be
able to do a push and your repository should show up in the server on the
browser now like so and resources nice and light that’s how
it’s done thanks for watching

6 Comments

  • Dude with a Drone

    Hey Grok, This was great until it got to Docker. That's one package that can't be installed on a DS216J. Yeah I'm a cheapskate. I'll see if Postgres can be installed another way.

  • Tony Tony

    Thank you for this great video. I had no problems configuring gitea on my synology with MariaDB10. I suspect they fixed it after your raised an issue. I was confused a bit trying to figure out the architecture of my DS1517+. Based on what I found my synology has an Intel Atom C2538 /Avoton. I though I should use the 386 file but I had to use the amd64 one. I was able to expose the gitea outside my network, but I am not sure how to make it https. Any ideas? I do have a domain name that I pointed to my synology (https://syno.example.com:2000) and I can hit the gitea at (http://syno.example.com:2001) but not https. My certs are from lets encrypt.

  • The Grok Shop

    UPDATE: It appears Synology has updated the MariaDB10 package recently. Check the package rev on you rsystem to see if its 10.3 or greater. If so, I'd recommend using MariaDB over Postgres in a Docker, just to remove the extra layer of configuration complexity.

  • Danny A

    I't tells me that the package can not be installed because it's not supporter or the DSM is not supported (DSM 6.2). i'm having a 214Play and compile with the linux-386.
    Is DSM 6.2 supported?

Leave a Reply

Your email address will not be published. Required fields are marked *