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
(12)clone前端代码:将前端代码克隆到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)其他说明:通过页面注册以第一个用户为平台管理员用户