«C'est une affaire dangereuse, Frodon, de dépasser le seuil: cela vaut la peine de mettre le pied sur la route et, si vous laissez libre cours à vos pieds, vous ne saurez pas où vous serez conduit.
(c) Le Seigneur des Anneaux: La Communauté de l'Anneau
Comment tout a commencé
Je voulais me procurer un serveur Git domestique pour m'entraîner au développement et au déploiement de projets familiers. De plus, c'est plus calme lorsque votre travail n'est pas uniquement sur 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.
:
, .. ;
Golang - ;
;
.
. :
- 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
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-githost:~# gogs -v
Gogs version 0.11.91.0811
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.
J'ai décidé de vérifier à nouveau - j'ai cloné un conteneur avec Alpine et déjà configuré ssh. Et puis tout s'est avéré très 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 ]
C'est vraiment suffisant pour que votre serveur Git soit opérationnel (si vous êtes satisfait de la base de données SQLite). Vous pouvez maintenant accéder à l'interface Web, pour moi, c'était http://192.168.50.205:3000 et effectuer les réglages de base.
Conclusion
Avec cet article, je veux souligner l'importance de la documentation et des compétences Linux. Très probablement, les utilisateurs Linux expérimentés ont immédiatement compris ce qui se passait et se sont moqués de mon amateurisme. Eh bien, maintenant, c’est drôle pour moi à quel point mon chemin était sinueux =).
Mais la vérité est aussi que je n'ai pas trouvé d'aide simple pour étendre le paquet gogs sur l'Alpine. J'espère que mon article sera utile à ceux qui pensent à quelque chose comme ça.