diff --git a/README-zh_CN.md b/README-zh_CN.md index 12d387fe..2930ba8a 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -115,14 +115,18 @@ go get -u github.com/swaggo/swag/cmd/swag ```` ##### (2)无法翻墙 -由于国内没法安装 go.org/x 包下面的东西,需要先安装`gopm` + +由于国内没法安装 go.org/x 包下面的东西,推荐使用 [goproxy.io](https://goproxy.io/zh/) ```bash -# 下载gopm包 -go get -v -u github.com/gpmgo/gopm +如果您使用的 Go 版本是 1.13 及以上(推荐) +# 启用 Go Modules 功能 +go env -w GO111MODULE=on +# 配置 GOPROXY 环境变量 +go env -w GOPROXY=https://goproxy.io,direct # 执行 -gopm get -g -v github.com/swaggo/swag/cmd/swag +go get -g -v github.com/swaggo/swag/cmd/swag # 到GOPATH的/src/github.com/swaggo/swag/cmd/swag路径下执行 go install diff --git a/README.md b/README.md index d1326d9c..b95fe0bc 100644 --- a/README.md +++ b/README.md @@ -116,14 +116,23 @@ go build go get -u github.com/swaggo/swag/cmd/swag ```` -##### (2) In mainland China -In mainland China, access to go.org/x is prohibited,we recommend `gopm` +##### (2) In mainland China + +In mainland China, access to go.org/x is prohibited,we recommend [goproxy.io](https://goproxy.io/zh/) + ````bash -# install gopm -go get -v -u github.com/gpmgo/gopm + +If you are using Go version 1.13 and above (recommended) +# Enable Go Modules function +go env -w GO111MODULE=on +# Configure GOPROXY environment variables +go env -w GOPROXY=https://goproxy.io,direct +If you are using Go version 1.12 and below +go env -w GO111MODULE=on +go env -w GOPROXY=https://goproxy.io # get swag -gopm get -g -v github.com/swaggo/swag/cmd/swag +go get -g -v github.com/swaggo/swag/cmd/swag # cd GOPATH/src/github.com/swaggo/swag/cmd/swag go install diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 00000000..7d27ef4f --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,31 @@ +version: "3.8" + +services: + server: + build: + context: ./ + dockerfile: ./dockerfile_server + container_name: gva-server # 容器名 + restart: always + ports: + - '8888:8888' + depends_on: + - mysql + - redis + + mysql: + image: registry.cn-shanghai.aliyuncs.com/gva/gva-mysql:1.1 + container_name: gva-mysql + command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci #设置utf8字符集 + restart: always + ports: + - "3306:3306" # host物理直接映射端口为6606 + environment: + MYSQL_ROOT_PASSWORD: "Aa@6447985" # root管理员用户密码 + + redis: + image: redis:6.0.6 + container_name: gva-redis # 容器名 + restart: always + ports: + - '6379:6379' \ No newline at end of file diff --git a/dockerfile_server b/dockerfile_server new file mode 100644 index 00000000..683846f2 --- /dev/null +++ b/dockerfile_server @@ -0,0 +1,47 @@ +FROM node:12.16.1 as gva-web + +WORKDIR /gva_web/ +COPY web/ . +RUN npm install -g cnpm --registry=https://registry.npm.taobao.org +RUN cnpm install || npm install +RUN npm run build + +FROM golang:alpine as gva-server + +ENV GO111MODULE=on +ENV GOPROXY=https://goproxy.io,direct +WORKDIR /go/src/gin-vue-admin +COPY server/ ./ +RUN go env && go list && go build -o gva-server . + + +FROM nginx:alpine +LABEL MAINTAINER="SliverHorn" + +WORKDIR gva/ + +# copy web +COPY --from=gva-web /gva_web/dist ./resource/dist +# copy server +COPY --from=gva-server /go/src/gin-vue-admin/gva-server ./ +COPY --from=gva-server /go/src/gin-vue-admin/config.yaml ./ +COPY --from=gva-server /go/src/gin-vue-admin/resource ./resource + + +EXPOSE 8888 + +ENTRYPOINT ./gva-server + +# 根据Dockerfile生成Docker镜像 + +# docker build -t gva-server:1.0 . + +#- 根据Docker镜像启动Docker容器 +# - 后台运行 +# - ``` +# docker run -d -p 8888:8888 --name gva-server-v1 gva-server:1.0 +# ``` +# - 以可交互模式运行, Ctrl + p + q +# - ``` +# docker run -it -p 8888:8888 --name gva-server-v1 gva-server:1.0 +# ``` \ No newline at end of file diff --git a/server/config.yaml b/server/config.yaml index 42be755c..f56d2993 100644 --- a/server/config.yaml +++ b/server/config.yaml @@ -12,7 +12,7 @@ jwt: mysql: username: root password: 'Aa@6447985' - path: '127.0.0.1:3306' + path: mysql db-name: 'qmPlus' config: 'charset=utf8&parseTime=True&loc=Local' max-idle-conns: 10 @@ -36,13 +36,13 @@ qiniu: # redis configuration redis: - addr: '127.0.0.1:6379' + addr: redis:6379 password: '' db: 0 # system configuration system: - use-multipoint: false + use-multipoint: true env: 'public' # Change to "develop" to skip authentication for development mode addr: 8888 db-type: "mysql" # support mysql/sqlite diff --git a/server/core/server.go b/server/core/server.go index f855aede..c3da2b45 100644 --- a/server/core/server.go +++ b/server/core/server.go @@ -18,6 +18,7 @@ func RunWindowsServer() { } Router := initialize.Routers() Router.Static("/form-generator", "./resource/page") + Router.Static("/admin", "./resource/dist") //InstallPlugs(Router) // end 插件描述 diff --git a/web/.env.production b/web/.env.production index 7fa06da5..ad9185dc 100644 --- a/web/.env.production +++ b/web/.env.production @@ -1,2 +1,2 @@ ENV = 'production' -VUE_APP_BASE_API = '/v1' \ No newline at end of file +VUE_APP_BASE_API = '' \ No newline at end of file