使用docker-compose部署
- 创建docker网络
docker network create --subnet=172.20.0.0/16 gps_network
1
- 文件目录结构
├─d
├── docker
├─── gps
├──── docker-compose.yml
├──── api
├───── Dockerfile
├───── gps-api-1.0.jar
├──── engine
├───── Dockerfile
├───── gps-engine-1.0.jar
├──── gate
├───── Dockerfile
├───── gps-gate-1.0.jar
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
- docker-compose.yml文件
version: '2'
services:
gps-api:
build: ./api
image: gps/gps-api
ports:
- "8085:8085"
extra_hosts:
- "myhbase:192.168.1.187"
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- /d/docker/gps/api/upgrade:/up
- /d/docker/gps/api/ipdb:/ipdb
- /d/docker/gps/api/cert:/cert
restart: always
environment:
- spring.profiles.active=prod
- MYSQL_HOST=172.18.98.0
- MYSQL_PORT=3306
- MYSQL_USERNAME=root
- MYSQL_PASSWORD=gps123
- REDIS_HOST=172.18.98.0
- REDIS_PORT=6379
- KAFKA_GROUP=consumerForPushUI
- KAFKA_ADDRESS=172.18.98.0:9092
networks:
gps_default:
ipv4_address: 172.20.0.30
gps-gate:
build: ./gate
image: gps/gps-gate
ports:
- "6868:6868"
- "6868:6868/udp"
logging:
options:
max-size: "1g"
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
restart: always
environment:
- spring.profiles.active=prod
- REDIS_HOST=172.18.98.0
- REDIS_PORT=6379
- REDIS_PWD=
- KAFKA_GROUP=consumerForCommand
# - KAFKA_ADDRESS=172.18.98.0:9092,172.18.221.127:9092,172.18.221.128:9092
- KAFKA_ADDRESS=172.18.98.0:9092
ulimits:
nproc: 65535
nofile:
soft: 20000
hard: 40000
networks:
gps_default:
ipv4_address: 172.20.0.10
gps-engine:
build: ./engine
image: gps/gps-engine
#network_mode: "host"
ports:
- "8083:8083"
extra_hosts:
- "myhbase:192.168.1.187"
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
restart: always
environment:
- spring.profiles.active=prod
- MYSQL_HOST=172.18.98.0
- MYSQL_PORT=3306
- MYSQL_USERNAME=root
- MYSQL_PASSWORD=gps123
- REDIS_HOST=172.18.98.0
- REDIS_PORT=6379
- REDIS_PWD=
- KAFKA_ADDRESS=172.18.98.0:9092
networks:
gps_default:
ipv4_address: 172.20.0.20
networks:
gps_default:
external:
name: gps_network
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
- 启动
cd /d/docker/gps
docker-compose up -d --build gps-api
docker-compose up -d --build gps-engine
docker-compose up -d --build gps-gate
1
2
3
4
2
3
4
- 查看log
docker logs -f --tail=2000 gps_gps-api_1
1