Gitea

From Alpine Linux
Revision as of 21:45, 7 December 2021 by Guest09248 (talk | contribs)
This material needs expanding ...

Please feel free to help us complete it.

Clarifications

1. Gitea was created by a group of users and contributors of the self-hosted Git service Gogs, It is a fork of Gogs and is written in Go.

2. This guide is for real deploy not for docker deploys.. dockers does not need to setup packages and filesystems configs, for that you must use always docker related configurations.

3. If even though docker always uses Alpine linux as images, and the software is alpine packages, it still has nothing to do with using alpine specific commands.

4. Git is the version control system (VCS) software behind gitea perse, so must be installed first. But repositories on server are not same as in clients.. server repositories are bare repositories.

Pre Requirements

This document will guide noob users,

  • CVS command line
    • git
    • git-lfs
  • Database:
    • mysql
    • postgresql
    • sqlite
    • tidb

For database professional setup please refers to the Production_DataBases_:_mysql page or Production_DataBases_:_postgresql page

A hostname is a unique name created to identify a machine on a network, configured in /etc/hostname. To change the computer's hostname edit the /etc/hostname file or execute the following command (make sure to replace myhostname with your desired hostname):

# echo "myhostname" > /etc/hostname

You should also add the hostname to your hosts file (/etc/hosts):

127.0.0.1   localhost.localdomain localhost
127.0.1.1   myhostname.mydomain myhostname
::1         localhost.localdomain localhost

Installation

This guide does work either if are or not in main or edge the gitea package:, take note, do not install any more from edge.. so in fact all gitea dependencies must be listed and installed before gitea and edge brand are activated, so the following process will guide and show you how to do that; first gain root privileges or access ssh to your alpine server and then:

  1. added and update normal repositories
  2. install direct dependences: git, gnupg, make, bash, coreutils and from normal stable repositories
  3. install indirect dependences: manpages, grep, lsof, less, curl, binutils, attr, dialog
  4. alternate edge repositories
  5. install gitea from edge repository
  6. restore normal repository
cat > /etc/apk/repositories << EOF; $(echo)
http://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/main
http://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/community
EOF

apk update

apk add git git-lfs git-doc gnupg gnupg1 make bash bash-doc coreutils

apk add man man-pages grep grep-doc lsof lsof-doc less less-doc curl curl-doc binutils dialog dialog-doc attr

export PAGER=less

cat >> /etc/apk/repositories << EOF; $(echo)
http://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/main
http://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/community
http://dl-cdn.alpinelinux.org/alpine/edge/main
http://dl-cdn.alpinelinux.org/alpine/edge/community
EOF

apk update

apk add gitea

cat > /etc/apk/repositories << EOF; $(echo)
http://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/main
http://dl-cdn.alpinelinux.org/alpine/v$(cat /etc/alpine-release | cut -d'.' -f1,2)/community
EOF

apk update
Warning: Take in consideration that the user gitea or "a gitea" system user must be in the system. Check if the gitea package already crated the user, if not, just created but set home to /var/lib/gitea


Configurations

Gitea configurations are defined by the gitea service at /etc/init.d/gitea script:

Artifac Name Path related
Daemon script gitea /etc/init.d/gitea
Daemon user gitea /var/lib/gitea/
Group user www-data /var/www/
Binary program gitea /usr/bin/gitea
Working dir GITEA_WORK_DIR /var/lib/gitea/
Customizing GITEA_CUSTOM /var/lib/gitea/custom/
Config global gitea.ini /etc/gitea/app.ini
Web files STATIC_ROOT_PATH /usr/share/webapps/gitea/
Data files APP_DATA_PATH /var/lib/gitea/data/

Gitea runs as gitea user, and www-data group, so are compatible with any web deploy in system webservers packages of alpine repositories, but not with any other external installation if does not are same as.

Gitea has two configuration files, the system defaults at /var/lib/gitea/conf/app.ini and modifiable package defaults, at /etc/gitea/app.ini. Original files are in /usr/share/webapps/gitea and are defaults non-modifiable. For alterations see next sections where are defined initialization, customization and configurations.

Gitea can be customized: just take same path from /usr/share/webapps/gitea/ and put in same manner at /var/lib/gitea/custom/ place.

Initialization

Gitea just after install does not need many configurations, the daemon service init all the needs, take in consideration that this means:

Config Default
Start to use http://localhost:3000
Git repositories /var/lib/gitea/git
Database files Sqlite at /var/lib/gitea/db/gitea.db
Loggin files /var/log/gitea

For others configurations please check next sections.

Controlling and starting gitea

Gitea binary itselt cannot be start alone, without parameters will put lot of directories and files in the default path, so to start to use must be:

  1. Start from init script!
  2. Make enabled the init script!
  3. Stop from init script
rc-update add gitea default

rc-service gitea restart

To stop:

rc-service gitea stop

A manual start without init script can be done but to use the files installed on the system the steps are:

  1. stop any running instance
  2. make a command to run with proper arguments
rc-service gitea stop

GITEA_WORK_DIR='/var/lib/gitea' /usr/bin/gitea web --config /etc/gitea/app.ini

This will use the config files and installed files from the package.

Post installation

After install and initialized the daemon, you now can just go to http://localhost:3000 and start the post-installation process, if you dont want to change any configuration.. if not check next sections. A starting page will be show.

The post install page, only are show when try to use the system, away of the starting page, by example if browse the repositories or try to login. You must not forget to setup that installation.

Administrator account must be configured before push "install gitea", the button at the end of the post-configuration page when you first visit the installation. Provide and username for admin user, take note "admin" are a reserved word so choose another name. after provide passowrd you will continue the installation.

Configuring

Gitea can be customized: just take same path from /usr/share/webapps/gitea/ and put in same manner at /var/lib/gitea/custom/ place, by example to customize default landing page, just take a copy of the /usr/share/webapps/gitea/templates/home.tmpl and put modified one as /var/lib/gitea/custom/templates/home.tmpl as well.


Database configurations

Gitea for data database backend for storing configurations.. SQLite are the default. But for others database backends alpine packages of MySQL/MariaDB or PostgreSQL are like normal tarball of each one, admins must know what they want.. there's no automatic window-like installation here. So first go to MariaDB or PostgreSQL wiki pages and with a user database configure in the /etc/gitea/app.ini and modify the DB_TYPE change from sqlite to postgres or mysql, NAME as the database access where gitea will store the data, USER as the user that will access the database, PASSWORD with the password of the user to access to the database defined. HOST must be with "localhost" value since this wiki assumes local installation.

Setup the database to MySQL:

service gitea stop

Of course you must changed "secret_new_root_password" by a proper password provided by you.

Setup the database to PosgreSQL:

service gitea stop

Of course you must changed "secret_new_root_password" by a proper password provided by you.

See Also