git server setup

1: Story background:

In project development, code management usually includes SVN and git, which have their own advantages. Here we explain the construction and use of GIT

2: Precautions:

Because the source code construction is too cumbersome, here we introduce the whole environment with docker. It is unclear what docker is used. Please follow the steps strictly

Environment introduction:

root@server:~/git# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.10
Release:        20.10
Codename:       groovy

3: docker environment construction

3.1 installation of docker

3.1.1 preparation for docker installation

If you have installed docker in the past, delete it first:

sudo apt-get remove docker docker-engine

Install dependencies first:

sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common

According to your distribution, the following contents are different. The distribution you use, I'm Ubuntu

Trust Docker's GPG public key:

curl -fsSL | sudo apt-key add -

For computers with amd64 architecture, add a software warehouse:

sudo add-apt-repository \
   "deb [arch=amd64] \
   $(lsb_release -cs) \

3.1.2 start installation

sudo apt-get update
sudo apt-get install docker-ce

3.2 installation of docker compose

sudo apt-get install docker-compose

3.3 change docker to domestic source

Due to the moving speed of downloading image in China, it is modified as domestic accelerated image source here. Please ignore this step if you can access the Internet scientifically

Modify dockers configuration file
Execute the command sudo VIM / etc / docker / daemon The JSON configuration is modified as follows

  "registry-mirrors": [

3.4 restart docker application configuration

sudo systemctl daemon-reload
sudo systemctl restart docker

4: git environment construction

Official document description link.

4.1 preparation

Create a folder for storing data

mkdir git
cd git

Configure docker compose YML file
Execute the command sudo VIM docker compose The YML configuration is modified as follows

version: "3"

    external: false

    image: gitea/gitea:1.13.2
    container_name: gitea
      - USER_UID=1000
      - USER_GID=1000
      - DB_TYPE=mysql
      - DB_HOST=db:3306
      - DB_NAME=gitea
      - DB_USER=gitea
      - DB_PASSWD=gitea
    restart: always
      - gitea
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
       - "3000:3000"
       - "222:22"
       - db

    image: mysql:5.7
    restart: always
      - MYSQL_USER=gitea
      - MYSQL_PASSWORD=gitea
      - MYSQL_DATABASE=gitea
      - gitea
      - ./mysql:/var/lib/mysql

4.2 downloading image files

Note that downloading in advance here is to prevent the failure of downloading the image when starting the project. My network environment is not good, so download in advance to prevent error reporting during operation

docker pull mysql:5.7
docker pull gitea/gitea:1.13.2

4.3 operation items

Execute the command sudo docker compose up - D server

root@server:~/git# docker-compose up -d server
Creating git_db_1 ... done
Creating gitea    ... done

View run results
Execute the command sudo docker compose PS

root@server:~/git# docker-compose ps
  Name                Command               State                      Ports
git_db_1 mysqld      Up      3306/tcp, 33060/tcp
gitea      /usr/bin/entrypoint /bin/s ...   Up>22/tcp,>3000/tcp

You can see that both containers are Up

5: Basic configuration of git environment

Browser input server IP:3000 to access Git warehouse

As shown in the figure, you can see that Git has run successfully
Click login in the upper right corner of the page
Get this configuration page

These items need to be changed in the previous configuration

Finally, click Install now
This is what it looks like after a successful installation

Click Manage background to perform a series of operations

6: git created our first project and tested it

Tags: Docker Ubuntu git server

Posted by joshmaker on Sat, 16 Apr 2022 03:25:42 +0930