码迷,mamicode.com
首页 > Web开发 > 详细

EdgeX Foundry初体验(五)-- Web Console图形界面(v1.0.0)

时间:2020-06-19 16:25:22      阅读:85      评论:0      收藏:0      [点我收藏+]

标签:rac   图形   too   eee   sed -e   listen   btree   uid   common   

技术图片

【源码部署新版edgex-ui】

在yml文件中注释掉ui如下部分:

  ui:
    image: edgexfoundry/docker-edgex-ui-go:0.1.1
    ports:
      - "4000:4000"
    container_name: edgex-ui-go
    hostname: edgex-ui-go
    networks:
      - edgex-network
    volumes:
      - db-data:/data/db
      - log-data:/edgex/logs
      - consul-config:/consul/config
      - consul-data:/consul/data
    depends_on:
      - data
      - command

注释后:

#  ui:
#    image: edgexfoundry/docker-edgex-ui-go:0.1.1
#    ports:
#      - "4000:4000"
#    container_name: edgex-ui-go
#    hostname: edgex-ui-go
#    networks:
#      - edgex-network
#    volumes:
#      - db-data:/data/db
#      - log-data:/edgex/logs
#      - consul-config:/consul/config
#      - consul-data:/consul/data
#    depends_on:
#      - data
#      - command

删除之前版本的ui:

docker container ls
docker stop 3c6c76f039d9
docker container rm 3c6c76f039d9

构建go环境:

1.go下载最新的版本(linux),解压出go文件放在 /usr/local/下

2.环境变量配置

vi /etc/profile

export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin

3.运行环境变量

source /etc/profile

4.确认环境正常

[root@edgex src]# go version
go version go1.14.4 linux/amd64

5.设置绕墙:

[root@edgex ~]# go env -w GOPROXY=https://goproxy.cn

[第一种运行方式:源码编译并在edgex本机运行UI]

部署下载edgex-ui-go最新版源码编译:

源码参考:https://github.com/edgexfoundry/edgex-ui-go

cd $GOROOT/src
git clone http://github.com/edgexfoundry/edgex-ui-go.git github.com/edgexfoundry/edgex-ui-go      
cd $GOROOT/src/github.com/edgexfoundry/edgex-ui-go
make build     //如果正常运行 则忽略下面的“注意”

注意:在运行make bulid的时候出现了找不到version版本号的情况,所以重新创建一个版本号(此时稳定版本为1.2.1)的文件,以便于编译:

[root@edgex edgex-ui-go]# vim VERSION
1.2.1

再次运行就正常了:

[root@edgex edgex-ui-go]# make build         
CGO_ENABLED=0 GO111MODULE=on go build -ldflags "-X github.com/edgexfoundry/edgex-ui-go.Version=1.2.1" -o cmd/edgex-ui-server/edgex-ui-server ./cmd/edgex-ui-server
go: downloading github.com/pelletier/go-toml v1.7.0
go: downloading gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce
go: downloading github.com/gorilla/mux v1.7.1
go: downloading github.com/edgexfoundry/go-mod-registry v0.1.11
go: downloading github.com/gorilla/websocket v1.4.0
go: downloading github.com/eclipse/paho.mqtt.golang v1.2.0
go: downloading github.com/mitchellh/consulstructure v0.0.0-20190329231841-56fdc4d2da54
go: downloading github.com/pkg/errors v0.8.1
go: downloading github.com/hashicorp/consul/api v1.4.0
go: downloading golang.org/x/net v0.0.0-20190923162816-aa69164e4478
go: downloading github.com/mitchellh/mapstructure v1.2.2
go: downloading github.com/mitchellh/copystructure v1.0.0
go: downloading github.com/cenkalti/backoff v2.2.1+incompatible
go: downloading github.com/hashicorp/go-rootcerts v1.0.2
go: downloading github.com/hashicorp/serf v0.9.0
go: downloading github.com/hashicorp/go-hclog v0.12.2
go: downloading github.com/hashicorp/go-cleanhttp v0.5.1
go: downloading github.com/mitchellh/reflectwalk v1.0.1
go: downloading github.com/mattn/go-isatty v0.0.12
go: downloading github.com/fatih/color v1.9.0
go: downloading github.com/mattn/go-colorable v0.1.6
go: downloading golang.org/x/sys v0.0.0-20200409092240-59c9f1ba88fa
go: downloading github.com/armon/go-metrics v0.3.3
go: downloading github.com/hashicorp/go-immutable-radix v1.2.0
go: downloading github.com/hashicorp/golang-lru v0.5.4
CGO_ENABLED=0 GO111MODULE=on go build ./...

运行此UI:

[root@edgex edgex-ui-go]# make run              //如果需要后台运行执行  make run &
cd bin && ./edgex-ui-go-launch.sh
2020/06/18 14:54:19 Loading configuration from: /usr/local/go/src/github.com/edgexfoundry/edgex-ui-go/cmd/edgex-ui-server/res/configuration.toml
2020/06/18 14:54:19 Connect to memoryDB success !
2020/06/18 14:54:19 EdgeX UI Server Listen On :4000

在浏览器中查看:

技术图片

 

【第二种方式:继承第一种方式的环境】

[root@edgex edgex-ui-go]# ll
total 76
drwxr-xr-x.  3 root root    20 Jun 18 14:04 assets
drwxr-xr-x.  2 root root    35 Jun 18 14:04 bin
drwxr-xr-x.  3 root root    29 Jun 18 14:04 cmd
-rw-r--r--.  1 root root  3959 Jun 18 14:04 CONTRIBUTING.md
-rw-r--r--.  1 root root    10 Jun 18 15:09 coverage.out
-rw-r--r--.  1 root root   923 Jun 18 15:13 Dockerfile
-rw-r--r--.  1 root root   898 Jun 18 14:04 Dockerfile.build
drwxr-xr-x.  4 root root    72 Jun 18 14:04 docs
-rw-r--r--.  1 root root  1019 Jun 18 14:04 go.mod
-rw-r--r--.  1 root root 20718 Jun 18 14:46 go.sum
drwxr-xr-x. 10 root root   139 Jun 18 14:04 internal
-rw-r--r--.  1 root root   675 Jun 18 14:04 Jenkinsfile
-rw-r--r--.  1 root root 11357 Jun 18 14:04 LICENSE
-rw-r--r--.  1 root root   951 Jun 18 14:04 Makefile
-rw-r--r--.  1 root root  2599 Jun 18 14:04 README.md
-rw-r--r--.  1 root root     6 Jun 18 14:50 VERSION
-rw-r--r--.  1 root root   155 Jun 18 14:04 version.go

修改Dockerfile文件里的路径:

[root@edgex edgex-ui-go]# vim Dockerfile

ARG BASE=golang:1.13-alpine FROM ${BASE} AS builder ARG MAKE="make cmd/edgex-ui-server/edgex-ui-server" ARG ALPINE_PKG_BASE="make git" ARG ALPINE_PKG_EXTRA="" LABEL Name=edgex-ui-go LABEL license=SPDX-License-Identifier: Apache-2.0 copyright=Copyright (c) 2018-2020: Intel RUN sed -e s/dl-cdn[.]alpinelinux.org/nl.alpinelinux.org/g -i~ /etc/apk/repositories RUN apk update && apk add --no-cache ${ALPINE_PKG_BASE} ${ALPINE_PKG_EXTRA} ENV GO111MODULE=on WORKDIR /go/src/github.com/edgexfoundry/edgex-ui-go COPY go.mod . COPY Makefile . RUN make update COPY . . RUN ${MAKE} FROM alpine EXPOSE 4000 COPY --from=builder /src/github.com/edgexfoundry/edgex-ui-go/cmd/edgex-ui-server /go/src/github.com/edgexfoundry/edgex-ui-go/cmd/edgex-ui-server WORKDIR /go/src/github.com/edgexfoundry/edgex-ui-go/cmd/edgex-ui-server ENTRYPOINT ["./edgex-ui-server","-conf=res/docker/configuration.toml"]

利用Dockerfile进行创建edgex-ui容器

将edgex所在的主机放上“梯子”,并设置go的代理:

[root@edgex edgex-ui-go]# go env -w GOPROXY=https://goproxy.cn

[root@edgex edgex-ui-go]# docker build ./ -t edgex-ui-go:v1.2.1 --network=host --build-arg HTTP_PROXY=http://192.168.0.252:10809
Sending build context to Docker daemon 20.63MB
Step 1/21 : ARG BASE=golang:1.13-alpine
Step 2/21 : FROM ${BASE} AS builder
---> cea245765db1
Step 3/21 : ARG MAKE="make cmd/edgex-ui-server/edgex-ui-server"
---> Using cache
---> c6b557c04d6e
Step 4/21 : ARG ALPINE_PKG_BASE="make git"
---> Using cache
---> 346f167c944a
Step 5/21 : ARG ALPINE_PKG_EXTRA=""
---> Using cache
---> a13cf70818a1
Step 6/21 : LABEL Name=edgex-ui-go
---> Using cache
---> 268ce4773ed2
Step 7/21 : LABEL license=‘SPDX-License-Identifier: Apache-2.0‘ copyright=‘Copyright (c) 2018-2020: Intel‘
---> Using cache
---> 15b34499a850
Step 8/21 : RUN sed -e ‘s/dl-cdn[.]alpinelinux.org/nl.alpinelinux.org/g‘ -i~ /etc/apk/repositories
---> Using cache
---> ac5e43fadefa
Step 9/21 : RUN apk update && apk add --no-cache ${ALPINE_PKG_BASE} ${ALPINE_PKG_EXTRA}
---> Using cache
---> f1b030d38912
Step 10/21 : ENV GO111MODULE=on
---> Using cache
---> 7486d1656ff9
Step 11/21 : WORKDIR /go/src/github.com/edgexfoundry/edgex-ui-go
---> Using cache
---> a391d47fd426
Step 12/21 : COPY go.mod .
---> Using cache
---> f79593e83522
Step 13/21 : COPY Makefile .
---> Using cache
---> 6fdd37e51ec6
Step 14/21 : RUN make update
---> Running in f8f885c541b7
CGO_ENABLED=0 GO111MODULE=on go mod download
go: finding github.com/BurntSushi/toml v0.3.1
go: finding github.com/DataDog/datadog-go v3.2.0+incompatible
go: finding github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
go: finding github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4
go: finding github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e
go: finding github.com/armon/go-metrics v0.3.3
go: finding github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310
go: finding github.com/beorn7/perks v1.0.1
go: finding github.com/bgentry/speakeasy v0.1.0
go: finding github.com/cenkalti/backoff v2.2.1+incompatible
go: finding github.com/cespare/xxhash/v2 v2.1.1
go: finding github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible
go: finding github.com/circonus-labs/circonusllhist v0.1.3
go: finding github.com/davecgh/go-spew v1.1.1
go: finding github.com/eclipse/paho.mqtt.golang v1.2.0
go: finding github.com/edgexfoundry/go-mod-registry v0.1.11
go: finding github.com/fatih/color v1.9.0
go: finding github.com/go-kit/kit v0.9.0
go: finding github.com/go-logfmt/logfmt v0.4.0
go: finding github.com/go-stack/stack v1.8.0
go: finding github.com/gogo/protobuf v1.1.1
go: finding github.com/golang/protobuf v1.3.2
go: finding github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c
go: finding github.com/google/go-cmp v0.4.0
go: finding github.com/google/gofuzz v1.0.0
go: finding github.com/gorilla/mux v1.7.1
go: finding github.com/gorilla/websocket v1.4.0
go: finding github.com/hashicorp/consul/api v1.4.0
go: finding github.com/hashicorp/consul/sdk v0.4.0
go: finding github.com/hashicorp/errwrap v1.0.0
go: finding github.com/hashicorp/go-cleanhttp v0.5.1
go: finding github.com/hashicorp/go-hclog v0.12.2
go: finding github.com/hashicorp/go-immutable-radix v1.2.0
go: finding github.com/hashicorp/go-msgpack v0.5.5
go: finding github.com/hashicorp/go-multierror v1.0.0
go: finding github.com/hashicorp/go-retryablehttp v0.5.3
go: finding github.com/hashicorp/go-rootcerts v1.0.2
go: finding github.com/hashicorp/go-sockaddr v1.0.2
go: finding github.com/hashicorp/go-syslog v1.0.0
go: finding github.com/hashicorp/go-uuid v1.0.1
go: finding github.com/hashicorp/go.net v0.0.1
go: finding github.com/hashicorp/golang-lru v0.5.4
go: finding github.com/hashicorp/logutils v1.0.0
go: finding github.com/hashicorp/mdns v1.0.1
go: finding github.com/hashicorp/memberlist v0.2.0
go: finding github.com/hashicorp/serf v0.9.0
go: finding github.com/json-iterator/go v1.1.9
go: finding github.com/julienschmidt/httprouter v1.2.0
go: finding github.com/konsorten/go-windows-terminal-sequences v1.0.1
go: finding github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515
go: finding github.com/kr/pretty v0.2.0
go: finding github.com/kr/pty v1.1.1
go: finding github.com/kr/text v0.1.0
go: finding github.com/mattn/go-colorable v0.1.6
go: finding github.com/mattn/go-isatty v0.0.12
go: finding github.com/matttproud/golang_protobuf_extensions v1.0.1
go: finding github.com/miekg/dns v1.1.26
go: finding github.com/mitchellh/cli v1.0.0
go: finding github.com/mitchellh/consulstructure v0.0.0-20190329231841-56fdc4d2da54
go: finding github.com/mitchellh/copystructure v1.0.0
go: finding github.com/mitchellh/go-homedir v1.1.0
go: finding github.com/mitchellh/go-testing-interface v1.0.0
go: finding github.com/mitchellh/go-wordwrap v1.0.0
go: finding github.com/mitchellh/gox v0.4.0
go: finding github.com/mitchellh/iochan v1.0.0
go: finding github.com/mitchellh/mapstructure v1.2.2
go: finding github.com/mitchellh/reflectwalk v1.0.1
go: finding github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
go: finding github.com/modern-go/reflect2 v1.0.1
go: finding github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223
go: finding github.com/pascaldekloe/goe v0.1.0
go: finding github.com/pelletier/go-toml v1.7.0
go: finding github.com/pkg/errors v0.8.1
go: finding github.com/pmezard/go-difflib v1.0.0
go: finding github.com/posener/complete v1.1.1
go: finding github.com/prometheus/client_golang v1.4.0
go: finding github.com/prometheus/client_model v0.2.0
go: finding github.com/prometheus/common v0.9.1
go: finding github.com/prometheus/procfs v0.0.8
go: finding github.com/ryanuber/columnize v2.1.0+incompatible
go: finding github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529
go: finding github.com/sirupsen/logrus v1.4.2
go: finding github.com/stretchr/objx v0.1.1
go: finding github.com/stretchr/testify v1.4.0
go: finding github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926
go: finding golang.org/x/crypto v0.0.0-20191106202628-ed6320f186d4
go: finding golang.org/x/net v0.0.0-20190923162816-aa69164e4478
go: finding golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
go: finding golang.org/x/sys v0.0.0-20200409092240-59c9f1ba88fa
go: finding golang.org/x/text v0.3.2
go: finding golang.org/x/tools v0.0.0-20190907020128-2ca718005c18
go: finding golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
go: finding gopkg.in/alecthomas/kingpin.v2 v2.2.6
go: finding gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15
go: finding gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce
go: finding gopkg.in/yaml.v2 v2.2.8
Removing intermediate container f8f885c541b7
---> 3d3ba33b2765
Step 15/21 : COPY . .
---> 29507bdedd66
Step 16/21 : RUN ${MAKE}
---> Running in 01f5ff57deaa
CGO_ENABLED=0 GO111MODULE=on go build -ldflags "-X github.com/edgexfoundry/edgex-ui-go.Version=1.2.1" -o cmd/edgex-ui-server/edgex-ui-server ./cmd/edgex-ui-server
Removing intermediate container 01f5ff57deaa
---> 0edb93763792
Step 17/21 : FROM alpine
latest: Pulling from library/alpine
Image docker.io/library/alpine:latest uses outdated schema1 manifest format. Please upgrade to a schema2 image for better future compatibility. More information at https://docs.docker.com/registry/spec/deprecated-schema-v1/
df20fa9351a1: Already exists
Digest: sha256:e1f1e9fed5baa4027a2ffe96f5f202a48dd9e4d06ad0a3d378b98d1a4a9ba449
Status: Downloaded newer image for alpine:latest
---> a24bb4013296

Step 18/21 : EXPOSE 4000
---> Using cache
---> d7fd629a6485
Step 19/21 : COPY --from=builder /go/src/github.com/edgexfoundry/edgex-ui-go/cmd/edgex-ui-server /go/src/github.com/edgexfoundry/edgex-ui-go/cmd/edgex-ui-server
---> c429f43f108b
Step 20/21 : WORKDIR /go/src/github.com/edgexfoundry/edgex-ui-go/cmd/edgex-ui-server
---> Running in d07783609eee
Removing intermediate container d07783609eee
---> 011ace07a51e
Step 21/21 : ENTRYPOINT ["./edgex-ui-server","-conf=res/docker/configuration.toml"]
---> Running in 247721274bbb
Removing intermediate container 247721274bbb
---> 0d2ea9da9115
Successfully built 0d2ea9da9115

查看新构建的image 名字叫做edgex-ui-go:v1.2.1

[root@edgex edgex-ui-go]# docker images  |grep edgex-ui-go
edgex-ui-go                                                                      v1.2.1              0d2ea9da9115        10 minutes ago      21.1MB
edgexfoundry/docker-edgex-ui-go                                                  1.2.1               88dd3f675921        7 days ago          21.1MB
nexus3.edgexfoundry.org:10004/docker-edgex-ui-go-arm64                           master              ac895030e8fc        12 days ago         20.6MB
edgexfoundry/docker-edgex-ui-go

运行新构建的镜像:

[root@edgex edgex-ui-go]# docker run -it -d -p 4000:4000 --name edgex-ui-go edgex-ui-go:v1.2.1
a695c7ed1e67da3f038df3defb21af9db6ca425dd6a266047f8d6a539b085631

 技术图片

 

 

【直接使用容器运行新版本的ui】

也可以使用容器运行新版本的edgex-ui:

具体可用版本可以在这个地方查看:https://github.com/edgexfoundry/edgex-ui-go/releases

直接在docker-compose.yml文件中修改ui镜像的版本号  0.1.1 --> 1.2.1

技术图片

 

 

 修改保存后,重新拉取ui镜像:

[root@edgex ~]# ls
anaconda-ks.cfg  docker-compose.yml
[root@edgex ~]# pwd
/root
[root@edgex ~]# docker-compose pull 
Pulling volume         ... done
Pulling consul         ... done
Pulling config-seed    ... done
Pulling mongo          ... done
Pulling logging        ... done
Pulling notifications  ... done
Pulling metadata       ... done
Pulling data           ... done
Pulling command        ... done
Pulling scheduler      ... done
Pulling export-client  ... done
Pulling export-distro  ... done
Pulling rulesengine    ... done
Pulling device-virtual ... done
Pulling device-random  ... done
Pulling ui             ... done
Pulling portainer      ... done

重新启动ui:

[root@edgex ~]# docker-compose up -d ui
edgex-files is up-to-date
edgex-mongo is up-to-date
edgex-core-consul is up-to-date
Starting edgex-config-seed ... done
edgex-support-logging is up-to-date
edgex-core-data is up-to-date
edgex-core-metadata is up-to-date
edgex-core-command is up-to-date
edgex-ui-go is up-to-date

查看v1.2.1版本的ui是否正常启动:

技术图片

 

 

 在浏览器中输入本机ip192.168.0.133  端口4000:

技术图片

 

这个时候发现无法访问:在edgex  本机测试端口也是正常:

 

 技术图片

 

 

 最后发现是没有开启数据包转发:

[root@edgex ~]# echo 1 > /proc/sys/net/ipv4/ip_forward

开启后正常访问:

第一步是创建

用户名   admin

密码: admin

确认密码: admin

技术图片

 

 

 创建完成后重新登录:

技术图片

 

 

 

技术图片

 

 数据依然还在 只是新版本将界面换了一下,功能有所增加。

github:https://github.com/edgexfoundry/edgex-ui-go

国内gitee:https://gitee.com/diseng/edgex-ui-go

EdgeX Foundry初体验(五)-- Web Console图形界面(v1.0.0)

标签:rac   图形   too   eee   sed -e   listen   btree   uid   common   

原文地址:https://www.cnblogs.com/horizonli/p/13156550.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!