CentOS7.5 Gitea Install

by 민갤

Server /

Git

설치

  • Docker를 설치하기 위해 wget도 함께 설치한다.
# yum -y install git wget
(... skip ...)
Installed:
  git.x86_64 0:1.8.3.1-14.el7_5                                                         

Dependency Installed:
  libgnome-keyring.x86_64 0:3.12.0-1.el7      perl-Error.noarch 1:0.17020-2.el7         
  perl-Git.noarch 0:1.8.3.1-14.el7_5          perl-TermReadKey.x86_64 0:2.30-20.el7     
  rsync31u.x86_64 0:3.1.3-1.ius.centos7      

Complete!

Git 사용자 추가

# git config --global user.name mingael
# git config --global user.email mingael@dico.me

Docker

설치 및 실행

# wget -qO- https://get.docker.com/ | sh
Remember that you will have to log out and back in for this to take effect!

WARNING: Adding a user to the "docker" group will grant the ability to run
         containers which can be used to obtain root privileges on the
         docker host.
         Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
         for more information.
# /bin/systemctl start docker

버전 확인

# docker -v
Docker version 18.09.0, build 4d60db4

Docker Compose

설치

  • YML 설정 파일로 컨테이너를 생성하고 관리할 수 있다.
  • 최신버전은 https://github.com/docker/compose/releases 에서 확인할 수 있다.
# curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   617    0   617    0     0    565      0 --:--:--  0:00:01 --:--:--   566
100 11.2M  100 11.2M    0     0  49669      0  0:03:56  0:03:56 --:--:-- 59999

실행 권한 부여

# chmod +x /usr/local/bin/docker-compose

부팅 설정

# /bin/systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

YML 파일 생성

  • 설정값은 https://docs.gitea.io/en-us/install-with-docker/ 에서 확인할 수 있다.
# vi /usr/local/bin/docker-compose.yml
version: "2"

networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea:latest
    environment:
      - USER_UID=1000
      - USER_GID=1000
    restart: always
    networks:
      - gitea
    volumes:
      - ./gitea:/data
    ports:
      - "3000:3000"
      - "222:22"

실행

  • docker-compose.yml 파일이 있는 위치에서 실행한다.
# cd /usr/local/bin
# docker-compose up -d
Creating network "bin_gitea" with the default driver
Pulling server (gitea/gitea:latest)...
latest: Pulling from gitea/gitea
4fe2ade4980c: Pull complete
c9395547d228: Pull complete
0e63a3d9657b: Pull complete
df526d9bd80a: Pull complete
247b64e5bd94: Pull complete
9273372fe1ac: Pull complete
Creating bin_server_1 ... done

실행 확인

# docker ps -a
CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS              PORTS                                         NAMES
af56a86b40c7        gitea/gitea:latest   "/usr/bin/entrypoint…"   30 seconds ago      Up 27 seconds       0.0.0.0:3000->3000/tcp, 0.0.0.0:222->22/tcp   bin_server_1

Gitea

3000 포트 추가

# firewall-cmd --permanent --zone=public --add-port=3000/tcp
success

가상 머신 설정 > 네트워크 > 포트 포워딩 > 추가

이름프로토콜호스트 IP호스트 포트게스트 IP게스트 포트
GITTCP30003000

설정

# useradd gitea
# cd gitea
# chown -R gitea.gitea ./*

설치

  • http://localhost:3000/ 접속 > 가입하기 또는 로그인

데이터베이스 유형 : SQLite3 (개인용에 적합)

경로 : /data/gitea/gitea.db

Site Title : Dico

저장소 최상위 경로 : /data/git/repositories

Git LFS Root Path : /data/git/lfs

Run As Username : git

SSH Server Domain : localhost

SSH Server Port : 22

Gitea HTTP Listen Port : 3000

Gitea Base URL : http://localhost:3000/

로그 경로 : /data/gitea/log

  • 데이터베이스를 생성하지 않고 설치할 경우 오류 발생 : 재부팅 후 재접속한다.

The database settings are invalid: unable to open database file

# reboot

관리자 생성

  • 최초 생성하는 계정이 관리자가 된다.

저장소 추가

  • 우측 메뉴의 Repositories 옆에 있는 + 버튼

저장소 이름 : DicoProject

커맨드 라인에서 새 레포리지터리 생성

  • 저장소 추가 후 나오는 화면에 위 제목의 내용을 프로젝트 안에서 실행한다.

touch README.md

git init

git add README.md

git commit -m "first commit"

git remote add origin http://localhost:3000/mingael/DicoProject.git

git push -u origin master

# cd /home/laravel/DicoProject
# touch README.md
# git init
Initialized empty Git repository in /home/laravel/DicoProject/.git/
# git add README.md
# git commit -m "first commit"
[master (root-commit) 42e20b1] first commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README.md
# git remote add origin http://localhost:3000/mingael/DicoProject.git
# git push -u origin master
Username for 'http://localhost:3000': Gitea 계정
Password for 'http://mingael@localhost:3000': 
Counting objects: 3, done.
Writing objects: 100% (3/3), 203 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To http://localhost:3000/mingael/DicoProject.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

Author

민갤

민갤

Back-End Developer

꾸잉꾸잉하고 웁니다.

로그인

디코에 오신 것을 환영해요!
전문가들의 수많은 아티클 창고 🤓