提交 64e7eced 编写于 作者: Sliver_Horn's avatar Sliver_Horn

更新文档,优化docker-compose的网络自定义

上级 f71a9aa7
此差异已折叠。
......@@ -17,7 +17,7 @@ server {
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; # 设置代理服务器的协议和地址
proxy_pass http://177.7.0.12:8888; # 设置代理服务器的协议和地址
}
location /api/swagger/index.html {
......
......@@ -71,9 +71,16 @@ We are excited that you are interested in contributing to gin-vue-admin. Before
- [gin-vue-admin_v1.0_dev](https://github.com/flipped-aurora/gin-vue-admin/tree/gin-vue-admin_v1_dev) (stop maintenance)
## 2. Getting started
```
- node version > v8.6.0
- golang version >= v1.11
- IDE recommendation: Goland
- After you clone the project, use the scripts in directory db to create your own database.
- We recommend you to apply for your own cloud service in QINIU. Replace the public key, private key, warehouse name and default url address with your own, so as not to mess up the test database.
```
> Use docker-compose to experience this project
- Installation docker-compose [Official document](https://docs.docker.com/compose/install/)
- ```shell script
......@@ -95,6 +102,7 @@ We are excited that you are interested in contributing to gin-vue-admin. Before
- ```git
git clone https://github.com/flipped-aurora/gin-vue-admin.git
```
- Use docker-compose up to start the startup project with one click
- ```shell script
# Use docker-compose to start four containers
......@@ -109,86 +117,27 @@ We are excited that you are interested in contributing to gin-vue-admin. Before
- swagger APIs [http://127.0.0.1:8888/swagger/index.html](http://127.0.0.1:8888/swagger/index.html)
- Openhttp://127.0.0.1:8000, if the verification code cannot be displayed or padding,Please try the following
- ```shell
# Enter the following command in the terminal to find
docker network inspect gin-vue-admin_default
[
{
"Name": "gin-vue-admin_default",
"Id": "dd65598bd3fcce9916a88161f26268f4e08a6d5bd1c619d07e69abc93c69bba3",
"Created": "2020-09-10T10:36:37.868984015Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.29.0.0/16",
"Gateway": "172.29.0.1"
}
]
},
"Internal": false,
"Attachable": true,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"1e246725c7ab689608c9f451c57a892e070fd63ec971d1749ede8dfbdaf704e1": {
"Name": "gva-redis",
"EndpointID": "d457e4babd5676e289bdf4f4c5ef0ce30c2acd87d437bfd7ea8809467a9304ef",
"MacAddress": "02:42:ac:1d:00:02",
"IPv4Address": "172.29.0.2/16",
"IPv6Address": ""
},
"7228d1c37654173e78a5ae82047b3a3b771feeea855dcc1e88e8e29e262bf789": {
"Name": "gva-web",
"EndpointID": "ffc9c29b9aa1e4c7a56b9e8060fff455295813298df585df51b802548c477969",
"MacAddress": "02:42:ac:1d:00:05",
"IPv4Address": "172.29.0.5/16",
"IPv6Address": ""
},
"99b6063801049d659a329cada5ad0d418c02a9956794b9bcbc07327fff3a1e58": {
"Name": "gva-server",
"EndpointID": "9a04629997d8b9aa6d75cc396d5dbb54bc5d239017a1010bacb53f73e2d46199",
"MacAddress": "02:42:ac:1d:00:04",
"IPv4Address": "172.29.0.4/16",
"IPv6Address": ""
},
"af60bee9ddca855beaf6bd6c6612516970f1336215af622d560f982276d9e4c6": {
"Name": "gva-mysql",
"EndpointID": "998a67b2b2ca9a12c916e97bf30f6b5879ee610c52d5ab329253192acd686cd8",
"MacAddress": "02:42:ac:1d:00:03",
"IPv4Address": "172.29.0.3/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {
"com.docker.compose.network": "default",
"com.docker.compose.project": "gin-vue-admin",
"com.docker.compose.version": "1.26.2"
}
}
]
# Replace the ip on line 20 of .docker-compose/nginx/conf.d/my.conf with the ip of IPv4Address whose Name is "gva-server"
```
- If the internal ip of the server's 177.7.0.12 container is occupied, the place to be modified is
```
- node version > v8.6.0
- golang version >= v1.11
- IDE recommendation: Goland
- After you clone the project, use the scripts in directory db to create your own database.
- We recommend you to apply for your own cloud service in QINIU. Replace the public key, private key, warehouse name and default url address with your own, so as not to mess up the test database.
```
- Replace 177.7.0.12 on line 39 of [docker-compose.yaml](./docker-compose.yaml) with the ip you want
- Replace 177.7.0.12 in line 20 of [.docker-compose/nginx/conf.d/my.conf](./.docker-compose/nginx/conf.d/my.conf) with the ip you want
- docker-compose uses a custom docker network
- ```dockerfile
networks:
network:
ipam:
driver: default
config:
- subnet: '177.7.0.0/16'
```
- Subnet address, the default gateway is 177.7.0.1 (docker-compose V2 needs to write, V3 does not need),For specific information, see the [official document](https://docs.docker.com/compose/compose-file/#ipv4_address-ipv6_address)
- The default network name is gin-vue-admin_network, and the default is bridge mode
- If the subnet is modified, the ipv4_address of each service needs to be modified, and the ip of the server on line 20 of [.docker-compose/nginx/conf.d/my.conf](.docker-compose/nginx/conf.d/my.conf) also needs to be modified
### 2.1 Web
......
......@@ -99,6 +99,7 @@ Gin-vue-admin 的成长离不开大家的支持,如果你愿意为 gin-vue-adm
- ```git
git clone https://github.com/flipped-aurora/gin-vue-admin.git
```
- 使用docker-compose up一键启动启动项目
- ```shell script
# 使用docker-compose启动四个容器
......@@ -113,77 +114,28 @@ Gin-vue-admin 的成长离不开大家的支持,如果你愿意为 gin-vue-adm
- swagger文档 [http://127.0.0.1:8888/swagger/index.html](http://127.0.0.1:8888/swagger/index.html)
- 打开http://127.0.0.1:8000,验证码无法显示或者padding的话, 请尝试以下方法
- ```shell
# 终端输入以下命令查找
docker network inspect gin-vue-admin_default
[
{
"Name": "gin-vue-admin_default",
"Id": "dd65598bd3fcce9916a88161f26268f4e08a6d5bd1c619d07e69abc93c69bba3",
"Created": "2020-09-10T10:36:37.868984015Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.29.0.0/16",
"Gateway": "172.29.0.1"
}
]
},
"Internal": false,
"Attachable": true,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"1e246725c7ab689608c9f451c57a892e070fd63ec971d1749ede8dfbdaf704e1": {
"Name": "gva-redis",
"EndpointID": "d457e4babd5676e289bdf4f4c5ef0ce30c2acd87d437bfd7ea8809467a9304ef",
"MacAddress": "02:42:ac:1d:00:02",
"IPv4Address": "172.29.0.2/16",
"IPv6Address": ""
},
"7228d1c37654173e78a5ae82047b3a3b771feeea855dcc1e88e8e29e262bf789": {
"Name": "gva-web",
"EndpointID": "ffc9c29b9aa1e4c7a56b9e8060fff455295813298df585df51b802548c477969",
"MacAddress": "02:42:ac:1d:00:05",
"IPv4Address": "172.29.0.5/16",
"IPv6Address": ""
},
"99b6063801049d659a329cada5ad0d418c02a9956794b9bcbc07327fff3a1e58": {
"Name": "gva-server",
"EndpointID": "9a04629997d8b9aa6d75cc396d5dbb54bc5d239017a1010bacb53f73e2d46199",
"MacAddress": "02:42:ac:1d:00:04",
"IPv4Address": "172.29.0.4/16",
"IPv6Address": ""
},
"af60bee9ddca855beaf6bd6c6612516970f1336215af622d560f982276d9e4c6": {
"Name": "gva-mysql",
"EndpointID": "998a67b2b2ca9a12c916e97bf30f6b5879ee610c52d5ab329253192acd686cd8",
"MacAddress": "02:42:ac:1d:00:03",
"IPv4Address": "172.29.0.3/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {
"com.docker.compose.network": "default",
"com.docker.compose.project": "gin-vue-admin",
"com.docker.compose.version": "1.26.2"
}
}
]
# .docker-compose/nginx/conf.d/my.conf的第20行的ip替换为Name为"gva-server"的IPv4Address的ip
- 如果server的177.7.0.12这个容器内部ip被占用了,需要修改地方为
- docker-compose.yaml的第39行的177.7.0.12更换为你想要的ip
- .docker-compose/nginx/conf.d/my.conf的第20行的177.7.0.12更换为你想要的ip
- docker-compose使用自定义的一个docker网络
- ```dockerfile
networks:
network:
ipam:
driver: default
config:
- subnet: '177.7.0.0/16'
```
- 子网地址, 默认网关是177.7.0.1(docker-compose V2需要写,V3则不需要),具体信息看[官方文档](https://docs.docker.com/compose/compose-file/#ipv4_address-ipv6_address)
- 默认的network名为gin-vue-admin_network,默认是bridge模式
- 如果修改了子网,对应的每个service的ipv4_address都需要修改,还有.docker-compose/nginx/conf.d/my.conf的第20行的server的ip也需要修改
### 2.1 web端
```bash
......
version: "3.8"
networks:
network:
ipam:
driver: default
config:
- subnet: '177.7.0.0/16'
services:
web:
build:
context: ./
dockerfile: ./Dockerfile
dockerfile: ./dockerfile_web
container_name: gva-web
restart: always
ports:
- '8000:8000'
links:
- server
depends_on:
- server
command: ['nginx-debug', '-g', 'daemon off;']
command: [ 'nginx-debug', '-g', 'daemon off;' ]
networks:
network:
ipv4_address: 177.7.0.11
server:
build:
context: ./
dockerfile: ./DockerfileServer
dockerfile: ./dockerfile_server
container_name: gva-server
restart: always
ports:
......@@ -26,6 +34,9 @@ services:
depends_on:
- mysql
- redis
networks:
network:
ipv4_address: 177.7.0.12
mysql:
image: mysql:8.0.21
......@@ -38,11 +49,17 @@ services:
MYSQL_DATABASE: 'qmPlus' # 初始化启动时要创建的数据库的名称
MYSQL_ROOT_PASSWORD: 'Aa@6447985' # root管理员用户密码
volumes:
- '.docker-compose/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d'
- '.docker-compose/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d'
networks:
network:
ipv4_address: 177.7.0.13
redis:
image: redis:6.0.6
container_name: gva-redis # 容器名
restart: always
ports:
- '6379:6379'
\ No newline at end of file
- '6379:6379'
networks:
network:
ipv4_address: 177.7.0.14
\ No newline at end of file
......@@ -5,13 +5,11 @@ ENV GOPROXY=https://goproxy.io,direct
WORKDIR /go/src/gin-vue-admin
COPY server/ ./
RUN cat ./core/server.go
RUN cat ./config.yaml
COPY .docker-compose/shell/server-handle.sh .
RUN ls -al
RUN sh ./server-handle.sh
RUN rm -f server-handle.sh
RUN cat ./core/server.go
RUN cat ./config.yaml
RUN go env && go build -o server .
......
......@@ -16,5 +16,3 @@ RUN cat /etc/nginx/nginx.conf
RUN cat /etc/nginx/conf.d/my.conf
RUN ls -al /usr/share/nginx/html
CMD ls -al /usr/share/nginx/html
CMD ['nginx-debug', '-g', 'daemon off;']
\ No newline at end of file
......@@ -29,7 +29,7 @@ func RunWindowsServer() {
fmt.Printf(`欢迎使用 Gin-Vue-Admin
默认自动化文档地址:http://127.0.0.1%s/swagger/index.html
默认前端文件运行地址:http://127.0.0.1:8080
默认前端文件运行地址:http://127.0.0.1:8000
`, address)
global.GVA_LOG.Error(s.ListenAndServe().Error())
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册