How to Install Gitea on Your Synology NAS

How to Install Gitea on Your Synology NAS

Gitea is a painless self-hosted Git service written in GO, and very lightweight. It is somewhat similar to GitHub, Bitbucket and Gitlab. As well as support for Git revision control, it also provides issue tracking and wiki pages development. In this step by step guide I will show you how to install Gitea on your Synology NAS using Docker and Portainer.

Note: This guide works perfectly with the latest Gitea v1.18.3 release.

  • STEP 1

Please Support My work by Making a Donation.

  • STEP 2

Install Portainer using my step by step guide. If you already have Portainer installed on your Synology NAS, skip this STEP. Attention: Make sure you have installed the latest Portainer version.

  • STEP 3

Make sure you have a synology.me Wildcard Certificate. Follow my guide to get a Wildcard Certificate. If you already have a synology.me Wildcard certificate, skip this STEP.

  • STEP 4

Install Text Editor via Synology “Package Center”. (Mandatory STEP.) If you already have Text Editor installed on your Synology NAS, skip this STEP.

Synology Install Text Editor 2023

  • STEP 5

Go to Control Panel / Login Portal / Advanced Tab / click Reverse Proxy. Follow the instructions in the image below.

Gitea Synology NAS Set up 1

  • STEP 6

Now click the “Create” button. Follow the instructions in the image below.

Gitea Synology NAS Set up 2

  • STEP 7

After you click the Create button, the window below will open. Follow the instructions in the image below.

On the General area, set the Reverse Proxy Name description: type in Gitea. After that, add the following instructions:

Source:
Protocol: HTTPS
Hostname: gitea.yourname.synology.me
Port: 443

Check Enable HSTS

Destination:
Protocol: HTTP
Hostname: localhost
Port: 3052

Gitea Synology NAS Set up 3

  • STEP 8

On the Reverse Proxy Rules click the Custom Header tab. Click Create and then, from the drop-down menu, click WebSocket. After you click on WebSocket, two Header Names and two Values will be automatically added. Click Save. Follow the instructions in the image below.

Synology Proxy WebSocket

  • STEP 9

Go to Control Panel / Network / Connectivity tab/ Check Enable HTTP/2 then click Apply. Follow the instructions in the image below.

Gitea Synology NAS Set up 4

  • STEP 10

Go to Control Panel / Security / Advanced tab/ Check Enable HTTP Compression then click Apply. Follow the instructions in the image below.

Gitea Synology NAS Set up 5

  • STEP 11

Go to File Station and open the docker folder. Inside the docker folder, create one new folder and name it gitea. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.

Gitea Synology NAS Set up 6

  • STEP 12

Now create two new folders inside the gitea folder that you created at STEP 11 and name them data and db. Follow the instructions in the image below.
Note: Be careful to enter only lowercase, not uppercase letters.

Gitea Synology NAS Set up 7

  • STEP 13

Log into Portainer using your username and password. On the left sidebar in Portainer, click on Stacks then + Add stack. Follow the instructions in the image below.

1 Synology Portainer Add Stack

  • STEP 14

In the Name field type in gitea. Follow the instructions in the image below.

Note: Copy Paste the code below in the Portainer Stacks Web editor.

version: "3.9"
services:
  db:
    image: postgres
    container_name: Gitea-DB
    hostname: gitea-db
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: ["CMD", "pg_isready", "-q", "-d", "Database", "-U", "user"]
      timeout: 45s
      interval: 10s
      retries: 10
    user: 1026:100
    volumes:
      - /volume1/docker/gitea/db:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=gitea
      - POSTGRES_USER=giteauser
      - POSTGRES_PASSWORD=giteapass
    restart: always

  web:
    image: gitea/gitea:latest
    container_name: Gitea
    hostname: gitea
    security_opt:
      - no-new-privileges:true
    healthcheck:
      test: wget --no-verbose --tries=1 --spider http://localhost:3000/ || exit 1
    ports:
      - 3052:3000
      - 2222:22
    volumes:
      - /volume1/docker/gitea/data:/data
      - /etc/TZ:/etc/TZ:ro
      - /etc/localtime:/etc/localtime:ro
    environment:
      - USER_UID=1026
      - USER_GID=100
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=gitea-db:5432
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=giteauser
      - GITEA__database__PASSWD=giteapass
      #- GITEA__mailer__ENABLED=true
      #- GITEA__mailer__FROM=Your-own-gmail-address
      #- GITEA__mailer__MAILER_TYPE=smtp
      #- GITEA__mailer__HOST=smtp.gmail.com
      #- GITEA__mailer__IS_TLS_ENABLED=true
      #- GITEA__mailer__USER=Your-own-gmail-address
      #- GITEA__mailer__PASSWD=Your-own-app-password
    restart: always

Note: Before you paste the code above in the Web editor area below, change the value numbers for user with your own UID and GID values. (Follow my step by step guide on how to do this.) 1026 is my personal UID value and 100 is my personal GID value. You have to type in your own values.
Note: Before you paste the code above in the Web editor area below, change the value numbers for USER_UID and USER_GID with your own values. (Follow my step by step guide on how to do this.) 1026 is my personal USER_UID value and 100 is my personal USER_GID value. You have to type in your own values.
Note: If you want, you can also add your own SMTP email details by removing all the # in the code above. If you don’t have SMTP details, then leave the code as it is with the #. (Follow my guide on how to Activate Gmail SMTP For Docker Containers.)

Gitea Synology NAS Set up 8

  • STEP 15

Scroll down on the page until you see a button named Deploy the stack. Click on it. Follow the instructions in the image below. The installation process can take up to a few minutes. It will depend on your Internet speed connection.

Gitea Synology NAS Set up 9

  • STEP 16

If everything goes right, you will see the following message at the top right of your screen: “Success Stack successfully deployed“.

Gitea Synology NAS Set up 10

  • STEP 17

Go back to STEP 1 or you will deal with karma 🙂.

  • STEP 18

Now open your browser and type in your HTTPS/SSL certificate like this https://gitea.yourname.synology.me In my case it’s https://gitea.mariushosting.synology.me If everything goes right, you will see the Gitea configuration page. Type in your Company Name then scroll down on the page. Follow the instructions in the image below.

Gitea Synology NAS Set up 11

  • STEP 19

On the Server Domain field type in your own synology.me DDNS that you have previously created at STEP 7 without https at the beginning. On the SSH Server Port type in 2222 instead of 22. On the Gitea Base URL field type in your own synology.me DDNS that you have previously created at STEP 7 with https at the beginning. Click Install Gitea. Follow the instructions in the image below.

Gitea Synology NAS Set up 12 new

  • STEP 20

After you click Install Gitea at STEP 19, you will get a synology blank page error message because the installation is not finished. Refresh the page to solve the temporary issue. At the top right of the page click Register. Follow the instructions in the image below.

Gitea Synology NAS Set up 13

  • STEP 21

Type in your own Username, Email Address and Password. Confirm the Password then click Register Account. Follow the instructions in the image below.

Gitea Synology NAS Set up 14

  • STEP 22

At the top right of the page select Settings. In this area you can change different parameters on your Gitea installation. For example, you can switch the theme to Dark Mode. Select arc-green then Update Theme. Follow the instructions in the image below.

Gitea Synology NAS Set up 15

Your Gitea Dashboard at a Glance!

Gitea Synology NAS Set up 16

  • STEP 23

If you want to modify some settings in Gitea, for example disable user registration, continue to follow the instructions. Make sure you have installed Synology Text Editor as per the instructions at STEP 4. In File Station go to docker / gitea / data / gitea / conf and double click on the app.ini file. Scroll down until you find DISABLE_REGISTRATION and type in true instead of false. Click X to save the file. Follow the instructions in the image below.

Gitea Synology NAS Set up 17

  • STEP 24

To apply the settings, you have to restart the Gitea container. On the left sidebar in Portainer, click Containers. Identify your Gitea instance, select it then click Restart. Follow the instructions in the image below.

Gitea Synology NAS Set up 18

  • STEP 25

Now open your browser and connect to your own synology.me DDNS address, for example https://gitea.yourname.synology.me/admin/config In my case it’s https://gitea.mariushosting.synology.me/admin/config and you can see the Disable Registration is set to true as a result of the settings that you have previously changed at STEP 23.

Gitea Synology NAS Set up 19

Enjoy Gitea!

Note: Can I run Docker on my Synology NAS? See the supported models.
Note: Find out how to update the Gitea container with the latest image.
Note: How to Free Disk Space on Your NAS if You Run Docker.
Note: Instead of the synology.me DDNS you can also use your own domain name.
Note: How to Schedule Start & Stop For Docker Containers.
Note: How to Activate Email Notifications.
Note: How to Add Access Control Profile on Your NAS.
Note: How to Change Docker Containers Restart Policy.
Note: How to Use Docker Containers With VPN.
Note: Convert Docker Run Into Docker Compose.
Note: How to Clean Docker.
Note: How to Clean Docker Automatically.
Note: Best Practices When Using Docker and DDNS.
Note: Some Docker Containers Need WebSocket.
Note: Find out the Best NAS Models For Docker.
Note: Activate Gmail SMTP For Docker Containers.

This post was updated on Friday / January 27th, 2023 at 12:22 AM