优化docker-compose的前端项目不依赖于Gin,使用nginx

This commit is contained in:
SliverHorn
2020-09-10 19:15:44 +08:00
parent 93d1fdae31
commit ba0bcefec4
8 changed files with 156 additions and 90 deletions
+26
View File
@@ -0,0 +1,26 @@
server {
listen 8000;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
try_files $uri $uri/ /index.html;
}
location /api {
proxy_set_header Host $http_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;
rewrite ^/api/(.*)$ /$1 break; #重写
proxy_pass http://172.25.0.4:8888; # 设置代理服务器的协议和地址
}
location /api/swagger/index.html {
proxy_pass http://127.0.0.1:8888/swagger/index.html;
}
}
+9 -43
View File
@@ -1,48 +1,5 @@
#! /bin/bash
rm -f ./core/server.go
# 生成server.go文件, 添加Router.Static("/admin", "./resource/dist")这个代码
touch ./core/server.go
filename="./core/server.go"
cat>"${filename}"<<EOF
package core
import (
"fmt"
"gin-vue-admin/global"
"gin-vue-admin/initialize"
"go.uber.org/zap"
"time"
)
type server interface {
ListenAndServe() error
}
func RunWindowsServer() {
if global.GVA_CONFIG.System.UseMultipoint {
// 初始化redis服务
initialize.Redis()
}
Router := initialize.Routers()
Router.Static("/form-generator", "./resource/page")
Router.Static("/admin", "./resource/dist")
//InstallPlugs(Router)
// end 插件描述
address := fmt.Sprintf(":%d", global.GVA_CONFIG.System.Addr)
s := initServer(address, Router)
// 保证文本顺序输出
// In order to ensure that the text order output can be deleted
time.Sleep(10 * time.Microsecond)
global.GVA_LOG.Debug("server run success on ", zap.String("address", address))
fmt.Printf("欢迎使用 Gin-Vue-Admin默认自动化文档地址:http://127.0.0.1%s/swagger/index.html\n 默认前端文件运行地址:http://127.0.0.1:8888/admin\n", address)
global.GVA_LOG.Error(s.ListenAndServe().Error())
}
EOF
rm -f ./config.yaml
# 生成config.yaml文件, 用于docker-compose的使用
touch ./config.yaml
@@ -123,5 +80,14 @@ zap:
encode_level: 'LowercaseColorLevelEncoder'
stacktrace_key: 'stacktrace'
log_in_console: true
email:
email_from: 'xxx@163.com'
email_nick_name: 'test'
email_secret: 'xxx'
email_to: 'xxx@qq.com'
email_host: 'smtp.163.com'
email_port: 465
email_isSSL: true
EOF
-10
View File
@@ -1,10 +0,0 @@
#! /bin/bash
rm -f .env.production
touch .env.production
filename="./.env.production"
cat>"${filename}"<<EOF
ENV = 'production'
VUE_APP_BASE_API = ''
EOF