1 介绍
工单系统ferry 01–docker部署ferry 已经介绍了如何使用docker部署ferry,本文继上文介绍如何在本地通过源码运行ferry实例,包括前端和后端服务。
2 操作
前置条件:
参考 工单系统ferry 01–docker部署ferry 启动一个mysql 和redis 实例,并将host 信息更新到 config/settings.dev.yml 中。
运行后端:
git clone https://github.com/lanyulei/ferry.git
git clone https://gitee.com/yllan/ferry.git
cd ferry
go get
go run main.go server -c=config/settings.dev.yml
交叉编译:
env GOOS=linux GOARCH=amd64 go build
实际使用的时候根据Dockerfile的方式build,否则生成的可执行文件替换docker中二进制文件后不能正常执行:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ferry .
运行前端:
git clone https://github.com/lanyulei/ferry_web.git
git clone https://gitee.com/yllan/ferry_web.git
cd ferry_web
npm config set registry https://registry.npm.taobao.org
npm install
# 若npm install安装失败,可尝试使用一下命令安装
npm install --unsafe-perm --force
npm run dev
输出日志如下:
xghome:~/files/code/github/ferry_web$ npm install --unsafe-perm --force
npm WARN using --force I sure hope you know what you are doing.
npm WARN @babel/helper-define-polyfill-provider@0.3.1 requires a peer of @babel/core@^7.4.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN ferry_web@1.0.0 No repository field.
up to date in 7.847s
81 packages are looking for funding
run `npm fund` for details
启动后进入登录界面:
http://localhost:9527/#/login?redirect=%2Fdashboard
3 注意事项
git 报错处理:
npm install --unsafe-perm --force 时候会使用git拉数据,而git当前已经提高了其安全性,因此正常情况会报错:
4537 error The unauthenticated git protocol on port 9418 is no longer supported.
4537 error Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.
解决方法:
git config --global --edit
追加如下内容,然后重新npm install 即可:
[url "https://"]
insteadOf = ssh://
[url "https://"]
insteadOf = git://
参考文档:
[The unauthenticated git protocol on port 9418 is no longer supported.的解决方法](https://blog.csdn.net/qq_50796105/article/details/123655483)
执行python报错
npm install --unsafe-perm --force 过程中会使用 python脚本,默认使用的是python2,因此需要 apt install python2 来安装,否则会报错
4 说明
软件环境:
ubuntu 20.04.1 LTS Desktop
Docker 20.10.7
go version go1.18 linux/amd64
node v14.13.1(笔者用16.13.1 编译报错)
参考文档:
主页/ ferry 教程文档/ 手动部署
The unauthenticated git protocol on port 9418 is no longer supported.的解决方法