Browse Source

恢复web的前端production配置文件的v1代理,server的config.yaml以及core文件夹下的server.go文件恢复原样,新增两个命令行脚本自定义配置及文件变动,修改mysql的3306端口为13306

main
SliverHorn 4 years ago
parent
commit
b011cd2ef8
  1. 2
      docker-compose.yaml
  2. 112
      docker/server-handle.sh
  3. 10
      docker/web-handle.sh
  4. 16
      dockerfile_server
  5. 6
      server/config.yaml
  6. 1
      server/core/server.go
  7. 2
      web/.env.production

2
docker-compose.yaml

@ -19,7 +19,7 @@ services:
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci #设置utf8字符集 command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci #设置utf8字符集
restart: always restart: always
ports: ports:
- "3306:3306" # host物理直接映射端口为6606
- "13306:3306" # host物理直接映射端口为6606
environment: environment:
MYSQL_ROOT_PASSWORD: "Aa@6447985" # root管理员用户密码 MYSQL_ROOT_PASSWORD: "Aa@6447985" # root管理员用户密码

112
docker/server-handle.sh

@ -0,0 +1,112 @@
#! /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"
"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 ", 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())
}
EOF
rm -f ./config.yaml
# 生成config.yaml文件, 用于docker-compose的使用
touch ./config.yaml
filename="./config.yaml"
cat>"${filename}"<<EOF
# Gin-Vue-Admin Global Configuration
# casbin configuration
casbin:
model-path: './resource/rbac_model.conf'
# jwt configuration
jwt:
signing-key: 'qmPlus'
# mysql connect configuration
mysql:
username: root
password: 'Aa@6447985'
path: mysql
db-name: 'qmPlus'
config: 'charset=utf8&parseTime=True&loc=Local'
max-idle-conns: 10
max-open-conns: 10
log-mode: true
#sqlite 配置
sqlite:
path: db.db
log-mode: true
config: 'loc=Asia/Shanghai'
# oss configuration
# 请自行七牛申请对应的 公钥 私钥 bucket 和 域名地址
qiniu:
access-key: '25j8dYBZ2wuiy0yhwShytjZDTX662b8xiFguwxzZ'
secret-key: 'pgdbqEsf7ooZh7W3xokP833h3dZ_VecFXPDeG5JY'
bucket: 'qm-plus-img'
img-path: 'http://qmplusimg.henrongyi.top'
# redis configuration
redis:
addr: redis:6379
password: ''
db: 0
# system configuration
system:
use-multipoint: true
env: 'public' # Change to "develop" to skip authentication for development mode
addr: 8888
db-type: "mysql" # support mysql/sqlite
# captcha configuration
captcha:
key-long: 6
img-width: 240
img-height: 80
# logger configuration
log:
prefix: '[GIN-VUE-ADMIN]'
log-file: true
stdout: 'DEBUG'
file: 'DEBUG'
EOF

10
docker/web-handle.sh

@ -0,0 +1,10 @@
#! /bin/bash
rm -f .env.production
touch .env.production
filename="./.env.production"
cat>"${filename}"<<EOF
ENV = 'production'
VUE_APP_BASE_API = ''
EOF

16
dockerfile_server

@ -2,6 +2,13 @@ FROM node:12.16.1 as gva-web
WORKDIR /gva_web/ WORKDIR /gva_web/
COPY web/ . COPY web/ .
RUN cat .env.production
COPY docker/web-handle.sh .
RUN sh ./web-handle.sh
RUN cat .env.production
RUN rm -f web-handle.sh
RUN npm install -g cnpm --registry=https://registry.npm.taobao.org RUN npm install -g cnpm --registry=https://registry.npm.taobao.org
RUN cnpm install || npm install RUN cnpm install || npm install
RUN npm run build RUN npm run build
@ -12,6 +19,15 @@ ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.io,direct ENV GOPROXY=https://goproxy.io,direct
WORKDIR /go/src/gin-vue-admin WORKDIR /go/src/gin-vue-admin
COPY server/ ./ COPY server/ ./
RUN cat ./core/server.go
RUN cat ./config.yaml
COPY docker/server-handle.sh .
RUN sh ./server-handle.sh
RUN rm -f server-handle.sh
RUN cat ./core/server.go
RUN cat ./config.yaml
RUN go env && go list && go build -o gva-server . RUN go env && go list && go build -o gva-server .

6
server/config.yaml

@ -12,7 +12,7 @@ jwt:
mysql: mysql:
username: root username: root
password: 'Aa@6447985' password: 'Aa@6447985'
path: mysql
path: '127.0.0.1:3306'
db-name: 'qmPlus' db-name: 'qmPlus'
config: 'charset=utf8&parseTime=True&loc=Local' config: 'charset=utf8&parseTime=True&loc=Local'
max-idle-conns: 10 max-idle-conns: 10
@ -36,13 +36,13 @@ qiniu:
# redis configuration # redis configuration
redis: redis:
addr: redis:6379
addr: '127.0.0.1:6379'
password: '' password: ''
db: 0 db: 0
# system configuration # system configuration
system: system:
use-multipoint: true
use-multipoint: false
env: 'public' # Change to "develop" to skip authentication for development mode env: 'public' # Change to "develop" to skip authentication for development mode
addr: 8888 addr: 8888
db-type: "mysql" # support mysql/sqlite db-type: "mysql" # support mysql/sqlite

1
server/core/server.go

@ -18,7 +18,6 @@ func RunWindowsServer() {
} }
Router := initialize.Routers() Router := initialize.Routers()
Router.Static("/form-generator", "./resource/page") Router.Static("/form-generator", "./resource/page")
Router.Static("/admin", "./resource/dist")
//InstallPlugs(Router) //InstallPlugs(Router)
// end 插件描述 // end 插件描述

2
web/.env.production

@ -1,2 +1,2 @@
ENV = 'production' ENV = 'production'
VUE_APP_BASE_API = ''
VUE_APP_BASE_API = '/v1'
Loading…
Cancel
Save