【docker系列】(202307) 构建dashboard的arm镜像

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
############################ 1.下载仓库 ############################
[root@ningan ~]# pwd
/root

[root@ningan ~]# git clone https://github.com/kubernetes/dashboard.git
Cloning into 'dashboard'...
remote: Enumerating objects: 95919, done.
remote: Counting objects: 100% (445/445), done.
remote: Compressing objects: 100% (167/167), done.
remote: Total 95919 (delta 307), reused 401 (delta 274), pack-reused 95474
Receiving objects: 100% (95919/95919), 183.17 MiB | 5.84 MiB/s, done.
Resolving deltas: 100% (56815/56815), done.

############################ 2.找到main函数 ############################
[root@ningan ~]# cd dashboard

[root@ningan dashboard]# git checkout v2.4.0
Note: checking out 'v2.4.0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

git checkout -b <new-branch-name>

HEAD is now at e75ebcf68 Prepare for v2.4.0 release (#6536)

[root@ningan dashboard]# ls
aio code-of-conduct.md cypress docs go.sum i18n license-checker-config.json OWNERS_ALIASES package-lock.json ROLES.md SECURITY.md tsconfig.json
angular.json CONTRIBUTING.md cypress.json go.mod gulpfile.babel.js LICENSE OWNERS package.json README.md SECURITY_CONTACTS src
[root@ningan dashboard]#
[root@ningan dashboard]# cd src
[root@ningan src]# ls
app
[root@ningan src]# cd app/
[root@ningan app]# ls
backend frontend
[root@ningan app]# cd backend/
[root@ningan backend]# ls
api args auth cert client dashboard.go errors handler integration plugin resource scaling settings sync systembanner validation
[root@ningan backend]#


############################ 3.编译arm二进制 ############################
[root@ningan backend]# GOOS=linux GOARCH=arm64 go build -o bin/dashboard-arm ./dashboard.go
[root@ningan backend]#
[root@ningan backend]# cd bin
[root@ningan bin]# ll
total 49880
drwxr-xr-x 2 root root 4096 Jul 13 15:36 ./
drwxr-xr-x 18 root root 4096 Jul 13 15:36 ../
-rwxr-xr-x 1 root root 51063857 Jul 13 15:36 dashboard-arm*


############################ 4.编写Dockerfile ############################
[root@ningan bin]# cat Dockerfilearm
FROM xxx # 此处写成自己的一个arm基础镜像

ADD ./dashboard-arm /dashboard
USER root
EXPOSE 8443 9090
ENTRYPOINT ["/dashboard"]

############################ 5.构建镜像 ############################
[root@ningan bin]# docker build -t dashboard:v2.4.0-arm64 . -f Dockerfilearm
Sending build context to Docker daemon 51.07MB
Step 1/5 : FROM xxx/istio/csm_stg/src_image_build/base_go:1.16
---> 3ad4565d534b
Step 2/5 : ADD ./dashboard-arm /dashboard
---> 7e3d77933b5a
Step 3/5 : USER root
---> [Warning] The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested
---> Running in 2d9408e745f1
Removing intermediate container 2d9408e745f1
---> 177800207a1e
Step 4/5 : EXPOSE 8443 9090
---> [Warning] The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested
---> Running in 932853d116b3
Removing intermediate container 932853d116b3
---> 7ea9c1c8d5e5
Step 5/5 : ENTRYPOINT ["/dashboard"]
---> [Warning] The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested
---> Running in ce7ee0cc5586
Removing intermediate container ce7ee0cc5586
---> e14cdf3553f3
Successfully built e14cdf3553f3
Successfully tagged dashboard:v2.4.0-arm64


############################ 6.测试 ############################
启动是可以成功启动了,但是一直重启,也不知道为啥

【docker系列】(202307) 构建dashboard的arm镜像
http://example.com/2023/07/13/docker/【docker系列】(202307) 构建dashboard的arm镜像/
作者
ningan123
发布于
2023年7月13日
许可协议