Fast deployment of docker gogs git

Posted by wcl99 on Tue, 19 Nov 2019 16:31:03 +0100

Preface

  • gogs introduction

    • Gogs is an easy to build self-service Git service.
    • The goal of Gogs is to build a self-service Git service in the simplest, fastest and easiest way. Using Go language development enables Gogs to be distributed through independent binary, and supports all platforms supported by Go language, including Linux, Mac OS X, Windows and ARM platforms.
  • Why use gogs
    • gogs light weight
    • git update comes with gogs
    • Simple operation of gogs

Fast build based on docker

  • Preparing the database
    • If there is no database before, you can use docker to quickly deploy mysql or mariadb
mkdir -p ~/mysql/data ~/mysql/logs ~/mysql/conf
docker run -p 3306:3306 --name mymysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.6
  • Configuration database
MariaDB [(none)]> create database gogs default character set utf8;
MariaDB [(none)]> grant all on gogs.* to 'gogs'@'%' identified by 'gogspass';
  • If there is a docker to build a database, you can use the following method to communicate with each other through the docker's own network. Of course, the simple method is to use the database by accessing the Internet port
docker network ls
docker network connect dockeronlyofficenextcloudmysql_onlyoffice gogs
docker run -itd --name=gogs -p 10022:22 -p 10080:3000 -e TZ=Asia/Shanghai -v /volume1/docker/gogs:/data gogs/gogs

gogs configuration

gitlab vs gogs resource consumption

  • gitlab
  • gogs

Profile view

cat gogs/conf/app.ini

APP_NAME = Aiker Edward
RUN_USER = git
RUN_MODE = prod

[database]
DB_TYPE  = mysql
HOST     = mariadb:3306
NAME     = gogs
USER     = gogs
PASSWD   = gogspass
SSL_MODE = disable
PATH     = data/gogs.db

[repository]
ROOT = /data/git/gogs-repositories

[server]
DOMAIN           = gogs.abc.com
HTTP_PORT        = 3000
ROOT_URL         = http://gogs.abc.com/
DISABLE_SSH      = false
SSH_PORT         = 10022
START_SSH_SERVER = false
OFFLINE_MODE     = false

[mailer]
ENABLED = false

[service]
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL     = false
DISABLE_REGISTRATION   = false
ENABLE_CAPTCHA         = true
REQUIRE_SIGNIN_VIEW    = true
SHOW_REGISTRATION_BUTTON = false

[picture]
DISABLE_GRAVATAR        = false
ENABLE_FEDERATED_AVATAR = true

[session]
PROVIDER = file

[log]
MODE      = file
LEVEL     = Info
ROOT_PATH = /data/log

[security]
INSTALL_LOCK = true # true closes the web configuration wizard, false opens the web configuration wizard
SECRET_KEY   = NbSgKURfSaFxcdxW

Configure the reverse proxy based on nginx ssl

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name gogs.abc.com;

    ssl_certificate /usr/syno/etc/certificate/ReverseProxy/3a2b92d0-ea43-4c88-a7a0-e8be86104850/fullchain.pem;

    ssl_certificate_key /usr/syno/etc/certificate/ReverseProxy/3a2b92d0-ea43-4c88-a7a0-e8be86104850/privkey.pem;

    add_header Strict-Transport-Security "max-age=15768000; includeSubdomains; preload" always;

    location / {
        proxy_set_header        Host                $http_host;
        proxy_set_header        X-Real-IP           $remote_addr;
        proxy_set_header        X-Forwarded-For     $proxy_add_x_forwarded_for;
        proxy_set_header        X-Forwarded-Proto   $scheme;
        proxy_intercept_errors  on;
        proxy_http_version      1.1;

        proxy_pass http://localhost:10080;

    }

}

In this way, it can be accessed through https + domain name.

Topics: Linux Docker MySQL Database git