Skip to content

Commit aa708f4

Browse files
53845714nF53845714nF
authored andcommitted
Translate Gitea and new Thump
1 parent d64cc6a commit aa708f4

File tree

4 files changed

+161
-11
lines changed

4 files changed

+161
-11
lines changed

content/blog/gitea/img/gitea.webp

353 KB
Binary file not shown.

content/blog/gitea/index.en.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
title: "Gitea 🍵"
3+
date: 2022-08-08T20:03:02+02:00
4+
draft: false
5+
hideLastModified: true
6+
summaryImage: "img/gitea.webp"
7+
keepImageRatio: true
8+
summary: "Setting up your own Git service. And the migration from Alpine to Debian."
9+
showInMenu: false
10+
tags: ["Programming", "Git", "Home Lab", "DevOps"]
11+
---
12+
13+
## Introduction to Git
14+
15+
Git is currently the dominant version control tool in the market.
16+
The main idea behind it is to manage the state of various versions of source code.
17+
A full Git tutorial would be too lengthy for a blog post, so instead, I'll point you to a good resource.
18+
The comprehensive manual available at: [Pro Git Book](https://git-scm.com/book/en/v2).
19+
20+
Another key feature of Git is that it's a distributed system.
21+
It allows every user to create their own repository and sync it with others.
22+
However, it's common practice to have a central server where the main repository is hosted.
23+
These servers often come with a simple web UI to facilitate interactions with the repository.
24+
The largest platform for this type of software is [GitHub](https://github.com/), but there are others like [GitLab](https://about.gitlab.com) and [Gitea](https://gitea.io/en-us/).
25+
26+
## My Experience with Gitea 🕰️
27+
28+
The first service I installed on my home server was Gitea.
29+
30+
It's lightweight, consumes minimal resources, and its web interface is quite user-friendly, making it the perfect choice for me.
31+
My initial Gitea installation ran inside an LXC container with Alpine Linux.
32+
Using Alpine’s package manager, installing gitea was straightforward.
33+
34+
However, I aim to create a homogeneous server environment, meaning all servers should run Debian 11 on LXC.
35+
As a result, the Alpine container had to go, and I needed to migrate my Git server.
36+
37+
Unfortunately, Gitea doesn’t provide a pre-packaged solution for Debian, so the installation is a bit more complex compared to Alpine.
38+
Gitea is written in [Golang](https://go.dev/), and they provide a static-linked binary that you can download, but the rest requires some manual setup by the admin.
39+
40+
## Installing Gitea on Debian
41+
42+
Here’s a rough outline of how to install Gitea on Debian:
43+
44+
**Update and Install Dependencies:**
45+
46+
{{< codeWide >}}
47+
apt -y update
48+
apt -y install git vim bash-completion
49+
{{< /codeWide >}}
50+
51+
**Add a User for Gitea:**
52+
53+
{{< codeWide >}}
54+
adduser \
55+
--system \
56+
--shell /bin/bash \
57+
--gecos 'Git Version Control' \
58+
--group \
59+
--disabled-password \
60+
--home /home/gitea \
61+
gitea
62+
{{< /codeWide >}}
63+
64+
**Download the Binary and Move it to `/usr/local/bin:`**
65+
66+
{{< codeWide >}}
67+
curl -s https://api.github.com/repos/go-gitea/gitea/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep '\linux-amd64$' | wget -i -
68+
{{< /codeWide >}}
69+
70+
**Change Permissions and Rename the Binary:**
71+
72+
{{< codeWide >}}
73+
chmod +x gitea-*-linux-amd64
74+
mv gitea-*-linux-amd64 /usr/local/bin/gitea
75+
{{< /codeWide >}}
76+
77+
**Create Directories for Files:**
78+
79+
{{< codeWide >}}
80+
mkdir -p /etc/gitea /var/lib/gitea/{custom,data,indexers,public,log}
81+
chown gitea:gitea /var/lib/gitea/{data,indexers,log}
82+
chmod 750 /var/lib/gitea/{data,indexers,log}
83+
chown root:gitea /etc/gitea
84+
chmod 770 /etc/gitea
85+
{{< /codeWide >}}
86+
87+
**Create a Systemd Unit File:**
88+
89+
{{< codeWide >}}
90+
vim /etc/systemd/system/gitea.service
91+
{{< /codeWide >}}
92+
93+
Content of the file:
94+
95+
{{< codeWide >}}
96+
97+
[Unit]
98+
Description=Gitea (Git with a cup of tea)
99+
After=syslog.target
100+
After=network.target
101+
102+
[Service]
103+
LimitMEMLOCK=infinity
104+
LimitNOFILE=65535
105+
RestartSec=2s
106+
Type=simple
107+
User=gitea
108+
Group=gitea
109+
WorkingDirectory=/var/lib/gitea/
110+
ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini
111+
Restart=always
112+
Environment=USER=gitea HOME=/home/gitea GITEA_WORK_DIR=/var/lib/gitea
113+
114+
[Install]
115+
WantedBy=multi-user.target
116+
{{< /codeWide >}}
117+
118+
**Start Gitea Service with Systemd:**
119+
120+
{{< codeWide >}}
121+
systemctl daemon-reload
122+
systemctl enable --now gitea
123+
systemctl status gitea
124+
{{< /codeWide >}}
125+
126+
**Additional Permissions for Gitea**
127+
128+
This is important, or the service won't start properly.
129+
130+
{{< codeWide >}}
131+
setcap 'cap_net_bind_service=+ep' /usr/local/bin/gitea
132+
{{< /codeWide >}}
133+
134+
## Migration
135+
136+
The migration involved two steps: backing up the data and the database.
137+
The data primarily consisted of the repositories, which needed to be copied to the new server.
138+
You may also need to adjust Linux permissions if the user running Gitea has changed.
139+
140+
In my case, I also had to update Git hooks, as the directory where Gitea was installed had changed. To do this, you can use the following command:
141+
142+
{{< codeWide >}}
143+
grep -r "/usr/bin/gitea" . | cut -d : -f1 | xargs sed -i 's#/usr/bin/gitea#/usr/local/bin/gitea#g'
144+
{{< /codeWide >}}
145+
146+
The database was SQLite, and it was easy to dump and restore.
147+
148+
In conclusion, the migration was more difficult than I initially anticipated,
149+
but it wasn’t rocket science.
150+
I'm happy to say that I now have Gitea running on Debian 11! 😄

content/blog/gitea/index.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Gitea 🍵"
33
date: 2022-08-08T20:03:02+02:00
44
draft: false
55
hideLastModified: true
6-
summaryImage: "img/gitea.png"
6+
summaryImage: "img/gitea.webp"
77
keepImageRatio: true
88
summary: "Den eigene Git-Service einrichten. Und die Migration von Alpine zu Debian."
99
showInMenu: false
@@ -27,19 +27,19 @@ Meine erste Installation von gitea bestand aus einem LXC Container mit Alpine Li
2727
Da ich nun eine homogene Serverlandschaft anstrebe, sprich alle Server sollen mit Debian 11 auf LXC laufen. Musste nun der Alpine Container weichen.
2828

2929
Es stand mir jetzt die Migration meines Git Server bevor. Leider pakettiert gitea seine Software nicht für Debian. Die Installation ist somit ein wenig schwieriger als unter Alpine.
30-
Gitea selbst ist in [Go](https://go.dev/) geschrieben und es wird ein static link Binary zur Verfügung gestellt. Dies kann gedownloadet werden, doch der Rest muss vom Admin selbst angepasst werden.
30+
Gitea selbst ist in [Golang](https://go.dev/) geschrieben und es wird ein static link Binary zur Verfügung gestellt. Dies kann gedownloadet werden, doch der Rest muss vom Admin selbst angepasst werden.
3131

3232
## Installation von Gitea unter Debian
3333

3434
Hier gebe ich die Installation unter Debian schemenhaft an:
3535

36-
### Update und "Dependencys":
36+
**Update und "Dependencys":**
3737
{{< codeWide >}}
3838
apt -y update
3939
apt -y install git vim bash-completion
4040
{{< /codeWide >}}
4141

42-
### Benutzer hinzufügen:
42+
**Benutzer hinzufügen:**
4343
{{< codeWide >}}
4444
adduser \
4545
--system \
@@ -52,18 +52,18 @@ adduser \
5252
{{< /codeWide >}}
5353

5454

55-
### Downloaden und nach `/usr/local/bin` verschieben:
55+
**Downloaden und nach `/usr/local/bin` verschieben:**
5656
{{< codeWide >}}
5757
curl -s https://api.github.com/repos/go-gitea/gitea/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep '\linux-amd64$' | wget -i -
5858
{{< /codeWide >}}
5959

60-
### Rechte verändern und umbenennen:
60+
**Rechte verändern und umbenennen:**
6161
{{< codeWide >}}
6262
chmod +x gitea-*-linux-amd64
6363
mv gitea-*-linux-amd64 /usr/local/bin/gitea
6464
{{< /codeWide >}}
6565

66-
### Ordner für Files anlegen:
66+
**Ordner für Files anlegen:**
6767
{{< codeWide >}}
6868
mkdir -p /etc/gitea /var/lib/gitea/{custom,data,indexers,public,log}
6969
chown gitea:gitea /var/lib/gitea/{data,indexers,log}
@@ -72,7 +72,7 @@ chown root:gitea /etc/gitea
7272
chmod 770 /etc/gitea
7373
{{< /codeWide >}}
7474

75-
### Systemd Unit File erstellen:
75+
**Systemd Unit File erstellen:**
7676
{{< codeWide >}}
7777
vim /etc/systemd/system/gitea.service
7878
{{< /codeWide >}}
@@ -99,14 +99,14 @@ Environment=USER=gitea HOME=/home/gitea GITEA_WORK_DIR=/var/lib/gitea
9999
WantedBy=multi-user.target
100100
{{< /codeWide >}}
101101

102-
### Systemd gitea Service starten:
102+
**Systemd gitea Service starten:**
103103
{{< codeWide >}}
104104
systemctl daemon-reload
105105
systemctl enable --now gitea
106106
systemctl status gitea
107107
{{< /codeWide >}}
108108

109-
### Zusätzliche Rechte für Gitea
109+
**Zusätzliche Rechte für Gitea**
110110
Ist wichtig da der Dienst sonst nicht startet.
111111

112112
{{< codeWide >}}
@@ -127,4 +127,4 @@ grep -r "/usr/bin/gitea" . | cut -d : -f1 | xargs sed -i 's#/usr/bin/gitea#/usr/
127127
Die Datenbank war ein SQLite, diese ließ sich auch anstandslos dumpen und wieder einspielen.
128128

129129
Abschließend kann man sagen, die Migration war schwieriger als erwartet aber kein Hexenwerk.
130-
Ich bin zufrieden, daß ich nun ein Gitea mir Debian 11 unter der Haube besitze.
130+
Ich bin zufrieden, daß ich nun ein Gitea mir Debian 11 unter der Haube besitze. 😄

0 commit comments

Comments
 (0)