1 GitLink部署流程
maxjhandsome edited this page 2022-09-06 11:01:09 +08:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

本文档将详细描述GitLink部署流程

依赖库

  • Ruby 2.4.5

  • Rails ~> 5.2

  • MySql ~> 5.6

  • Redis 5+

  • imagemagick

步骤

1安装 Rails 必要的一些三方库:

  • Mac OS X
 brew install imagemagick ghostscript libxml2 libxslt libiconv
  • Ubuntu
sudo apt-get update
sudo apt-get install -y openssl libssl-dev imagemagick git ruby-dev nodejs libmariadb-dev libmysqlclient-dev shared-mime-info libpq-dev libxml2-dev libxslt-dev
sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y tzdata
sudo ln -s /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime

2安装 Ruby, Rails 运行环境:如何快速正确的安装 Ruby, Rails 运行环境

#检验环境是否正确
ruby -v
#ruby 2.4.x ...

gem -v
#3.x.x

bundle -v
#Bundler version 2.x.x

rails -v
#Rails 5.2.x

3克隆稳定版本

git clone -b master https://gitlink.org.cn/Gitlink/forgeplus.git

4安装依赖包

#进入目录
cd forgeplus
#删除Gemfile.lock
rm -rf Gemfile.lock
#安装依赖包
bundle install

5配置初始化文件进入项目根目录执行以下命令

cp config/configuration.yml.example config/configuration.yml
cp config/database.yml.example config/database.yml
touch config/redis.yml
touch config/elasticsearch.yml

6配置数据库数据库配置信息请查看/config/database.yml文件项目默认采用mysql数据库, 如需更改,请自行修改配置信息,默认配置如下

default: &default
  adapter: mysql2
  host: 127.0.0.1
  encoding: utf8
  username: root
  password: 123456

7配置gitea服务(可选)如需要部署自己的gitea平台请参考gitea官方平台文档。因目前gitea平台api受限暂时推荐从forge平台获取gitea部署文件进行部署

  • 配置gitea服务步骤

    -- 部署gitea服务并注册root账户

    -- 修改forge平台的 config/configuration.yml中的gitea服务指向地址

gitea:
  access_key_id: 'root'
  access_key_secret: 'password'
  domain: 'http://www.gitea.example.com'
  base_url: '/api/v1'

8配置/config/database.yml文件(安装redis环境:请自行搜索各平台如何安装部署redis环境)

default: &default
  url: redis://localhost:6379
  db: 1

production:
  <<: *default
  url: redis://localhost:6379

9创建数据库开发环境为development 生成环境为production

rails db:create  RAILS_ENV=development

10导入数据表结构

bundle exec rake sync_table_structure:import_csv

11执行migrate迁移文件开发环境为development 生成环境为production

rails db:migrate RAILS_ENV=development

12clone前端代码将前端代码克隆到public/react目录下目录结构应该是: public/react/build

git clone -b master https://gitlink.org.cn/Gitlink/build.git

13启动redis(此处以macOS系统为例)

redis-server&

14启动sidekiq开发环境为development 生成环境为production

bundle exec sidekiq -C config/sidekiq.yml -e production -d

15启动rails服务

rails s

16浏览器访问在浏览器中输入如下地址访问

http://localhost:3000/

17其他说明通过页面注册以第一个用户为平台管理员用户