edgex0.7.1_1.0.1的X86編譯和交叉編譯

一. X86編譯

1. 安裝zeromq庫html

根據setup script安裝:linux

wget https://github.com/zeromq/libzmq/releases/download/v4.2.2/zeromq-4.2.2.tar.gz
tar xvzf zeromq-4.2.2.tar.gz cd zeromq-4.2.2 ./configure sudo make install sudo ldconfig ldconfig -p | grep zmq libzmq.so.5 (libc6,x86-64) => /usr/local/lib/libzmq.so.5 libzmq.so (libc6,x86-64) => /usr/local/lib/libzmq.so export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/

2. 獲取源碼c++

go get github.com/edgexfoundry/edgex-go

3. 安裝依賴包git

edgex0.7.1採用glide管理go工程github

$ glide install [INFO] Lock file (glide.lock) does not exist. Performing update. [INFO] Downloading dependencies. Please wait... [INFO] --> Fetching updates for github.com/BurntSushi/toml [INFO] --> Fetching updates for github.com/eclipse/paho.mqtt.golang [INFO] --> Fetching updates for github.com/stretchr/testify [INFO] --> Fetching updates for github.com/hashicorp/consul [INFO] --> Fetching updates for github.com/docker/docker [INFO] --> Fetching updates for github.com/gorilla/mux [INFO] --> Fetching updates for github.com/docker/go-units [INFO] --> Fetching updates for github.com/go-zoo/bone [INFO] --> Fetching updates for github.com/docker/go-connections [INFO] --> Fetching updates for github.com/mitchellh/consulstructure [INFO] --> Fetching updates for github.com/pelletier/go-toml [INFO] --> Fetching updates for github.com/pebbe/zmq4 [INFO] --> Fetching updates for github.com/robfig/cron [INFO] --> Fetching updates for gopkg.in/mgo.v2 [INFO] --> Fetching updates for gopkg.in/yaml.v2 [INFO] --> Fetching updates for github.com/mattn/go-xmpp [INFO] --> Fetching updates for github.com/satori/go.uuid [INFO] --> Fetching updates for github.com/magiconair/properties [INFO] --> Fetching updates for github.com/docker/distribution [INFO] --> Fetching updates for github.com/gomodule/redigo [INFO] --> Setting version for github.com/mattn/go-xmpp to e543ad3fcd51155e4b39f7487bdfcb5e3772f1ce. [INFO] --> Setting version for github.com/docker/docker to b1116479b23434de7d70710b6454af7cb2484a58. [INFO] --> Setting version for github.com/docker/go-connections to 97c2040d34dfae1d1b1275fa3a78dbdd2f41cf7e. [INFO] --> Setting version for github.com/docker/go-units to 47565b4f722fb6ceae66b95f853feed578a4a51c. [INFO] --> Setting version for github.com/BurntSushi/toml to a368813c5e648fee92e5f6c30e3944ff9d5e8895. [INFO] --> Setting version for github.com/mitchellh/consulstructure to b407c521973b7b902db2f09e65dbf5cb10f2dc5f. [INFO] --> Setting version for github.com/docker/distribution to 16128bbac47f75050e82f7e91b04df33775e0c23. [INFO] --> Setting version for github.com/go-zoo/bone to 9eaad4b99a9a66b85c0cc32cb9691621ccfa4278. [INFO] --> Detected semantic version. Setting version for github.com/pelletier/go-toml to v1.2.0 [INFO] --> Detected semantic version. Setting version for github.com/hashicorp/consul to v1.1.0 [INFO] --> Detected semantic version. Setting version for github.com/stretchr/testify to v1.2.1 [INFO] --> Detected semantic version. Setting version for github.com/gorilla/mux to v1.3.0 [INFO] --> Detected semantic version. Setting version for github.com/pebbe/zmq4 to v1.0.0 [INFO] --> Detected semantic version. Setting version for github.com/robfig/cron to v1.1.0 [INFO] --> Detected semantic version. Setting version for github.com/gomodule/redigo to v2.0.0 [INFO] --> Detected semantic version. Setting version for github.com/magiconair/properties to v1.8.0 [INFO] --> Detected semantic version. Setting version for github.com/satori/go.uuid to v1.2.0 [INFO] --> Detected semantic version. Setting version for github.com/eclipse/paho.mqtt.golang to v1.1.1 [INFO] --> Setting version for gopkg.in/mgo.v2 to 3f83fa5005286a7fe593b055f0d7771a7dce4655. [INFO] --> Setting version for gopkg.in/yaml.v2 to eb3733d160e74a9c7e442f435eb3bea458e1d19f. [INFO] Resolving imports [INFO] --> Fetching updates for github.com/gorilla/context [INFO] --> Fetching updates for github.com/davecgh/go-spew [INFO] --> Fetching updates for github.com/pmezard/go-difflib [INFO] --> Fetching updates for github.com/stretchr/objx [INFO] --> Fetching golang.org/x/net/proxy [WARN] Unable to checkout golang.org/x/net/proxy [ERROR] Error looking for golang.org/x/net/proxy: Cannot detect VCS [INFO] --> Fetching golang.org/x/net/websocket [WARN] Unable to checkout golang.org/x/net/websocket [ERROR] Error looking for golang.org/x/net/websocket: Cannot detect VCS [INFO] --> Fetching updates for github.com/influxdata/influxdb [INFO] --> Fetching updates for github.com/hashicorp/go-cleanhttp [INFO] --> Fetching updates for github.com/hashicorp/go-rootcerts [INFO] --> Fetching updates for github.com/hashicorp/serf [INFO] --> Fetching updates for github.com/cenkalti/backoff [INFO] --> Fetching updates for github.com/mitchellh/copystructure [INFO] --> Fetching updates for github.com/mitchellh/mapstructure [INFO] --> Fetching updates for github.com/opencontainers/go-digest [INFO] --> Fetching updates for github.com/pkg/errors [INFO] --> Fetching golang.org/x/net/context/ctxhttp [WARN] Unable to checkout golang.org/x/net/context/ctxhttp [ERROR] Error looking for golang.org/x/net/context/ctxhttp: Cannot detect VCS [ERROR] Error scanning github.com/influxdata/influxdb/client/v2: cannot find package "." in: /home/wang/.glide/cache/src/https-github.com-influxdata-influxdb/client/v2 [INFO] --> Fetching updates for github.com/mitchellh/go-homedir [INFO] --> Fetching updates for github.com/armon/go-metrics [INFO] --> Fetching updates for github.com/mitchellh/reflectwalk [INFO] --> Fetching updates for github.com/opencontainers/image-spec [INFO] --> Fetching updates for github.com/Microsoft/go-winio [WARN] Unable to set version on golang.org/x/net/proxy to . Err: Cannot detect VCS [INFO] --> Fetching updates for github.com/hashicorp/go-immutable-radix [INFO] --> Fetching updates for github.com/gogo/protobuf [INFO] --> Fetching golang.org/x/sys/windows [WARN] Unable to checkout golang.org/x/sys/windows [ERROR] Error looking for golang.org/x/sys/windows: Cannot detect VCS [INFO] --> Fetching updates for github.com/hashicorp/golang-lru [WARN] Unable to set version on golang.org/x/sys/windows to . Err: Cannot detect VCS [ERROR] Failed to retrieve a list of dependencies: Error resolving imports

提取以下依賴包錯誤:golang

golang.org/x/net/proxy golang.org/x/net/websocket golang.org/x/net/context/ctxhttp golang.org/x/sys/windows

glide搜索到的包應該以git或svn等vcs,但上述proxy、websocket和ctxhttp是net的子包,golang.org/x/net/採用git管理。一樣,golang.org/x/sys採用git管理,windows是sys的子目錄。此時,可在glide.yaml中指定golang.org/x/net和golang.org/x/sys的子包關係:web

- package: golang.org/x/net subpackages: - proxy - websocket - context/ctxhttp - package: golang.org/x/sys subpackages: - windows

此時,直接設置git管理包的鏡像便可,mirror設置:mongodb

glide mirror set https://golang.org/x/net https://github.com/golang/net --vcs git
glide mirror set golang.org/x/sys https://github.com/golang/sys --vcs git

此時,glide install成功執行。docker

注:若安裝的依賴包出現錯誤,多是包版本不對,須要在glide.yaml中指定軟件包的版本(如master中已不包含原來的目錄,致使包檢索依賴不成功,github.com/influxdata/influxdb/client/v2最新版沒有client目錄)。數據庫

edgex1.0.1採用GO111MODULE管理

首先確保go版本在1.11之上,golang從1.11開始內置module管理功能。

因爲golang.org被牆,須要在go.mod中增長替換:

replace ( bitbucket.org/bertimus9/systemstat => github.com/sigma/systemstat v0.0.0-20180207000608-0eeff89b0690 golang.org/x/crypto => github.com/golang/crypto v0.0.0-20181029021203-45a5f77698d3 golang.org/x/net => github.com/golang/net v0.0.0-20181201002055-351d144fa1fc golang.org/x/sync => github.com/golang/sync v0.0.0-20181221193216-37e7f081c4d4 golang.org/x/sys => github.com/golang/sys v0.0.0-20181026203630-95b1ffbd15a5 golang.org/x/tools => github.com/golang/tools v0.0.0-20181112210238-4b1f3b6b1646 )

4. 編譯

make prepare make build

5. 啓動mongodb,而後直接運行make run便可。

在自目錄保存數據,如/home/wang/edgex/db 

sudo mongod --dbpath "/home/wang/edgex/db" mongo init_mongo.js sudo mongod --dbpath "/home/wang/edgex/db" --shutdown sudo chown -R mongodb:mongodb "/home/wang/edgex/db" sudo mongod --dbpath "/home/wang/edgex/db" --auth 
sudo mongod --dbpath "/home/wang/edgex/db" --bind_ip_all ;容許遠程訪問數據庫

make run

若運行報錯,多是mongo權限問題,去除--auth

6.  測試隨機數設備

參考4.3.1. Writing a Device Service in Go編譯隨機數簡單設備,運行device-simple可執行文件。

若不報錯,且數據一直上報,可經過以下地址查詢數據:

http://localhost:48080/api/v1/event/device/RandNum-Device01/100

http://172.61.1.125:48080/api/v1/event
http://172.61.1.125:48071/api/v1/registration
http://172.61.1.125:48080/api/v1/event/count
http://172.61.1.125:48080/api/v1/valuedescriptor
http://172.61.1.125:48081/api/v1/device
http://172.61.1.125:48081/api/v1/deviceservice

可註冊mosquitto雲平臺,上傳至雲平臺:

POST to http://192.168.134.144:48071/api/v1/registration
{"name":"MyMQTTTopic","addressable":{"name":"MyMQTTBroker","protocol":"TCP","address":"192.168.134.144","port":1883,"publisher":"EdgeXExportPublisher","user":"wang","password":"mypass","topic":"a/b/c"},"format":"JSON","enable":true,"destination":"MQTT_TOPIC"}

在主機192.168.134.144上開啓mosquitto,並:

$ mosquitto_sub -t a/b/c {"id":"5cecfb6d902d0f90ade77aca","pushed":0,"device":"RandNum-Device01","created":1559034733008,"modified":0,"origin":1559034733003,"schedule":null,"event":null,"readings":[{"id":"5cecfb6d902d0f90ade77acb","pushed":0,"created":1559034733008,"origin":1559034733002,"modified":0,"device":"RandNum-Device01","name":"Random","value":"58"}]}

二. 交叉編譯

Ubuntu16.04上交叉編譯edgex 1.0.1,編譯後的程序運行於OKMX6DL-S3Cortex-A932位,雙核)。

2.1 交叉編譯工具鏈

板卡自帶交叉編譯工具鏈應用

. /opt/fsl-imx-x11/4.1.15-2.1.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++

通用交叉編譯工具鏈應用

sudo apt-get install g++-5-arm-linux-gnueabihf g++-5-arm-linux-gnueabihf sudo update-alternatives --install /usr/bin/arm-linux-gnueabihf-gcc arm-linux-gnueabihf-gcc /usr/bin/arm-linux-gnueabihf-gcc-5 100 --slave /usr/bin/arm-linux-gnueabihf-g++ arm-linux-gnueabihf-g++ /usr/bin/arm-linux-gnueabihf-g++-5

注:板卡自帶交叉編譯工具鏈編譯edgex不成功,隨採用通用交叉編譯工具鏈。

2.2 交叉編譯zeromq

板卡自帶交叉編譯工具鏈應用

./configure --prefix=/home/wang/edgex/edgex_mx6dl/zeromq-4.2.2/winstall --host=arm-poky-linux-gnueabi  CC="/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc --sysroot=$SDKTARGETSYSROOT -mfloat-abi=hard" CXX="/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ --sysroot=$SDKTARGETSYSROOT -mfloat-abi=hard " make && make install

通用交叉編譯工具鏈應用

./configure --prefix=/home/wang/edgex/edgex_mx6dl/zeromq-4.2.2/winstall --host=arm-poky-linux-gnueabi  CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ make && make install

2.3 交叉編譯edgex

採用通用交叉編譯器編譯edgex,解決包依賴關係後,修改Makefile中編譯選項:

GO=GOARCH=arm CGO_ENABLED=0 GO111MODULE=on go GOCGO=GOARCH=arm CGO_ENABLED=1 CC="arm-linux-gnueabihf-gcc" \ CGO_CFLAGS="-I/home/wang/edgex/edgex_mx6dl/zeromq-4.2.2/winstall/include" CGO_LDFLAGS="-L/home/wang/edgex/edgex_mx6dl/zeromq-4.2.2/winstall/lib -lzmq" \ GO111MODULE=on go

而後執行以下命令編譯

make build

將生成的zeromq庫文件winstall,edgex生成的bin和cmd,及mongodb編譯而成的bin(mongodb自編譯有問題,從網上下載2.6.4版本可執行文件)拷貝到板卡並安裝。

先啓動mongodb,而後執行edgex,同X86上運行順序,可正確執行並運行。

三. docker鏡像製做

生成全部docker可運行命令:

make docker

生成單獨docker可運行命令(以docker_export_distro爲例):

make docker_export_distro

docker_export_distro: docker build \ -f cmd/export-distro/Dockerfile \ --label "git_sha=$(GIT_SHA)" \ -t edgexfoundry/docker-export-distro-go:$(GIT_SHA) \ -t edgexfoundry/docker-export-distro-go:$(DOCKER_TAG) \ .

Dockerfile文件以下:

# # Copyright (c) 2017-2018 # Mainflux # Cavium # # SPDX-License-Identifier: Apache-2.0 # FROM golang:1.11-alpine AS builder ENV GO111MODULE=on WORKDIR /go/src/github.com/edgexfoundry/edgex-go # The main mirrors are giving us timeout issues on builds periodically. # So we can try these. RUN sed -e 's/dl-cdn[.]alpinelinux.org/nl.alpinelinux.org/g' -i~ /etc/apk/repositories RUN apk update && apk add zeromq-dev libsodium-dev pkgconfig build-base git COPY go.mod . #COPY go.sum . RUN go mod download COPY . . RUN make cmd/export-distro/export-distro FROM alpine LABEL license='SPDX-License-Identifier: Apache-2.0' \ copyright='Copyright (c) 2017-2018: Mainflux, Cavium' # The main mirrors are giving us timeout issues on builds periodically. # So we can try these. RUN sed -e 's/dl-cdn[.]alpinelinux.org/nl.alpinelinux.org/g' -i~ /etc/apk/repositories RUN apk --no-cache add zeromq COPY --from=builder /go/src/github.com/edgexfoundry/edgex-go/cmd/export-distro/Attribution.txt / COPY --from=builder /go/src/github.com/edgexfoundry/edgex-go/cmd/export-distro/export-distro / COPY --from=builder /go/src/github.com/edgexfoundry/edgex-go/cmd/export-distro/res/docker/configuration.toml /res/docker/configuration.toml ENTRYPOINT ["/export-distro","--registry","--profile=docker","--confdir=/res"]

上述命令生成兩個鏡像(其中一個在cache中,另外一個爲實際鏡像,兩個tag),沒有容器產生(docker ps -a不顯示,容器被刪除):

export-distro容器鏡像生成日誌:

make docker_export_distro docker build \ -f cmd/export-distro/Dockerfile \ --label "git_sha=48146ead559bd9f27e80af344e3cf787530a1539" \ -t edgexfoundry/docker-export-distro-go:48146ead559bd9f27e80af344e3cf787530a1539 \ -t edgexfoundry/docker-export-distro-go:1.0.2-dev \ . Sending build context to Docker daemon 161MB Step 1/18 : FROM golang:1.11-alpine AS builder ---> e116d2efa2ab Step 2/18 : ENV GO111MODULE=on ---> Using cache ---> 6f17441d1946 Step 3/18 : WORKDIR /go/src/github.com/edgexfoundry/edgex-go ---> Using cache ---> 1e94eec59dac Step 4/18 : RUN sed -e 's/dl-cdn[.]alpinelinux.org/nl.alpinelinux.org/g' -i~ /etc/apk/reposi tories ---> Using cache ---> 48697136fcca Step 5/18 : RUN apk update && apk add zeromq-dev libsodium-dev pkgconfig build-base git ---> Running in bea28e9e5eb1 fetch http://nl.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://nl.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
v3.10.3-17-g2fd4d3cdac [http://nl.alpinelinux.org/alpine/v3.10/main]
v3.10.3-13-g8068beb776 [http://nl.alpinelinux.org/alpine/v3.10/community]
OK: 10340 distinct packages available (1/28) Installing binutils (2.32-r0) (2/28) Installing libmagic (5.37-r1) (3/28) Installing file (5.37-r1) (4/28) Installing gmp (6.1.2-r1) (5/28) Installing isl (0.18-r0) (6/28) Installing libgomp (8.3.0-r0) (7/28) Installing libatomic (8.3.0-r0) (8/28) Installing libgcc (8.3.0-r0) (9/28) Installing mpfr3 (3.1.5-r1) (10/28) Installing mpc1 (1.1.0-r0) (11/28) Installing libstdc++ (8.3.0-r0) (12/28) Installing gcc (8.3.0-r0) (13/28) Installing musl-dev (1.1.22-r3) (14/28) Installing libc-dev (0.7.1-r0) (15/28) Installing g++ (8.3.0-r0) (16/28) Installing make (4.2.1-r2) (17/28) Installing fortify-headers (1.1-r0) (18/28) Installing build-base (0.5-r1) (19/28) Installing nghttp2-libs (1.39.2-r0) (20/28) Installing libcurl (7.66.0-r0) (21/28) Installing expat (2.2.8-r0) (22/28) Installing pcre2 (10.33-r0) (23/28) Installing git (2.22.0-r0) (24/28) Installing libsodium (1.0.18-r0) (25/28) Installing pkgconf (1.6.1-r1) (26/28) Installing libsodium-dev (1.0.18-r0) (27/28) Installing libzmq (4.3.2-r1) (28/28) Installing zeromq-dev (4.3.2-r1) Executing busybox-1.30.1-r2.trigger OK: 182 MiB in 43 packages Removing intermediate container bea28e9e5eb1 ---> 650c39be3c34 Step 6/18 : COPY go.mod . ---> 3afaf7b13163 Step 7/18 : RUN go mod download ---> Running in ca37635ae857 go: finding github.com/stretchr/testify v1.3.0 go: finding github.com/BurntSushi/toml v0.3.1 go: finding github.com/edgexfoundry/go-mod-core-contracts v0.1.0 go: finding github.com/ugorji/go v1.1.4 go: finding github.com/vektra/mockery v0.0.0-20181123154057-e78b021dcbb5 go: finding github.com/imdario/mergo v0.3.6 go: finding github.com/pkg/errors v0.8.1 go: finding github.com/edgexfoundry/go-mod-registry v0.1.0 go: finding github.com/OneOfOne/xxhash v1.2.5 go: finding bitbucket.org/bertimus9/systemstat v0.0.0-20180207000608-0eeff89b0690 go: finding github.com/hashicorp/consul v1.4.2 go: finding github.com/magiconair/properties v1.8.0 go: finding github.com/gorilla/mux v1.7.0 go: finding github.com/go-stack/stack v1.8.0 go: finding github.com/hashicorp/go-cleanhttp v0.5.0 go: finding github.com/gorilla/context v1.1.1 go: finding github.com/robfig/cron v0.0.0-20180505203441-b41be1df6967 go: finding github.com/stretchr/testify v1.2.2 go: finding github.com/mitchellh/go-testing-interface v1.0.0 go: finding github.com/go-kit/kit v0.8.0 go: finding github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 go: finding github.com/golang/tools v0.0.0-20181112210238-4b1f3b6b1646 go: finding github.com/gomodule/redigo v2.0.0+incompatible go: finding github.com/davecgh/go-spew v1.1.1 go: finding github.com/stretchr/objx v0.1.0 go: finding github.com/go-logfmt/logfmt v0.4.0 go: finding github.com/mitchellh/mapstructure v1.1.2 go: finding github.com/edgexfoundry/go-mod-messaging v0.1.8 go: finding github.com/eclipse/paho.mqtt.golang v1.1.1 go: finding github.com/mattn/go-xmpp v0.0.0-20190124093244-6093f50721ed go: finding github.com/hashicorp/serf v0.8.2 go: finding github.com/cenkalti/backoff v2.1.1+incompatible go: finding github.com/pebbe/zmq4 v1.0.0 go: finding github.com/hashicorp/go-rootcerts v1.0.0 go: finding gopkg.in/yaml.v2 v2.2.2 go: finding gopkg.in/eapache/queue.v1 v1.1.0 go: finding github.com/davecgh/go-spew v1.1.0 go: finding github.com/mitchellh/copystructure v1.0.0 go: finding github.com/google/uuid v1.1.0 go: finding github.com/pelletier/go-toml v1.2.0 go: finding github.com/mitchellh/go-homedir v1.0.0 go: finding github.com/mitchellh/consulstructure v0.0.0-20190329231841-56fdc4d2da54 go: finding github.com/stretchr/objx v0.1.1 go: finding github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515 go: finding github.com/pmezard/go-difflib v1.0.0 go: finding github.com/hashicorp/go-syslog v1.0.0 go: finding github.com/hashicorp/memberlist v0.1.3 go: finding github.com/hashicorp/mdns v1.0.0 go: finding github.com/mitchellh/reflectwalk v1.0.0 go: finding github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee go: finding github.com/mitchellh/cli v1.0.0 go: finding github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da go: finding github.com/golang/net v0.0.0-20181023162649-9b4f9f5ad519 go: finding github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f go: finding github.com/hashicorp/go-msgpack v0.5.3 go: finding github.com/miekg/dns v1.0.14 go: finding github.com/mitchellh/gox v0.4.0 go: finding gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 go: finding github.com/posener/complete v1.1.1 go: finding github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c go: finding github.com/hashicorp/go-immutable-radix v1.0.0 go: finding github.com/hashicorp/go-multierror v1.0.0 go: finding github.com/hashicorp/go-uuid v1.0.1 go: finding github.com/mitchellh/iochan v1.0.0 go: finding github.com/mattn/go-isatty v0.0.3 go: finding github.com/bgentry/speakeasy v0.1.0 go: finding github.com/hashicorp/errwrap v1.0.0 go: finding github.com/hashicorp/go.net v0.0.1 go: finding github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310 go: finding github.com/hashicorp/go-uuid v1.0.0 go: finding github.com/hashicorp/logutils v1.0.0 go: finding github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c go: finding github.com/mattn/go-colorable v0.0.9 go: finding github.com/hashicorp/golang-lru v0.5.0 go: finding github.com/hashicorp/go-sockaddr v1.0.0 go: finding github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 go: finding github.com/golang/sys v0.0.0-20181026203630-95b1ffbd15a5 go: finding github.com/golang/sync v0.0.0-20181221193216-37e7f081c4d4 go: finding github.com/golang/crypto v0.0.0-20181029021203-45a5f77698d3 go: finding github.com/fatih/color v1.7.0 go: finding github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e Removing intermediate container ca37635ae857 ---> 2ea018099509 Step 8/18 : COPY . . ---> 84ba3cac05ec Step 9/18 : RUN make cmd/export-distro/export-distro ---> Running in 8a604a3ff538 CGO_ENABLED=1 GO111MODULE=on go build -ldflags "-X github.com/edgexfoundry/edgex-go.Version=1.0.2"                                                                                            -o cmd/export-distro/export-distro ./cmd/export-distro Removing intermediate container 8a604a3ff538 ---> baee083043d1 Step 10/18 : FROM alpine ---> 965ea09ff2eb Step 11/18 : LABEL license='SPDX-License-Identifier: Apache-2.0'       copyright='Copyright (c) 201 7-2018: Mainflux, Cavium'
 ---> Running in a01ad4abfdfb Removing intermediate container a01ad4abfdfb ---> 62e4c99a09a5 Step 12/18 : RUN sed -e 's/dl-cdn[.]alpinelinux.org/nl.alpinelinux.org/g' -i~ /etc/apk/repositories ---> Running in 42ead2d3a8ae Removing intermediate container 42ead2d3a8ae ---> bb1077aa9c15 Step 13/18 : RUN apk --no-cache add zeromq ---> Running in aca49fd6b908 fetch http://nl.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://nl.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
(1/5) Installing libgcc (8.3.0-r0) (2/5) Installing libsodium (1.0.18-r0) (3/5) Installing libstdc++ (8.3.0-r0) (4/5) Installing libzmq (4.3.2-r1) (5/5) Installing zeromq (4.3.2-r1) Executing busybox-1.30.1-r2.trigger OK: 8 MiB in 19 packages Removing intermediate container aca49fd6b908 ---> 87d4d892ce45 Step 14/18 : COPY --from=builder /go/src/github.com/edgexfoundry/edgex-go/cmd/export-distro/Attribu                                                                                           tion.txt /
 ---> fb0838b3634e Step 15/18 : COPY --from=builder /go/src/github.com/edgexfoundry/edgex-go/cmd/export-distro/export-                                                                                           distro /
 ---> cbc71f92b1a8 Step 16/18 : COPY --from=builder /go/src/github.com/edgexfoundry/edgex-go/cmd/export-distro/res/doc                                                                                           ker/configuration.toml /res/docker/configuration.toml ---> 249eb2415b09 Step 17/18 : ENTRYPOINT ["/export-distro","--registry","--profile=docker","--confdir=/res"] ---> Running in 3ce321e2bbc9 Removing intermediate container 3ce321e2bbc9 ---> a9e2f471715a Step 18/18 : LABEL git_sha=48146ead559bd9f27e80af344e3cf787530a1539 ---> Running in 4d218e19c2ba Removing intermediate container 4d218e19c2ba ---> 67b4d76a7d45 Successfully built 67b4d76a7d45 Successfully tagged edgexfoundry/docker-export-distro-go:48146ead559bd9f27e80af344e3cf787530a1539 Successfully tagged edgexfoundry/docker-export-distro-go:1.0.2-dev
edinburgh_1.0.2

注:生成其餘docker鏡像時,都會使用cache中鏡像(repository和tag都是<none>),編譯一次供多個容器使用。能夠經過docker tag保留容器。

docker tag baee083043d1 edgex_mid1:first

 make docker_core_data docker build \ -f cmd/core-data/Dockerfile \ --label "git_sha=48146ead559bd9f27e80af344e3cf787530a1539" \ -t edgexfoundry/docker-core-data-go:48146ead559bd9f27e80af344e3cf787530a1539 \ -t edgexfoundry/docker-core-data-go:1.0.2-dev \ . Sending build context to Docker daemon 161MB Step 1/18 : FROM golang:1.11-alpine AS builder ---> e116d2efa2ab Step 2/18 : ENV GO111MODULE=on ---> Using cache ---> 6f17441d1946 Step 3/18 : WORKDIR /go/src/github.com/edgexfoundry/edgex-go ---> Using cache ---> 1e94eec59dac Step 4/18 : RUN sed -e 's/dl-cdn[.]alpinelinux.org/nl.alpinelinux.org/g' -i~ /etc/apk/repositories ---> Using cache ---> 48697136fcca Step 5/18 : RUN apk update && apk add zeromq-dev libsodium-dev pkgconfig build-base git ---> Using cache ---> 650c39be3c34 Step 6/18 : COPY go.mod . ---> Using cache ---> 3afaf7b13163 Step 7/18 : RUN go mod download ---> Using cache ---> 2ea018099509 Step 8/18 : COPY . . ---> 2f43fc26cea8 Step 9/18 : RUN make cmd/core-data/core-data ---> Running in c4f567e254ba CGO_ENABLED=1 GO111MODULE=on go build -ldflags "-X github.com/edgexfoundry/edgex-go.Version=1.0.2" -o cmd/core-data/core-data ./cmd/core-data Removing intermediate container c4f567e254ba ---> 3f47fb78be86 Step 10/18 : FROM alpine ---> 965ea09ff2eb Step 11/18 : LABEL license='SPDX-License-Identifier: Apache-2.0'       copyright='Copyright (c) 2018: Dell, Cavium'
 ---> Running in 0df73306b0d5 Removing intermediate container 0df73306b0d5 ---> 2ab515094063 Step 12/18 : RUN sed -e 's/dl-cdn[.]alpinelinux.org/nl.alpinelinux.org/g' -i~ /etc/apk/repositories ---> Running in db0db60625d5 Removing intermediate container db0db60625d5 ---> ccfa3db0f47e Step 13/18 : RUN apk --no-cache add zeromq ---> Running in 236dcf9889df fetch http://nl.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://nl.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
(1/5) Installing libgcc (8.3.0-r0) (2/5) Installing libsodium (1.0.18-r0) (3/5) Installing libstdc++ (8.3.0-r0) (4/5) Installing libzmq (4.3.2-r1) (5/5) Installing zeromq (4.3.2-r1) Executing busybox-1.30.1-r2.trigger OK: 8 MiB in 19 packages Removing intermediate container 236dcf9889df ---> 01425d9e6bf4 Step 14/18 : COPY --from=builder /go/src/github.com/edgexfoundry/edgex-go/cmd/core-data/Attribution.txt /
 ---> 31a9a4020f22 Step 15/18 : COPY --from=builder /go/src/github.com/edgexfoundry/edgex-go/cmd/core-data/core-data /
 ---> 732b0fa69f65 Step 16/18 : COPY --from=builder /go/src/github.com/edgexfoundry/edgex-go/cmd/core-data/res/docker/configuration.toml /res/docker/configuration.toml ---> 7ed81604d03f Step 17/18 : ENTRYPOINT ["/core-data","--registry","--profile=docker","--confdir=/res"] ---> Running in dde57cf9df93 Removing intermediate container dde57cf9df93 ---> 1dbe1e5529bf Step 18/18 : LABEL git_sha=48146ead559bd9f27e80af344e3cf787530a1539 ---> Running in f88f03b51cd0 Removing intermediate container f88f03b51cd0 ---> 3ad0508f7ee4 Successfully built 3ad0508f7ee4 Successfully tagged edgexfoundry/docker-core-data-go:48146ead559bd9f27e80af344e3cf787530a1539 Successfully tagged edgexfoundry/docker-core-data-go:1.0.2-dev
edinburgh_1.0.2_core-data

 

參考:

1.在樹莓派3b+上運行edgex

2.  4.2.2.1. Get EdgeX Foundry - Go Developers

3. 4.3.1. Writing a Device Service in Go

4. 4.3.2. Writing a Device Service in C

相關文章
相關標籤/搜索