github
git clone 到本地
git clone https://github.com/zhenorzz/goploy.git
cd ./goploy
git checkout -b tagname
cd ./web
npm install && npm run build
cd ../
go build -o goploy cmd/server/main.go
// 这里算是本地编译的
//vite.config.ts中的配置
base: "./",
// .env.production
VITE_APP_BASE_API = '/goploy'
// package.json 最新版本的element-plus不兼容
"element-plus": "2.3.4",
根据Dockfile编译
// 这里算是docker编译的, 需要arm64的,则可以在本地通过如下命令编译go程序
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o goploy cmd/server/main.go
准备mysql数据库
// 下载mysql脚本
https://github.com/zhenorzz/goploy/blob/master/database/goploy.sql
// 在目标mysql服务端创建数据库
CREATE DATABASE goploy
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_bin;
// 直接在服务器上进行执行sql文件
mysql -h172.17.0.3 -P 3306 -uroot -pxxxxxx db</usr/local/goploy.sql
配置文件准备
https://github.com/zhenorzz/goploy/blob/master/goploy.example.toml
// 数据库相关配置
[db]
type = 'mysql'
user = 'root'
password = 'xxxxxx'
host = '127.0.0.1'
port = '3306'
database = 'goploy'
服务器上直接通过systemd服务运行
goploy.toml 文件和上面编译的goploy golang文件
一起拷贝到linux服务器上 /root/goploy
/usr/lib/systemd/system/dvsv3-goploy.service
[Unit]
Description=The Goploy
After=network.target
[Service]
Environment="HOME=/root"
WorkingDirectory=/root/goploy
ExecStart=/root/goploy/goploy
[Install]
WantedBy=multi-user.target
systemctl enable dvsv3-goploy
systemctl start dvsv3-goploy
systemctl status dvsv3-goploy
nginx 配置
location /goploy/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:19029;
# 解决潜在的路径问题
rewrite ^/goploy(/.*)$ $1 break;
}
nginx -s reload
运行后进行构建
npm command not found
yarn command not found