forked from vachirachat/backendSenior
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-cheatsheet
133 lines (99 loc) · 4.04 KB
/
docker-cheatsheet
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
--> Code pattern
--> Run Procedure
// Start mongoDB
docker run --rm -itd -p 27016:27017 --name mongo_proxy -v /Users/waritphon/Downloads/Senior/mongo_proxy:/data/db mongo
docker run --rm -itd -p 27017:27017 --name mongo_controller -v /Users/waritphon/Downloads/Senior:/data/db mongo
docker run -p 5555:5555 -p 5005:5005 -p 5050:5050 -d -t --name docker_upload --rm docker_upload
env GOOS=linux GOARCH=arm64 go build ...
//docker network list
docker network inspect bridge
// docker run --rm -itd -p 27017:27017 -v /Users/waritphon/Downloads/Senior:/data/db mongo
// chat-route-handler
// userID := "60001d1cf0a50a974cee376d"
// or 6036f05799a05bbc180bd3cb
// routerGroup.GET("/ws" /*, handler.authMiddleware.AuthRequired() */, func(context *gin.Context) {
// // Prin
// var message []BackupMessage
// conn.DB("backup").C("message").Find(nil).All(&message)
// for _, v := range message {
// log.Println(v, "\n")
// }
// return &proto.Empty{}, nil
// IN main client-> proxy
// // TO TEST must DELETE : TEST Message
// Message := backup.RawMessage{
// MessageID: bson.ObjectId("60001d1cf0a50a974cee376d").Hex(),
// TimeStamp: time.Now().Unix(),
// RoomID: bson.ObjectIdHex("60001d1cf0a50a974cee376d").Hex(),
// UserID: bson.ObjectIdHex("60001e33584cb6da2059f5b7").Hex(),
// ClientUID: "60001d1cf0a50a974cee376d",
// Data: "Test-message-1",
// Type: "CHAT",
// }
// User in OnMessageIn on_message_plugin_port
// feature, err := temp.OnMessageIn(ctx, &proto.Chat{
// MessageId: msg.MessageID,
// RoomId: msg.RoomID,
// Timestamp: msg.TimeStamp,
// UserId: msg.UserID,
// Type: msg.Type,
// ClientUid: msg.ClientUID,
// Data: msg.Data,
// })
// -> simple websocket-check
// ws://localhost:8090/api/v1/chat/ws?userId=60001260f0a50a974cee2f95
// {"type":"CHAT",
// "payload":{
// "data":"hi 1149 --> Test in DB -> TO javascript new",
// "uid":"60007606000000000400a304",
// "roomId":"60001e33584cb6da2059f5b7",
// "userId":"60001d1cf0a50a974cee376d",
// "type":"TEXT"}
// }
ws://localhost:8090/api/v1/chat/ws?userId=60001260f0a50a974cee2f95
{"type":"CHAT",
"payload":{
"data":"Test in Client",
"uid":"60007606000000000400a304",
"roomId":"60001e33584cb6da2059f5b7",
"userId":"60001260f0a50a974cee2f95",
"type":"TEXT"}
}
{
"status": "success",
"token": {
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NfdXVpZCI6ImYyNmFiYjFkLWVmMDYtNDM1YS1iYmUxLWIzZWI0YzMzMGU5OSIsImF1dGhvcml6ZWQiOnRydWUsImV4cCI6MjIxNDIxMzE1OSwicm9sZSI6InVzZXIiLCJ1c2VyX2lkIjoiNjAzNmYwNTc5OWEwNWJiYzE4MGJkM2NiIn0.u5s30RypgKMrnpEixHiStbjLejVVQMUH9GakiowoIF8",
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MTQ4MTgwMTksInJlZnJlc2hfdXVpZCI6IjBkZTVkMmJlLTE5MGItNGExMi05Y2ZmLWY3NTRkNjBjYzllNyIsInVzZXJfaWQiOiI2MDM2ZjA1Nzk5YTA1YmJjMTgwYmQzY2IifQ.CG6HIrrK35HA1EI-PqxDINa6XjZ-tP73LXWnxpJZLFs",
"expiresAt": 2214213159,
"refreshExpiresAt": 1614818019
}
}
// Run Protoc GO.
in path share/
protoc --go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
backup.proto
--> Helper <--
// must install to run mac-go/build in docker
docker pull karalabe/xgo-latest
docker build -t [name-image] .
docker run --publish 2020:2020 --name [name-container] --rm [name-image]
--> Build go
env GOOS=target-OS GOARCH=target-architecture go build package-import-path
// Docker go-build use linux / arm64
env GOOS=linux GOARCH=arm64 go build ...
--> name-image
#upload-server
# 2020 is upload
# 5050 is plugin-link
docker build -t upload-server .
docker build -t proxy-execable .
docker run --publish 2020:2020 --name test-upload --rm upload-server
chmod +x /Users/waritphon/code-fast-test/golang-upload-exec/file-upload/upload
--> Connect mutiple port to docker
docker run -p 5005:5005 -p 5050:5050 -p 6000:6000 -d -t --name proxy-execable --rm proxy-execable
// Run exec- in docker
docker exec -ti 4ff36ae35dbd sh -c "cat /app/go_server/docker-cheatsheet"
#####
-->Demo Connect mutiple port to docker Demo
docker run -p 5555:5555 -p 5005:5005 -p 5050:5050 -d -t --name docker_upload --rm docker_upload