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.
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:
- 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.
- 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.
- 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.
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:
- 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.
- Installing Gitea: This requires some clicks on Vultr and takes about 5 minutes.
- Setting up LFS: You'll need to create an object store bucket and configure Gitea, which should take about 10 minutes.
- Enabling HTTPS: This is highly recommended for security reasons and will take about 10 minutes.
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 provides coupon codes on their website. Use “CLOUD250FREE” to get some free credits.
Now we need to deploy a new server with the following settings:
- 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.
- 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.
- For the server image we want to use the Gitea preset. Click on Marketplace Apps and search for "gitea". Then select the application.
- 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.
- Finally, I also like to enable automatic backups, just in case something happens.
- We don't need any additional features.
- As server hostname & label, just type in "Gitea".
- Click on "Deploy Now
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.
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.
Setup Object Storage by following these steps.
- Go to the blue "Deploy" button and click "Add Object Storage".
- Choose a location that is close to your server. Remember, I had trouble when a location had a duplicate name, e.g. "New Jersey".
- For the label you can enter "Gitea_storage".
- Click on "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.
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.
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”.
Once you have connected to the server, type in this in your remote site address and press enter.
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:
2. At the end of the file, create a [storage] section and add these entries:
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_BUCKET (only if you named your bucket something other than "giteabucket")
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.
If you need to debug it, add this to the end of your “app.ini”.
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:
Password: needs to be downloaded from Filezilla. Just add "/root" to the remote site address and download the .gitea_password file.
Go to your Gitea website, click on “Sign In” and enter the credentials.
Now create a new repository, give it a name, and leave all the settings at the default.
Copy the HTTP address from your repository.
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.
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.
You will get the login window from Gitea. Enter the same credentials that you have used before to access the 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
- Log in to your provider
- Create a subdomain (e.g. gitea.anchorpoint.app)
- Create an A record
- Hostname = gitea.anchorpoint.app
- Value = the IP address of your Vultr server (e.g. 184.108.40.206)
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:
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".
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.
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.
Then copy the Client ID and Client Secret to the clipboard and paste them into Anchorpoint. Finally, click "Connect to 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".
Under “Identity & Access” pick “User Accounts” and then “Create User Account”.
When choosing a username, choose the same username that your member has in the email. For example, "email@example.com" will be "john.hunt". This is the only way Anchorpoint will be able to match Anchorpoint users and Gitea users in the Gitea integration.
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.
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.
Introducing a new GitLab integration
Introducing our new integration to GitLab, which creates repositories and add members directly from Anchorpoint. The integration supports GitLab's cloud and self-hosted versions and makes it easy for artists to setup projects without learning a new interface.
How to set up a .gitignore file for Unity
Add a .gitignore file to your Unity project to avoid uploading unnecessary files. Learn how to customize it for your own needs.