Gitea: Difference between revisions
Mckaygerhard (talk | contribs) (remove newbie reference to stop the discussion) |
m (Change link to Repositories page) |
||
Line 5: | Line 5: | ||
== Installation == | == Installation == | ||
First, [[ | First, [[Repositories#Enabling_the_community_repository| Enable the Community Repository]] | ||
Then install the {{pkg|gitea}} package: | Then install the {{pkg|gitea}} package: |
Revision as of 04:25, 27 June 2022
Gitea is a community managed lightweight code hosting solution written in Go. It is a fork of Gogs.
Installation
First, Enable the Community Repository
Then install the gitea package:
apk add gitea
Setting up the Database
Install the MariaDB and mariadb-client packages:
apk add mariadb mariadb-client
Set up the MariaDB installation and secure it:
mysql_install_db --user=mysql --datadir=/var/lib/mysql service mariadb start rc-update add mariadb mysql_secure_installation
Create the gitea
database and a user with access to it:
mysql -u root -p
should be typed in the MariaDB prompt (looks like MariaDB [(none)]>
)mysql -u root -p CREATE DATABASE gitea DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; GRANT ALL ON gitea.* TO 'giteauser'@'localhost' IDENTIFIED BY 'giteapassword'; FLUSH PRIVILEGES; EXIT
If you want, you can uninstall the mariadb-client
now as it's not needed anymore:
apk del mariadb-client
In /etc/gitea/app.ini, replace the contents of the [database]
section with the following:
DB_TYPE = mysql HOST = /var/run/mysqld/mysqld.sock NAME = gitea ; The database name set with 'CREATE DATABASE' USER = giteauser ; The database user PASSWD = giteapassword ; The password for the database user
Configurations
The Gitea service can be configured using /etc/conf.d/gitea:
Description | Configuration Variable | Default Value |
---|---|---|
User to run Gitea under | GITEA_USER | gitea |
Gitea working directory | GITEA_WORK_DIR | /var/lib/gitea/ |
Gitea configuration file | GITEA_CONF | /etc/gitea/app.ini |
Some additional settings in /etc/gitea/app.ini:
Description | Configuration Variable | Default Value |
---|---|---|
Gitea customization directory | Cannot be configured |
/var/lib/gitea/custom/ |
Web files | STATIC_ROOT_PATH | /usr/share/webapps/gitea/ |
Data files | APP_DATA_PATH | /var/lib/gitea/data/ |
Git repository storage directory | ROOT | /var/lib/gitea/git/ |
Log directory | ROOT_PATH | /var/log/gitea/ |
Controlling and starting gitea
You should not start Gitea without setting certain environment variables and passing some options, since it won't know where to store data and logs, so it is recommended to start gitea using the init script:
service gitea start
To add Gitea to the default runlevel (such that it runs automatically on every boot):
rc-update add gitea
To stop the Gitea service:
service gitea stop
Running Gitea without the init script
If (for whatever reason), you would like to start Gitea without using the initscript, you should first stop the Gitea service:
service gitea stop
Then, run Gitea with this command (as the gitea
user):
GITEA_WORK_DIR=/var/lib/gitea gitea web --config /etc/gitea/app.ini
This will use the correct configuration file and write to the correct directories.
Post installation
This material needs expanding ... Please feel free to help us complete it. |
After installing Gitea, go to http://localhost:3000 and start the post-installation process.
Setting up SSH Git access
Do not try to be clever and use ssh-copy-id
, as it will not have the correct command set.
As an example, if this is the public key:
ssh-ed25519 ******************************************************************** **********@gmail.com
The line in .ssh/authorized_keys needs to be:
command="/usr/bin/gitea --config=/etc/gitea/app.ini serv key-2",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-ed25519 ******************************************************************** **********@gmail.com
In order to do this, generate a SSH key, then go to the Gitea settings panel and click the Add Key
button, then paste in your public key.
Now, once you've added your private key to the SSH agent, you can use SSH with Gitea like you normally would with GitHub, GitLab, etc.