瀏覽代碼

feature: 更新dockerfile

chenqinghe 4 年之前
父節點
當前提交
940a9bf912
共有 5 個文件被更改,包括 11 次插入96 次删除
  1. 11
    8
      Dockerfile
  2. 0
    17
      cmd/webpprof/index.html
  3. 0
    62
      cmd/webpprof/main.go
  4. 0
    3
      go.mod
  5. 0
    6
      go.sum

+ 11
- 8
Dockerfile 查看文件

@@ -4,13 +4,19 @@ COPY . /app
4 4
 
5 5
 WORKDIR /app
6 6
 
7
-RUN GOOS=linux GOARCH=amd64 go build cmd/webpprof -o webpprof
7
+ENV GOOS=linux \
8
+    GOARCH=amd64 \
9
+    GOPROXY=https://goproxy.cn,direct \
10
+    GO111MODULE=on
11
+
12
+RUN go build -o webpprof github.com/google/pprof/cmd/webpprof \
13
+    && ls
8 14
 
9 15
 
10 16
 FROM node:latest as frontend
11 17
 
12 18
 # 添加taobao镜像源并安装vue-cli 3.0
13
-RUN npm config set registry https://registry.npmjs.org \
19
+RUN npm config set registry http://registry.npm.taobao.org \
14 20
     && npm install -g @vue/cli
15 21
 
16 22
 COPY web /web
@@ -20,16 +26,13 @@ WORKDIR /web
20 26
 # 安装依赖并构建
21 27
 RUN npm install && npm run build
22 28
 
23
-
24
-FROM alpine:latest
29
+# 这里一定要使用带glibc的apline,不然会报standard_init_linux.go:207: exec user process caused "no such file or directory" 错误
30
+FROM frolvlad/alpine-glibc:latest
25 31
 
26 32
 COPY --from=backend /app/webpprof /app/webpprof
27 33
 
28 34
 COPY --from=frontend /web/dist/   /app/html/
29 35
 
30
-EXPOSE 80
36
+EXPOSE 8090
31 37
 
32 38
 ENTRYPOINT ["/app/webpprof"]
33
-
34
-
35
-

+ 0
- 17
cmd/webpprof/index.html 查看文件

@@ -1,17 +0,0 @@
1
-<!DOCTYPE html>
2
-<html lang="en">
3
-<head>
4
-    <meta charset="UTF-8">
5
-    <title>upload pprof profile file</title>
6
-</head>
7
-<body>
8
-
9
-<form action="http://localhost:8090/upload" method="post" enctype="multipart/form-data">
10
-    <input type="file" name="file">
11
-    <input type="submit" name="上传" id="">
12
-</form>
13
-
14
-
15
-
16
-</body>
17
-</html>

+ 0
- 62
cmd/webpprof/main.go 查看文件

@@ -18,35 +18,10 @@ import (
18 18
 func main() {
19 19
 	r := gin.Default()
20 20
 
21
-	r.OPTIONS("/upload", func(c *gin.Context) {
22
-		c.Header("Access-Control-Allow-Origin", "http://localhost:8080")
23
-		c.Header("Access-Control-Allow-Credentials", "true")
24
-		c.Header("Access-Control-Allow-Method", "POST")
25
-		//c.Header("","")
26
-		//c.Header("","")
27
-		//Access-Control-Allow-Origin: *
28
-		//	Access-Control-Allow-Credentials: true
29
-		//Access-Control-Expose-Headers: FooBar
30
-		//Content-Type: text/html; charset=utf-8
31
-	})
32 21
 	r.POST("/upload", upload)
33
-
34 22
 	r.GET("/pprof/:hash/:method", mapping)
35
-	//r.GET("/pprof/:hash/", dot)
36
-	//r.GET("/pprof/:hash/top", top)
37
-	//r.GET("/pprof/:hash/disasm", disasm)
38
-	//r.GET("/pprof/:hash/source", source)
39
-	//r.GET("/pprof/:hash/peek", peek)
40
-	//r.GET("/pprof/:hash/flamegraph", flamegraph)
41
-	//r.GET("/pprof/:hash/saveconfig", saveconfig)
42
-	//r.GET("/pprof/:hash/deleteconfig", deleteconfig)
43
-
44
-	go func() {
45
-		http.ListenAndServe(":8091", nil)
46
-	}()
47 23
 
48 24
 	r.Run(":8090")
49
-
50 25
 }
51 26
 
52 27
 func mapping(c *gin.Context) {
@@ -146,40 +121,3 @@ func hash(data []byte) string {
146 121
 func fileExist(file string) bool {
147 122
 	return false
148 123
 }
149
-
150
-//
151
-//func dot(c *gin.Context)    {}
152
-//func top(c *gin.Context)    {}
153
-//func disasm(c *gin.Context) {}
154
-//func source(c *gin.Context) {}
155
-//func peek(c *gin.Context)   {}
156
-//func flamegraph(c *gin.Context) {
157
-//	hash := c.Param("hash")
158
-//	if hash == "" {
159
-//		c.AbortWithStatus(http.StatusNotFound)
160
-//		return
161
-//	}
162
-//
163
-//	filename := fmt.Sprintf("%s.pprof", hash)
164
-//	f, err := os.OpenFile(filename, os.O_RDONLY, os.ModePerm)
165
-//	if err != nil {
166
-//		c.AbortWithError(http.StatusInternalServerError, err)
167
-//		return
168
-//	}
169
-//	defer f.Close()
170
-//	prof, err := profile.Parse(f)
171
-//	if err != nil {
172
-//		c.AbortWithError(http.StatusInternalServerError, err)
173
-//		return
174
-//	}
175
-//
176
-//	ui, err := driver.MakeWebInterface(prof, nil)
177
-//	if err != nil {
178
-//		c.AbortWithError(http.StatusInternalServerError, err)
179
-//		return
180
-//	}
181
-//
182
-//	ui.Flamegraph(c.Writer, c.Request)
183
-//}
184
-//func saveconfig(c *gin.Context)   {}
185
-//func deleteconfig(c *gin.Context) {}

+ 0
- 3
go.mod 查看文件

@@ -3,9 +3,6 @@ module github.com/google/pprof
3 3
 go 1.14
4 4
 
5 5
 require (
6
-	github.com/chzyer/logex v1.1.10 // indirect
7
-	github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e
8
-	github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect
9 6
 	github.com/gin-gonic/gin v1.6.3
10 7
 	github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6
11 8
 	github.com/sirupsen/logrus v1.6.0

+ 0
- 6
go.sum 查看文件

@@ -1,9 +1,3 @@
1
-github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
2
-github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
3
-github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=
4
-github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
5
-github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=
6
-github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
7 1
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
8 2
 github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
9 3
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=