Use your Synology to host Gitea under Docker and run your own GIT server.
Why host your own? Because you can have local performance and unlimited private repositories. Or you simply want to keep your stuff hosted on your server and under your control.
This example is on Gitea, but other GIT server deployments are available of course - as installs directly onto your Synolgoy DSM (or any Linux server), and more easily as their own Docker images.
Why Gitea? The main reason is that it is easy and it has very low minimal requirements so is suitable for a low spec server such as a NAS. Also, it does just work.
Setup as follows:
- From the Docker app on your Synology in Registry find
gitea/giteaand download the image (105Mb)
- On the image tab select that download and click
launchto create a new container.
Advanced settingsselect the following:
Volumecreate a new folder on your NAS (probably somewhere under /volume1) and have it mounted as
Port Settingsmap some local port (I chose 3022) to port 22 in the container (for ssl) and local port 3000 to container port 3000 for main website browsing. Choose other local ports if those already taken.
- Under environment you should see
GITEA_CUSTOMalready set to
/data/giteawhere it will store all its stuff -- hence the need to provide that file mapping to a directory on your main Synology volume.
The instance is now running and you should see it listed under
Containertab. Double click to bring up the container properties dialog - not much to see or do here but it shows its running. The
terminaltab will do nothing as Gitea doesn't support a ssh terminal.
- You can browse to the running Gitea with something like nas.local:3000 i.e. browing to port 3000 on your NAS at nas.local and then port reditected 3000 to 3000 for web browsing.
- Go through the setup options -- give your site a title but I leave everything much as the default. The last setup option is for an admin account, but it says 'Creating an administrator account is optional. The first registered user will automatically become an administrator.' so leave it blank.
- Click the
Install Giteabutton and wait
- After the setup the page refreshes to
http://localhost:3000/user/loginbut that only make sense if you were on the hosting server itself. Instead change the url you the redirected port on your NAS, in my example
- You should now see the Sign In page to register the first user, who will become admin also. Use your enail address
- After setup, you should see a Gitea welcome page until you've created your first repository - then it starts to look and feel a bit like Github
You will still need to get ssh working in order to use Git from your development workstation using the
git: syntax for repos access. The steps for ssh access to the Synology in summary:
- Create your own key pair and save the public key in the
settingsof your account on the Gitea profile admin (which will write it to the .ssh/authorized_keys file on the Gitea server).
- Save the private key (and you keep this bit secret of course) in your .ssh/config folder - typically as the file id_rsa if that's the sort of key you created.
- I also like to use the
.ssh/configfile to create a alias especially if port if not the standard for ssh. For this scenario, accessing Gitea setup as above, we'll have something like:
Host git.nas HostName nas.local Port 3022 User git
git.nasis the alias name I want to use,
naslocalis the actual hostname for the Synology running Docker running Gitea - or it could be your NAS IP address of course - and
3022is the port redirection we specified in the container setup mapping to port 22 on the running instance.
You can then test this using
ssh git.nas . It wont work by giving you a shell prompt BUT it will give a message indicating all the ssh stuff is ok and you connected:
PS C:\Users\yourname> ssh git.nas PTY allocation request failed on channel 0 Hi there, yourname! You've successfully authenticated with the key named yourname@DESKTOP-1234, but Gitea does not provide shell access. If this is unexpected, please log in with password and setup Gitea under another user. Connection to nas.local closed.
NOW you are ready to create your first repos on your GIT server.
On the Gitea website dashboard, log in and click "+" to create a repository. Things tend to just work better if you create a empty repository on the server first - Gitea gives you handy options for a
.gitignore and a licence file. Go to your local workstation, cd to the repository root directory and clone it...
PS C:\Users\yourname\source\repos\test1> git clone email@example.com:yourname/test1.git
If you want to start with a local repository and just push it, then on your dev workstation, in a command prompt, cd to the directory you want to upload and create a local GIT repos (or of course, use one you prepared earlier)
PS C:\Users\yourname\source\repos\test1> git init PS C:\Users\yourname\source\repos\test1> git add . PS C:\Users\yourname\source\repos\test1> git commit -m "Initial Commit" PS C:\Users\yourname\source\repos\test1> git remote add origin firstname.lastname@example.org:yourname/test1.git PS C:\Users\yourname\source\repos\test1> git push --set-upstream origin master