How I installed Gogs home Git server on Alpine linux

"It is dangerous business, Frodo, to go beyond the threshold: it is worth setting foot on the road and, if you give free rein to your feet, it will take you no one knows where." 





(c) The Lord of the Rings: The Fellowship of the Ring





How it all started

I wanted to get myself a home Git server to practice developing and deploying pet projects. Plus, it's calmer when your work is not only on github.





Alpine linux, . . , , .





Proxmox 6.1-3, Alpine  (template) - Alpine Linux 3.12 Kernel 5.3.10-1-pve on an x86_64.





Git- . , . git-, . Gogs.io.





:





  1. , .. ;





  2. Golang - ;





  3. ;





  4. .





. :





  • - 4 x AMD Ryzen 3 1200 Quad-Core





  • - 8





  • - SSD ZFS





1-2 . . , 1-2 git- , 512 8 .





Alpine

Alpine Proxmox . . , . , .





, . Alpine :





alpine:~# apk search zabbix
      
      



:





alpine:~# hostname gogs-githost
      
      



openssh nano , ssh:





gogs-githost:~# apk add openssh nano
      
      



:





gogs-githost:~# rc-update add sshd
      
      



/etc/ssh/sshd_config :





...
Port 22
PermitRootLogin yes
...
      
      



, :





gogs-githost:~# /etc/init.d/sshd start
      
      



Gogs

Alpine Gitea. , . git- :





gogs-githost:~# apk add gogs
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/8) Installing ca-certificates (20191127-r4)
(2/8) Installing nghttp2-libs (1.41.0-r0)
(3/8) Installing libcurl (7.69.1-r3)
(4/8) Installing expat (2.2.9-r1)
(5/8) Installing pcre2 (10.35-r0)
(6/8) Installing git (2.26.3-r0)
(7/8) Installing gogs (0.11.91-r1)
Executing gogs-0.11.91-r1.pre-install
(8/8) Installing gogs-openrc (0.11.91-r1)
Executing busybox-1.31.1-r19.trigger
Executing ca-certificates-20191127-r4.trigger
OK: 89 MiB in 38 packages
      
      



, gogs , git. :





gogs-githost:~# gogs web
2021/03/18 20:13:42 [ WARN] Custom config '/usr/bin/custom/conf/app.ini' not found, ignore this if you're running first time
2021/03/18 20:13:42 [TRACE] Custom path: /usr/bin/custom
2021/03/18 20:13:42 [TRACE] Log path: /usr/bin/log
2021/03/18 20:13:42 [TRACE] Log Mode: Console (Trace)
2021/03/18 20:13:42 [ INFO] Gogs 0.11.91.0811
2021/03/18 20:13:42 [ INFO] Cache Service Enabled
2021/03/18 20:13:42 [ INFO] Session Service Enabled
2021/03/18 20:13:42 [ INFO] SQLite3 Supported
2021/03/18 20:13:42 [ INFO] Run Mode: Development
2021/03/18 20:13:42 [FATAL] [...gogs/gogs/cmd/web.go:66 checkVersion()] Fail to read 'templates/.VERSION': open /usr/bin/templates/.VERSION: no such file or directory
      
      



, . /usr/bin, gogs.





. .





- Gogs Linux. Gogs, , Alpine:





gogs-githost:~# gogs -v
Gogs version 0.11.91.0811
      
      



. /opt Alpine:





gogs-githost:/opt# wget https://dl.gogs.io/0.11.91/gogs_0.11.91_linux_amd64.tar.gz
      
      



:





gogs-githost:/opt# tar -xvf gogs_0.11.91_linux_amd64.tar.gz
      
      



, , . gogs:





gogs-githost:/opt# chown -R root:root gogs
      
      



(: , - Alpine mysl, ):





gogs-githost:/opt/gogs# ./gogs web
-ash: ./gogs: not found
      
      



gogs Alpine :





gogs-githost:/opt/gogs# cp /usr/bin/gogs gogs
      
      



! -. …





, “ !” . , Alpine, . , , .





- Alpine () . gogs Alpine.





- , . - . , gogs- :





gogs-githost:~# gogs web -c /etc/gogs/conf/app.ini
2021/03/20 19:22:47 [TRACE] Custom path: /usr/bin/custom
2021/03/20 19:22:47 [TRACE] Log path: /var/log/gogs
2021/03/20 19:22:47 [TRACE] Log Mode: File (Info)
2021/03/20 19:22:47 [ INFO] Gogs 0.11.91.0811
      
      



-, -.





, . GUI, , bash. 





, . , - /etc/init.d/gogs, :





#!/sbin/openrc-run
name=gogs
conffile="$GOGS_CUSTOM/conf/app.ini"
command="/usr/bin/gogs"
command_args="web -c $conffile"
start_stop_daemon_args="${GOGS_USER:+--user} $GOGS_USER --env GOGS_CUSTOM=$GOGS_CUSTOM"
pidfile="/var/run/gogs.pid"
command_background="yes"

depend() {
        use logger dns
        need net
        after firewall
}
      
      



:





#!/sbin/openrc-run

name=gogs
conffile="/etc/gogs/conf/app.ini"
command="/usr/bin/gogs"
command_args="web -c $conffile"
start_stop_daemon_args="${GOGS_USER:+--user} root --env GOGS_CUSTOM=/etc/gogs"
pidfile="/var/run/gogs.pid"
command_background="yes"

depend() {
        use logger dns
        need net
        after firewall
}
      
      



, - (, -). Alpine?





, ! , . , openssh.





I decided to check again - I cloned a container with Alpine and already configured ssh. And then everything turned out to be very simple:





alpine:~# apk add gogs
alpine:~# rc-update add gogs
 * service gogs added to runlevel default
alpine:~# /etc/init.d/gogs start
 * Starting gogs ...                                                                     [ ok ]
alpine:~# rc-status
Runlevel: default
 networking                                                                    [  started  ]
 sshd                                                                             [  started  ]
 crond                                                                            [  started  ]
 gogs                                                                             [  started  ]
      
      



This is really enough to get your Git server up and running (if you're happy with the SQLite database). Now you can go to the web interface, for me it was http://192.168.50.205:3000, and make basic settings.





Conclusion

With this article, I want to highlight the importance of Linux documentation and skills. Most likely, experienced Linux users immediately understood what was the matter and laughed heartily at my amateurism. Well, now it's funny for me myself how winding my path was =).





But the truth is also that I did not find a simple help on expanding the gogs package on the Alpine. I hope my article will be useful to those who think of something like this.








All Articles