生产部署
# 生产部署
# 初始化
- 从bin目录取出devinggo
cp devinggo /opt/devinggo/devinggo
- 初始化
cd /opt/devinggo/
sudo chmod 0777 devinggo
./devinggo unpack
# 打开manifest/config/config.yaml,配置mysql or postgresql,redis,以及其他配置
./devinggo migrate:up
# 使用systemclt
#到代码根目录复制docs/devinggo.service 到 /opt/devinggo/,转到/opt/devinggo/目录
cp devinggo.service /usr/lib/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable devinggo
sudo systemctl start devinggo
# 使用 Supervisor
#到代码根目录复制docs/devinggo.conf 到 /opt/devinggo/,转到/opt/devinggo/目录
cp devinggo.conf /etc/supervisor/conf.d/
supervisorctl reload
- 官网 web\site 目录
参见 https://nuxt.com.cn/docs/getting-started/deployment/
# 分端部署参考
# 以debain12系统为例
#编译后端
rm -rf ./resource/public/admin
rm -rf internal/packed/packed.go
go mod tidy
gf build -ew
#生成bin/v1.0.0/linux_amd64/devinggo 备用
# 编译前端
cd web/admin
#代码 web/admin/.env.production
# VITE_APP_BASE="/"
# VITE_APP_BASE_URL = http://127.0.0.1:8070
# VITE_APP_WS_URL = ws://127.0.0.1:8070/ws
# 127.0.0.1:8070 可以改成你自己的域名,如果使用https,http://改成https://,ws://改成wss://
yarn install
yarn build
#生成web/admin/dist 备用
# 后端初始化
cp bin/v1.0.0/linux_amd64/devinggo /opt/devinggo/devinggo
cd /opt/devinggo/
sudo chmod 0777 devinggo
./devinggo unpack
# 打开manifest/config/config.yaml,配置mysql or postgresql,redis,以及其他配置
./devinggo migrate:up
# 使用systemclt
#到代码根目录复制docs/devinggo.service 到 /opt/devinggo/,转到/opt/devinggo/目录
cp devinggo.service /usr/lib/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable devinggo
sudo systemctl start devinggo
# 部署前端
cp -R web/admin/dist /opt/devinggo/devinggo_admin
# nginx 配置
server {
listen 80;
server_name xxx.com;
root /opt/devinggo/devinggo_admin/dist;
index index.html;
# 如果使用 history 模式路由
# location / {
# try_files $uri $uri/ /index.html;
# }
location /uploads/ {
proxy_pass http://127.0.0.1:8070/uploads/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /api/ {
proxy_pass http://127.0.0.1:8070/api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /ws {
proxy_pass http://127.0.0.1:8070/ws;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# WebSocket支持
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
location /system/ {
proxy_pass http://127.0.0.1:8070/system/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
上次更新: 2025/08/12, 10:57:14