docker(docker-compose)搭建gogs服务器

前提:
确保自己事先在服务器上安装好了docker环境,然后执行pip install docker-compose安装docker-compose.

这样就好了。

然后gogs服务器所需要的docker-compose.yml如下:

version: '2.3'
services:
    mysql:
      image: mysql:5.7
      restart: always
      environment:
        - MYSQL_ROOT_PASSWORD=root
        - MYSQL_DATABASE=gogs
      volumes:
        - ./data/mysql:/var/lib/mysql
        - ./data/conf:/etc/mysql/conf.d
    gogs:
      image: gogs/gogs:latest
      restart: always
      ports:
        - "11022:22"
        - "11080:3000"
      volumes:
        - ./data/gogs:/data
      links:
        - mysql
      depends_on:
        - mysql

对照上面的文件夹映射,建立好文件夹即可,我一般是命名一个gogs文件夹,然后在下面放置一个data文件夹和docker-compose.yml文件,然后在data文件夹下面新建mysql、conf和gogs三个文件夹即可。

好了,直接在gogs文件夹下面执行:

docker-compose up

起来之后登录http://IP:11080然后进行你gogs初始化的设置,这里特别注意一下数据库的地址设置为mysql:3306

其他的保持不变就可以。

设置好了基本上就可以使用了,希望能帮助到!

我贴一下我这边的配置:

APP_NAME = Gogs
RUN_USER = git
RUN_MODE = prod

[database]
DB_TYPE  = mysql
HOST     = mysql:3306 #这里注意一下
NAME     = gogs
USER     = root
PASSWD   = root
SSL_MODE = disable
PATH     = data/gogs.db

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

[server]
DOMAIN           = localhost
HTTP_PORT        = 3000
ROOT_URL         = http://192.168.0.109:11080/ #如果是公网这边需要设置一下你公网IP和映射的端口
DISABLE_SSH      = false
SSH_PORT         = 22
START_SSH_SERVER = false
OFFLINE_MODE     = false

[mailer]
ENABLED = true
HOST    = smtp.qq.com:465
FROM    = [email protected]
USER    = [email protected]
PASSWD  = 授权码

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

[picture]
DISABLE_GRAVATAR        = false
ENABLE_FEDERATED_AVATAR = false

[session]
PROVIDER = file

[log]
MODE      = console, file
LEVEL     = Info
ROOT_PATH = /app/gogs/log

[security]
INSTALL_LOCK = true
SECRET_KEY   = j2E3k4skZmLraAt

希望能有所帮助,谢谢!


你可能感兴趣的:(docker,docker,docker-compose,gogs,git)