Skip to content

Commit 8ae25dc

Browse files
committed
新增docker-compose的支持,文档说明取消gopm,改用Go Modules主流的代理模式
1 parent fee4af6 commit 8ae25dc

File tree

7 files changed

+105
-13
lines changed

7 files changed

+105
-13
lines changed

README-zh_CN.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,18 @@ go get -u github.com/swaggo/swag/cmd/swag
115115
````
116116

117117
##### (2)无法翻墙
118-
由于国内没法安装 go.org/x 包下面的东西,需要先安装`gopm`
118+
119+
由于国内没法安装 go.org/x 包下面的东西,推荐使用 [goproxy.io](https://goproxy.io/zh/)
119120

120121
```bash
121-
# 下载gopm包
122-
go get -v -u github.com/gpmgo/gopm
122+
如果您使用的 Go 版本是 1.13 及以上(推荐)
123+
# 启用 Go Modules 功能
124+
go env -w GO111MODULE=on
125+
# 配置 GOPROXY 环境变量
126+
go env -w GOPROXY=https://goproxy.io,direct
123127

124128
# 执行
125-
gopm get -g -v github.com/swaggo/swag/cmd/swag
129+
go get -g -v github.com/swaggo/swag/cmd/swag
126130

127131
# 到GOPATH的/src/github.com/swaggo/swag/cmd/swag路径下执行
128132
go install

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,23 @@ go build
116116
go get -u github.com/swaggo/swag/cmd/swag
117117
````
118118

119-
##### (2) In mainland China
120-
In mainland China, access to go.org/x is prohibited,we recommend `gopm`
119+
##### (2) In mainland China
120+
121+
In mainland China, access to go.org/x is prohibited,we recommend [goproxy.io](https://goproxy.io/zh/)
122+
121123
````bash
122-
# install gopm
123-
go get -v -u github.com/gpmgo/gopm
124+
125+
If you are using Go version 1.13 and above (recommended)
126+
# Enable Go Modules function
127+
go env -w GO111MODULE=on
128+
# Configure GOPROXY environment variables
129+
go env -w GOPROXY=https://goproxy.io,direct
130+
If you are using Go version 1.12 and below
131+
go env -w GO111MODULE=on
132+
go env -w GOPROXY=https://goproxy.io
124133

125134
# get swag
126-
gopm get -g -v github.com/swaggo/swag/cmd/swag
135+
go get -g -v github.com/swaggo/swag/cmd/swag
127136

128137
# cd GOPATH/src/github.com/swaggo/swag/cmd/swag
129138
go install

docker-compose.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
version: "3.8"
2+
3+
services:
4+
server:
5+
build:
6+
context: ./
7+
dockerfile: ./dockerfile_server
8+
container_name: gva-server # 容器名
9+
restart: always
10+
ports:
11+
- '8888:8888'
12+
depends_on:
13+
- mysql
14+
- redis
15+
16+
mysql:
17+
image: registry.cn-shanghai.aliyuncs.com/gva/gva-mysql:1.1
18+
container_name: gva-mysql
19+
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci #设置utf8字符集
20+
restart: always
21+
ports:
22+
- "3306:3306" # host物理直接映射端口为6606
23+
environment:
24+
MYSQL_ROOT_PASSWORD: "Aa@6447985" # root管理员用户密码
25+
26+
redis:
27+
image: redis:6.0.6
28+
container_name: gva-redis # 容器名
29+
restart: always
30+
ports:
31+
- '6379:6379'

dockerfile_server

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM node:12.16.1 as gva-web
2+
3+
WORKDIR /gva_web/
4+
COPY web/ .
5+
RUN npm install -g cnpm --registry=https://registry.npm.taobao.org
6+
RUN cnpm install || npm install
7+
RUN npm run build
8+
9+
FROM golang:alpine as gva-server
10+
11+
ENV GO111MODULE=on
12+
ENV GOPROXY=https://goproxy.io,direct
13+
WORKDIR /go/src/gin-vue-admin
14+
COPY server/ ./
15+
RUN go env && go list && go build -o gva-server .
16+
17+
18+
FROM nginx:alpine
19+
LABEL MAINTAINER="SliverHorn"
20+
21+
WORKDIR gva/
22+
23+
# copy web
24+
COPY --from=gva-web /gva_web/dist ./resource/dist
25+
# copy server
26+
COPY --from=gva-server /go/src/gin-vue-admin/gva-server ./
27+
COPY --from=gva-server /go/src/gin-vue-admin/config.yaml ./
28+
COPY --from=gva-server /go/src/gin-vue-admin/resource ./resource
29+
30+
31+
EXPOSE 8888
32+
33+
ENTRYPOINT ./gva-server
34+
35+
# 根据Dockerfile生成Docker镜像
36+
37+
# docker build -t gva-server:1.0 .
38+
39+
#- 根据Docker镜像启动Docker容器
40+
# - 后台运行
41+
# - ```
42+
# docker run -d -p 8888:8888 --name gva-server-v1 gva-server:1.0
43+
# ```
44+
# - 以可交互模式运行, Ctrl + p + q
45+
# - ```
46+
# docker run -it -p 8888:8888 --name gva-server-v1 gva-server:1.0
47+
# ```

server/config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jwt:
1212
mysql:
1313
username: root
1414
password: 'Aa@6447985'
15-
path: '127.0.0.1:3306'
15+
path: mysql
1616
db-name: 'qmPlus'
1717
config: 'charset=utf8&parseTime=True&loc=Local'
1818
max-idle-conns: 10
@@ -36,13 +36,13 @@ qiniu:
3636

3737
# redis configuration
3838
redis:
39-
addr: '127.0.0.1:6379'
39+
addr: redis:6379
4040
password: ''
4141
db: 0
4242

4343
# system configuration
4444
system:
45-
use-multipoint: false
45+
use-multipoint: true
4646
env: 'public' # Change to "develop" to skip authentication for development mode
4747
addr: 8888
4848
db-type: "mysql" # support mysql/sqlite

server/core/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func RunWindowsServer() {
1818
}
1919
Router := initialize.Routers()
2020
Router.Static("/form-generator", "./resource/page")
21+
Router.Static("/admin", "./resource/dist")
2122

2223
//InstallPlugs(Router)
2324
// end 插件描述

web/.env.production

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
ENV = 'production'
2-
VUE_APP_BASE_API = '/v1'
2+
VUE_APP_BASE_API = ''

0 commit comments

Comments
 (0)