Gitea

Gitea is an open source, lightweight code hosting solution. You can find the official documentation here.

See also

Gitea is front-end application for Git. If you want to clone a git repository, please see the Cloning a Repository Hosted on your WebFaction Server section of our Git page for additional documentation.

Enable Public Registrations

Gitea has public registration enabled by default, to avoid unwanted registrations our installer disables this setting. To enable public registration:

  1. Open an SSH session to your account.
  2. Open /home/username/webapps/gitea_app/custom/conf/app.ini in a text editor, where:
  • username is your account name, and
  • gitea_app is the name of your Gitea application.
  1. Set DISABLE_REGISTRATION to false.
  2. Save and close the file.
  3. Restart the Gitea application.

Set Gitea to Production Mode

Our installer starts Gitea in dev mode by default. After you are done configuring to your needs, you should set it to production mode. To set Gitea to production mode:

  1. Open an SSH session to your account.
  2. Open /home/username/webapps/gitea_app/custom/conf/app.ini in a text editor, where:
  • username is your account name, and
  • gitea_app is the name of your Gitea application.
  1. Set RUN_MODE to prod.
  2. Save and close the file.
  3. Restart the Gitea application.

Edit First User’s Email Address

When our installer creates the first user, which has full admin privileges, it sets the email to username@username.webfactional.com. To change this to something more useful:

  1. Open http://domain.example/user/settings/ in a web browser, where domain.example is the Gitea site’s domain name and URL path.
  2. In the Email field, enter the email you want to use.
  3. Click the Update Profile button.

Configure Gitea to Send Email

To Configure Gitea to send mail:

  1. Open an SSH session to your account.

  2. Open /home/username/webapps/gitea_app/custom/conf/app.ini in a text editor, where:

    • username is your account name, and
    • gitea_app is the name of your Gitea application.
  3. Add these lines:

    [mailer]
    ENABLED = true
    SUBJECT = %(APP_NAME)s
    HOST = smtp.webfaction.com:587
    FROM = <adddress>
    USER = <mailbox>
    PASSWD = <password>
    

where:

  • <address> is an email address configured in the WebFaction control panel. This is the domain name your Gitea application will send mail from (such as git@example.domain),
  • <mailbox> is a mailbox name as it appears in the WebFaction control panel (for example, username_gitea), and
  • <password> is the mailbox’s password.
  1. Save and close the file.
  2. Restart the Gitea application.

Remove Public Keys After you have Deleted the App

You can easily manage public keys for the user’s that you have provided access to your repos using Gitea’s UI. If you have deleted the application though, without removing any users first, chances are their public keys are still in your account’s ~/.ssh/authorized_keys file.

Don’t worry, they will not have ssh access to your account or be able to browse your files, as the only command they can run is the gitea executable (which was removed from the filesystem when the application was deleted in the control panel).

To keep things neat and tidy you will have to remove the keys that are related to your Gitea app from the ~/.ssh/authorized_keys file manually. You can do this using your favourite text editor over an SSH session, or through FTP.

If your Gitea app was named for example codehub, a line added to your keys file would look like:

command="/home/username/webapps/codehub/gitea serv key-1 --config='/home/username/webapps/codehub/custom/conf/app.ini'",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty ssh-rsa AAAAB3Nza...[truncated]

You should remove all lines that contain a reference to your codehub Gitea application.

Starting, Stopping, and Restarting Gitea

Gitea applications include a script to start, stop, and restart the application.

Starting

If a Gitea application is not already running, it is automatically started by a cron job every 20 minutes. To manually start the application:

  1. Open an SSH session to your account.
  2. Enter $HOME/webapps/application/bin/start, where application is the name of the application as it appears on the control panel, and press Enter.

Stopping

To stop a Gitea application:

  1. Open an SSH session to your account.
  2. Enter $HOME/webapps/application/bin/stop, where application is the name of the application as it appears on the control panel, and press Enter.

Note

When the Gitea application was installed, a cron job was also created to automatically start the application—if it’s not already running—every 20 minutes. If you wish to prevent the application from being started automatically, this cron job must be removed. Please see Scheduling Tasks with Cron for details on modifying your cron jobs.

Restarting

To restart a Gitea application:

  1. Open an SSH session to your account.
  2. Enter $HOME/webapps/application/bin/restart, where application is the name of the application as it appears on the control panel, and press Enter.