From 02e915438e65ab8d74a5eb0bde8cf83ac573ecf3 Mon Sep 17 00:00:00 2001 From: Marc-philippe Fuller Date: Thu, 6 Jan 2022 10:32:32 -0800 Subject: [PATCH] fix: Resolved all comments made by Lenny for Makefile and Dockerfile and resolved null label issue Signed-off-by: Marc-philippe Fuller --- .gitignore | 2 +- Dockerfile | 11 ++++++----- Makefile | 17 ++++++----------- internal/driver/discover.go | 3 ++- snap/snapcraft.yaml | 4 ++-- 5 files changed, 17 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index b3ebf572..59936a3e 100644 --- a/.gitignore +++ b/.gitignore @@ -18,7 +18,7 @@ .idea/ vendor/ -cmd/device-rfid-llrp-go +cmd/device-rfid-llrp glide.lock # snap files diff --git a/Dockerfile b/Dockerfile index dd85cb50..f93fbccc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ ARG ALPINE_PKG_EXTRA="" RUN sed -e 's/dl-cdn[.]alpinelinux.org/nl.alpinelinux.org/g' -i~ /etc/apk/repositories RUN apk add --no-cache ${ALPINE_PKG_BASE} ${ALPINE_PKG_EXTRA} -WORKDIR $GOPATH/src/github.com/edgexfoundry/device-rfid-llrp-go +WORKDIR /app COPY . . RUN [ ! -d "vendor" ] && go mod download all || echo "skipping..." @@ -40,11 +40,12 @@ LABEL license='SPDX-License-Identifier: Apache-2.0' \ RUN sed -e 's/dl-cdn[.]alpinelinux.org/nl.alpinelinux.org/g' -i~ /etc/apk/repositories RUN apk add --update --no-cache zeromq dumb-init -COPY --from=builder /go/src/github.com/edgexfoundry/device-rfid-llrp-go/LICENSE / -COPY --from=builder /go/src/github.com/edgexfoundry/device-rfid-llrp-go/Attribution.txt / -COPY --from=builder /go/src/github.com/edgexfoundry/device-rfid-llrp-go/cmd / +COPY --from=builder /app/LICENSE / +COPY --from=builder /app/Attribution.txt / +COPY --from=builder /app/cmd/device-rfid-llrp /device-rfid-llrp +COPY --from=builder /app/cmd/res/ / EXPOSE 59989 -ENTRYPOINT ["/device-rfid-llrp-go"] +ENTRYPOINT ["/device-rfid-llrp"] CMD ["-cp=consul.http://edgex-core-consul:8500", "--confdir=/res", "--registry"] diff --git a/Makefile b/Makefile index b47a2133..80307e98 100644 --- a/Makefile +++ b/Makefile @@ -2,24 +2,21 @@ GO=CGO_ENABLED=1 GO111MODULE=on go -MICROSERVICES=cmd/device-rfid-llrp-go +MICROSERVICES=cmd/device-rfid-llrp .PHONY: $(MICROSERVICES) -DOCKERS=docker_device_rfid_llrp_go -.PHONY: $(DOCKERS) - VERSION=$(shell cat ./VERSION 2>/dev/null || echo 0.0.0) GIT_SHA=$(shell git rev-parse HEAD) -GOFLAGS=-ldflags "-X github.com/edgexfoundry/device-rfid-llrp-go.Version=$(VERSION)" +GOFLAGS=-ldflags "-X github.com/edgexfoundry/device-rfid-llrp.Version=$(VERSION)" build: $(MICROSERVICES) tidy: go mod tidy -cmd/device-rfid-llrp-go: +cmd/device-rfid-llrp: $(GO) build $(GOFLAGS) -o $@ ./cmd test: @@ -32,15 +29,13 @@ test: clean: rm -f $(MICROSERVICES) -docker: $(DOCKERS) - -docker_device_rfid_llrp_go: +docker: docker build \ --build-arg http_proxy \ --build-arg https_proxy \ --label "git_sha=$(GIT_SHA)" \ - -t edgexfoundry/docker-device-rfid-llrp-go:$(GIT_SHA) \ - -t edgexfoundry/docker-device-rfid-llrp-go:$(VERSION)-dev \ + -t edgexfoundry/device-rfid-llrp:$(GIT_SHA) \ + -t edgexfoundry/device-rfid-llrp:$(VERSION)-dev \ . vendor: diff --git a/internal/driver/discover.go b/internal/driver/discover.go index 3a7ac8cb..b973dcbe 100644 --- a/internal/driver/discover.go +++ b/internal/driver/discover.go @@ -498,8 +498,9 @@ func newDiscoveredDevice(info *discoveryInfo) dsModels.DiscoveredDevice { if VendorIDType(info.vendor) == Impinj { ipjModelStr := ImpinjModelType(info.model).String() if !strings.HasPrefix(modelStr, "ImpinjModelType(") { - labels = append(labels, modelStr) modelStr = ipjModelStr + labels = append(labels, modelStr) + } } diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index b418cfc6..80a188b1 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -96,8 +96,8 @@ parts: go mod tidy make build - # copy device-rfid-llrp-go and rename to device-rfid-llrp - install -DT "./cmd/device-rfid-llrp-go" "$SNAPCRAFT_PART_INSTALL/bin/device-rfid-llrp" + # copy device-rfid-llrp + install -DT "./cmd/device-rfid-llrp" "$SNAPCRAFT_PART_INSTALL/bin/device-rfid-llrp" install -d "$SNAPCRAFT_PART_INSTALL/config/device-rfid-llrp/res/" install -DT "./cmd/res/configuration.toml" \