How to install Gitea and configure LFS for game development

How to install a self-hosted GitHub alternative called Gitea on a Vultr cloud server. This allows you to host your project files at a low cost and with great flexibility.

Matthäus Niedoba
June 3, 2024
20
min read
Content

Gitea is a self-hosted GitHub alternative that is lightweight and provides all the features we need for our Unreal or Unity project. In this article we will

  • Set up a virtual machine on the Vultr cloud
  • Install and configure Gitea for Git LFS
  • Connect it to Anchorpoint so that everyone on our team can create repositories without worrying about the Gitea interface.

Why not GitHub or Azure DevOps?

While GitHub or Azure DevOps are popular as a good plug-and-play solution for version control, choosing a self-hosted Git server like Gitea on a generic cloud hosting solution has three main advantages:

  1. Full control over transfer speed: Cloud services can throttle your speed if you push a lot of files. With a self-hosted Git server, you always get maximum speed.
  2. Server location control: Hosting your server in a specific region can result in faster upload/download speeds and faster response times. Another reason why choosing your region is important is if you are only allowed to store your files in the EU, for example, for compliance reasons.
  3. Cost-effectiveness: A self-hosted Git server can be more budget-friendly compared to other services, especially for large projects with many users. Gitea is also lightweight and does not consume a lot of server resources.

How much does it cost?

That depends mostly on your storage needs. It also depends on the type of virtual machine you are using. In this example, we will use Vultr as our cloud storage provider because it has an overall good UX and pricing structure. You can also look at services like Digital Ocean, Linode and of course the big ones like AWS, Microsoft Azure and Google Cloud.

For a project with 1TB of storage and traffic, you can expect to pay around $16 - $20 per month.

Cost Breakdown

Virtual Machine: A 2GB RAM machine costs about $10 - $14 (Vultr pricing table).
Object storage: About $6 for 1TB of storage and traffic (Vultr object storage pricing).

Instead of using the virtual machine for storage (which can be expensive and limited), we will use scalable and inexpensive object storage for all our binary files.

How much work is involved?

Setting up Gitea and Git LFS is relatively easy if you follow the procedure in this article:

  1. Creating a Vultr account: You will need to enter credit card information and a coupon for a free quota. It will take about 5 minutes.
  2. Installing Gitea: This requires some clicks on Vultr and takes about 5 minutes.
  3. Setting up LFS: You'll need to create an object store bucket and configure Gitea, which should take about 10 minutes.
  4. Enabling HTTPS: This is highly recommended for security reasons and will take about 10 minutes.

Prerequisites

Before you start, make sure you have

  • A Vultr account (credit card required).
  • FileZilla (or any other FTP client) to transfer files.
  • Anchorpoint (or any git client of your choice) for pushing and pulling files to and from Gitea.

Installing Gitea on a Vultr cloud and setting up the Anchorpoint integration

We won't need Docker here because Vultr has a preset for installing Gitea.

Create a Vultr account

Go to Vultr.com and sign up for an account. The next step is to add your credit card, PayPal or other payment method. You can also tell Vultr not to take a deposit, because we will use some free credits first, which will allow us to use the service for 30 days without being charged.

vultr dashboard
You must set up the payment method before creating a server. However, we can use a coupon to get some free credits.

Vultr provides coupon codes on their website. Use “CLOUD250FREE” to get some free credits.

vultr dashboard
Use the coupon code "CLOUD250FREE" or any other code from the Vultr coupon website.

Now we need to deploy a new server with the following settings:

  1. We will choose a shared vCPU because this is totally fine for us. For CPU & Storage, choose whatever you need. The regular performance is totally fine for us.
  2. For server location, choose the one closest to your office.
    Important: I ran into problems with locations that have a two word name like "New York" in the Gitea config. This can be solved somehow, but I recommend picking a one-name location like "Miami" in this case.
  1. For the server image we want to use the Gitea preset. Click on Marketplace Apps and search for "gitea". Then select the application.
  2. The server size will be the one with 55GB. This is not the space we will use for our binaries, but for our database etc. This configuration also has 2GB of RAM, which should be enough for Gitea.
  3. Finally, I also like to enable automatic backups, just in case something happens.
  4. We don't need any additional features.
  5. As server hostname & label, just type in "Gitea".
  6. Click on "Deploy Now
vultr server creation
Follow all these steps to create a cloud server on Vultr

Now we have to wait for the server to be installed. This may take a few minutes. When it's done, click on the entry to get to the server settings.

vultr dashboard
This is our server's IP address. Copy and paste it into a new browser tab.

If you copy the IP address and paste it in a new browser tab, you can see that Gitea should been successfully installed.

Configuring Gitea with Object Storage for Git LFS

For our binary files we will be using Git LFS (Large File Storage). It is an extension to Git that allows us to work with GB-sized repositories by efficiently managing binary files. Without it, we will quickly hit limits and have to spend hours debugging.

One of the things that Git LFS gives us is the ability to put all of our binaries on external storage, which results in much lower costs and infinite scalability. Keep in mind that our virtual machine only has 55GB of storage.

vultr dashboard
Add Object Storage to your server for binary files

Setup Object Storage by following these steps.

  1. Go to the blue "Deploy" button and click "Add Object Storage".
  2. Choose a location that is close to your server. Remember, I had trouble when a location had a duplicate name, e.g. "New Jersey".
  3. For the label you can enter "Gitea_storage".
  4. Click on "Add
vultr dashboard
Enter a name for your bucket (it's up to you) and click "Add".

Once it’s created, click on the entry to enter the settings. We will need to create a bucket. A bucket is like a virtual hard drive. Click on create new bucket and name it “giteabucket”. Leave all settings as they are.

dashboard
Click on "Buckets"
dashboard
Create a bucket
dashboard
Name it "giteabucket"

Finally, go back to the “Overview” tab, because now, we need the credentials for configuring Gitea.

Configuring object storage in Gitea

We need to adjust the Gitea settings. They are in a config file that we need to download via SFTP from our server. To do this, we will need Filezilla or another FTP client.

Open Filezilla and go to the "Site Manager". Then we need to enter the server credentials.

filezilla
Open the Site Manager in Filezilla

In Vultr, they are located in your server settings under “Compute” then click on your “Gitea” server. Copy the IP address, your username (which is “root”) and the password and enter it to Filezilla. Change the Protocol to “SFTP”. Finally, click on “Connect”.

vultr dashboard and filezilla
Copy the IP address, username and password from Vultr to Filezilla and set the protocol to SFTP.

Once you have connected to the server, type in this in your remote site address and press enter.

/var/snap/gitea/common/conf
filezilla
The app.ini file is located in this folder. You can also browse to it.

Then, in the left pane, navigate to your desktop and drag the app.ini file you see on the right to your desktop. Open the app.ini file with a text editor (such as Visual Studio Code).

Now we need to add the following:

1. In the section [server] add this:

LFS_START_SERVER = true

2. At the end of the file, create a [storage] section and add these entries:

[storage]
STORAGE_TYPE = minio
SERVE_DIRECT = true
MINIO_ENDPOINT = ams1.vultrobjects.com
MINIO_ACCESS_KEY_ID = IOONEFSEW1PH2QGYBWO5
MINIO_SECRET_ACCESS_KEY = 7******************************j
MINIO_BUCKET = giteabucket
MINIO_LOCATION = Amsterdam
MINIO_USE_SSL = true

You will need to replace these entries with the values from your bucket. Go back to your bucket settings under "Cloud Storage/Object Storage" in Vultr and click on your object storage entry.

You will need to change this to your own values:

MINIO_ENDPOINT
MINIO_ACCESS_KEY_ID
MINIO_SECRET_ACCESS_KEY
MINIO_LOCATION
MINIO_BUCKET (only if you named your bucket something other than "giteabucket")

dashboard and vs code
Adjust the app.ini file and enter your keys from Vultr, so that Gitea can connect to the object storage bucket.

Now, upload the "app.ini" file via Filezilla to the server.

Test if Gitea still works

Go back to your server and restart it. Wait 3 minutes until it has started the Gitea server. Then, if you enter the IP of the server in a new browser tab, the Gitea website should load. If not, something is wrong with the configuration.

dashboard
Restart your server, so that Gitea reads the new app.ini file. Then you can test it if it still works.

If you need to debug it, add this to the end of your “app.ini”.

[log]
MODE = file

Then upload the file via Filezilla and restart the server. Gitea will create a log file with problems in this location: "/var/snap/gitea/common/log". Paste it into Filezilla to get there. The log file will print out any errors, which are helpful for debugging.

Testing file uploads from Anchorpoint

Now we need to log in to Gitea to create our first Git repository. To do this, we need our credentials. Vultr sets these defaults:

Username: gitea_admin

Password: needs to be downloaded from Filezilla. Just add "/root" to the remote site address and download the .gitea_password file.

filezilla
The .gitea_password file is located in the /root folder. Download it to see your admin password for Gitea.

Go to your Gitea website, click on “Sign In” and enter the credentials.

gitea
Your Gitea server

Now create a new repository, give it a name, and leave all the settings at the default.

gitea
Create a new repository

Copy the HTTP address from your repository.

gitea
This is what a blank page of a repository named "test" looks like. Copy the HTTP address.

Open Anchorpoint or your Git client of chocie and create a new project. Select a project folder and add your Gitea HTTP URL in the remote settings.

anchorpoint
Under Remote Settings, set it to "Connect via Https" and paste the HTTP URL from Gitea.

Then, finish the wizard. Once the project is created, add some files (e.g. your Unreal Engine project), then go to the Timeline and make an initial commit.

anchorpoint
Push your files to Gitea

You will get the login window from Gitea. Enter the same credentials that you have used before to access the Gitea website.

Anchorpoint
Enter the same username and password that you use to login to your Gitea website.

After that, wait until the push is successful. If you want to check whether your files are on Vultr, go to your bucket and see if folders have been created in it.

Configuring HTTPs for better security

Right now we connect to our Gitea server over plain HTTP. This is a security risk because the connection isn't encrypted, so someone could do a middleman attack and read our data. For better security we need to create an HTTPS connection.

This is what we need:

  • A domain
    You can use your existing domains or buy one from services like GoDaddy. It does not matter what type of domain it is.
  • Configure DNS settings with your domain provider
  • Modify the "app.ini" file on our Gitea server

Configuring DNS Settings

  1. Log in to your provider
  2. Create a subdomain (e.g. gitea.anchorpoint.app)
  3. Create an A record
    - Hostname = gitea.anchorpoint.app
    - Value = the IP address of your Vultr server (e.g. 199.247.7.197)
ionos
This is an example from the domain provider Ionos. You can also use any other service such as GoDaddy or Namecheap

Customizing the Gitea configuration

Open the "app.ini" file in your text editor and modify the `[server]` section. You will need to edit the PROTOCOL, DOMAIN and HTTP_PORT entries and add these entries:

ENABLE_ACME
ACME_ACCEPTTOS
ACME_DIRECTORY

[server]
PROTOCOL = https
DOMAIN=gitea.anchorpoint.app
ENABLE_ACME=true
ACME_ACCEPTTOS=true
ACME_DIRECTORY=https
HTTP_PORT = 443

Save the config and upload it via Filezilla. Restart the Vultr server as you would if you changed the configuration to store the Git LFS on an object store.

Connecting the Anchorpoint Gitea Integration

To make your life easier, you can use the Anchorpoint integration for Gitea to create repositories and add members directly from Anchorpoint. This is also great for your team members, so they don't have to learn the Gitea interface.

In Anchorpoint, create a new tab and scroll down to "Integrations". Then click on "Connect Application".

anchorpoint
Create a new tab in Anchorpoint and click on "Connect Application", then look for Gitea and click on "Connect"

Then scroll down to Gitea and click on "Connect".  Then enter your Gitea domain (or HTTP address if you skipped the previous part). Once you have added the domain, follow the instructions in the popup.

anchorpoint
Enter your IP address (if you are using HTTP) or your domain (if you are using HTTPS) and follow the instructions in the pop-up window.

If you click on the link, it will bring you to your Gitea website, where you have to enter the information, provided in the popup, so Gitea knows that Anchorpoint is a trusted application.

gitea
Paste this values from Anchorpoint to Gitea

Then copy the Client ID and Client Secret to the clipboard and paste them into Anchorpoint. Finally, click "Connect to Gitea".

anchorpoint
Paste the Client ID and Client Secret from Gitea

Again, the Gitea website will appear where you will have to authorize again. Finally, Anchorpoint will display another popup asking you to select an organization (which is usually your name). Then enter your Gitea credentials (your main user account) again.

Invite your team to Gitea

To work in a team, you must first create user accounts on Gitea before inviting them to projects on Anhorpoint. To do this, log in to your Gitea website. Click on your account in the top right corner and choose "Site management".

gitea
Click on Site Administration

Under “Identity & Access” pick “User Accounts” and then “Create User Account”.

gitea
Create new User Accounts.

When choosing a username, choose the same username that your member has in the email. For example, "john.hunt@anchorpoint.app" will be "john.hunt". This is the only way Anchorpoint will be able to match Anchorpoint users and Gitea users in the Gitea integration.

gitea
The username should match the email address. After that each member needs to login and change the password before starting collaboration.

Important: Each member needs to login in once and change their password, before creating any projects with them.

Recommendation: Create an account for yourself instead of using the Vultr "admin_gitea" account. This account should only be used to administer the Gitea server.

Create projects and work together

Now create a new project in Anchorpoint. Under Git repository, select the option "New Gitea repository". The next step is to invite your members in Anchorpoint. Their Anchorpoint email must match their username in Gitea.

anchorpoint
Create a new project in Anchorpoint and pick "New Gitea Repository"

Now you are ready to work with your team. Gitea offers many configuration options and has an active community if you need more help. Here is the link to the official configuration cheat sheet.

Try Anchorpoint

Git based version control for Unreal and Unity projects.
Learn about Anchorpoint