Skip to content

Commit

Permalink
build: Add option to build Core/Support services with NATS Capability
Browse files Browse the repository at this point in the history
Signed-off-by: Leonard Goodell <[email protected]>
  • Loading branch information
Leonard Goodell committed Aug 30, 2022
1 parent 346e0e8 commit b714cbf
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 29 deletions.
15 changes: 10 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,19 @@ tidy:

metadata: cmd/core-metadata/core-metadata
cmd/core-metadata/core-metadata:
$(GO) build -tags "$(NO_ZMQ_GO_BUILD_TAG) $(NON_DELAYED_START_GO_BUILD_TAG_FOR_CORE)" $(GOFLAGS) -o $@ ./cmd/core-metadata
$(GO) build -tags "$(ADD_BUILD_TAGS) $(NO_ZMQ_GO_BUILD_TAG) $(NON_DELAYED_START_GO_BUILD_TAG_FOR_CORE)" $(GOFLAGS) -o $@ ./cmd/core-metadata

data: cmd/core-data/core-data
cmd/core-data/core-data:
$(GOCGO) build -tags "$(NON_DELAYED_START_GO_BUILD_TAG_FOR_CORE)" $(CGOFLAGS) -o $@ ./cmd/core-data
$(GOCGO) build -tags "$(ADD_BUILD_TAGS) $(NON_DELAYED_START_GO_BUILD_TAG_FOR_CORE)" $(CGOFLAGS) -o $@ ./cmd/core-data

command: cmd/core-command/core-command
cmd/core-command/core-command:
$(GO) build -tags "$(NO_ZMQ_GO_BUILD_TAG) $(NON_DELAYED_START_GO_BUILD_TAG_FOR_CORE)" $(GOFLAGS) -o $@ ./cmd/core-command
$(GO) build -tags "$(ADD_BUILD_TAGS) $(NO_ZMQ_GO_BUILD_TAG) $(NON_DELAYED_START_GO_BUILD_TAG_FOR_CORE)" $(GOFLAGS) -o $@ ./cmd/core-command

notifications: cmd/support-notifications/support-notifications
cmd/support-notifications/support-notifications:
$(GO) build -tags "$(NO_MESSAGEBUS_GO_BUILD_TAG) $(NON_DELAYED_START_GO_BUILD_TAG_FOR_SUPPORT)" $(GOFLAGS) -o $@ ./cmd/support-notifications
$(GO) build -tags "$(ADD_BUILD_TAGS) $(NO_ZMQ_GO_BUILD_TAG) $(NON_DELAYED_START_GO_BUILD_TAG_FOR_SUPPORT)" $(GOFLAGS) -o $@ ./cmd/support-notifications

cmd/sys-mgmt-executor/sys-mgmt-executor:
$(GO) build -tags "$(NO_MESSAGEBUS_GO_BUILD_TAG) $(NON_DELAYED_START_GO_BUILD_TAG_FOR_CORE)" $(GOFLAGS) -o $@ ./cmd/sys-mgmt-executor
Expand All @@ -116,7 +116,7 @@ cmd/sys-mgmt-agent/sys-mgmt-agent:

scheduler: cmd/support-scheduler/support-scheduler
cmd/support-scheduler/support-scheduler:
$(GO) build -tags "$(NO_MESSAGEBUS_GO_BUILD_TAG) $(NON_DELAYED_START_GO_BUILD_TAG_FOR_SUPPORT)" $(GOFLAGS) -o $@ ./cmd/support-scheduler
$(GO) build -tags "$(ADD_BUILD_TAGS) $(NO_ZMQ_GO_BUILD_TAG) $(NON_DELAYED_START_GO_BUILD_TAG_FOR_SUPPORT)" $(GOFLAGS) -o $@ ./cmd/support-scheduler

proxy: cmd/security-proxy-setup/security-proxy-setup
cmd/security-proxy-setup/security-proxy-setup:
Expand Down Expand Up @@ -182,6 +182,7 @@ docker_base:
dmetadata: docker_core_metadata
docker_core_metadata: docker_base
docker build \
--build-arg ADD_BUILD_TAGS=$(ADD_BUILD_TAGS) \
--build-arg http_proxy \
--build-arg https_proxy \
--build-arg BUILDER_BASE=$(LOCAL_CACHE_IMAGE) \
Expand All @@ -194,6 +195,7 @@ docker_core_metadata: docker_base
ddata: docker_core_data
docker_core_data: docker_base
docker build \
--build-arg ADD_BUILD_TAGS=$(ADD_BUILD_TAGS) \
--build-arg http_proxy \
--build-arg https_proxy \
--build-arg BUILDER_BASE=$(LOCAL_CACHE_IMAGE) \
Expand All @@ -206,6 +208,7 @@ docker_core_data: docker_base
dcommand: docker_core_command
docker_core_command: docker_base
docker build \
--build-arg ADD_BUILD_TAGS=$(ADD_BUILD_TAGS) \
--build-arg http_proxy \
--build-arg https_proxy \
--build-arg BUILDER_BASE=$(LOCAL_CACHE_IMAGE) \
Expand All @@ -218,6 +221,7 @@ docker_core_command: docker_base
dnotifications: docker_support_notifications
docker_support_notifications: docker_base
docker build \
--build-arg ADD_BUILD_TAGS=$(ADD_BUILD_TAGS) \
--build-arg http_proxy \
--build-arg https_proxy \
--build-arg BUILDER_BASE=$(LOCAL_CACHE_IMAGE) \
Expand All @@ -230,6 +234,7 @@ docker_support_notifications: docker_base
dscheduler: docker_support_scheduler
docker_support_scheduler: docker_base
docker build \
--build-arg ADD_BUILD_TAGS=$(ADD_BUILD_TAGS) \
--build-arg http_proxy \
--build-arg https_proxy \
--build-arg BUILDER_BASE=$(LOCAL_CACHE_IMAGE) \
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@

EdgeX Foundry is a vendor-neutral open source project hosted by The Linux Foundation building a common open framework for IoT edge computing. At the heart of the project is an interoperability framework hosted within a full hardware- and OS-agnostic reference software platform to enable an ecosystem of plug-and-play components that unifies the marketplace and accelerates the deployment of IoT solutions. This repository contains the Go implementation of EdgeX Foundry microservices. It also includes files for building the services, containerizing the services, and initializing (bootstrapping) the services.

## Build with NATS Messaging
Currently, the NATS Messaging capability (NATS MessageBus) is opt-in at build time. This means that the published Docker images and Snaps do not include the NATS messaging capability.

The following make commands will build the local binaries or local Docker images with NATS messaging capability included for the Core and Support services.

```makefile
make -e ADD_BUILD_TAGS=include_nats_messaging build
make -e ADD_BUILD_TAGS=include_nats_messaging docker
```

Optionally build a single service with NATS messaging capability. The following builds Core Data binary (data target) and Docker (ddata target) with NATS messaging capability. See the Makefile for the other available make targets.

```makefile
make -e ADD_BUILD_TAGS=include_nats_messaging data
make -e ADD_BUILD_TAGS=include_nats_messaging ddata
```

The locally built Docker images can then be used in place of the published Docker images in your compose file.

## Get Started

EdgeX provides docker images in our organization's [DockerHub page](https://hub.docker.com/u/edgexfoundry/).
Expand Down
4 changes: 3 additions & 1 deletion cmd/core-command/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
ARG BUILDER_BASE=golang:1.18-alpine3.16
FROM ${BUILDER_BASE} AS builder

ARG ADD_BUILD_TAGS=""

WORKDIR /edgex-go

# The main mirrors are giving us timeout issues on builds periodically.
Expand All @@ -32,7 +34,7 @@ COPY go.mod vendor* ./
RUN [ ! -d "vendor" ] && go mod download all || echo "skipping..."

COPY . .
RUN make cmd/core-command/core-command
RUN make -e ADD_BUILD_TAGS=$ADD_BUILD_TAGS cmd/core-command/core-command

FROM alpine:3.16

Expand Down
20 changes: 13 additions & 7 deletions cmd/core-command/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,22 @@ Type = "consul"
InternalRequestQueryTopic = "/commandquery/request" # for subscribing to internal command query requests
InternalResponseQueryTopic = "/commandquery/response" # for publishing reponsses back to internal service
[MessageQueue.Internal.Optional]
# Client Identifiers
# Default MQTT Specific options that need to be here to enable evnironment variable overrides of them
ClientId ="core-command"
# Connection information
Qos = "0" # Quality of Sevice values are 0 (At most once), 1 (At least once) or 2 (Exactly once)
KeepAlive = "10" # Seconds (must be 2 or greater)
Retained = "false"
AutoReconnect = "true"
Qos = "0" # Quality of Sevice values are 0 (At most once), 1 (At least once) or 2 (Exactly once)
KeepAlive = "10" # Seconds (must be 2 or greater)
Retained = "false"
AutoReconnect = "true"
ConnectTimeout = "5" # Seconds
# TLS configuration - Only used if Cert/Key file or Cert/Key PEMblock are specified
SkipCertVerify = "false"
# Additional Default NATS Specific options that need to be here to enable evnironment variable overrides of them
Format = "nats"
RetryOnFailedConnect = "true"
QueueGroup = ""
Durable = ""
AutoProvision = "true"
Deliver = "new"
DefaultPubRetryAttempts = "2"
[MessageQueue.External]
Url = "tcp://localhost:1883"
ClientId = "core-command"
Expand Down
4 changes: 3 additions & 1 deletion cmd/core-data/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
ARG BUILDER_BASE=golang:1.18-alpine3.16
FROM ${BUILDER_BASE} AS builder

ARG ADD_BUILD_TAGS=""

WORKDIR /edgex-go

# The main mirrors are giving us timeout issues on builds periodically.
Expand All @@ -33,7 +35,7 @@ COPY go.mod vendor* ./
RUN [ ! -d "vendor" ] && go mod download all || echo "skipping..."

COPY . .
RUN make cmd/core-data/core-data
RUN make -e ADD_BUILD_TAGS=$ADD_BUILD_TAGS cmd/core-data/core-data

#Next image - Copy built Go binary into new workspace
FROM alpine:3.16
Expand Down
19 changes: 12 additions & 7 deletions cmd/core-data/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,21 @@ SubscribeEnabled = true
SubscribeTopic = "edgex/events/device/#" # required for subscribing to Events from MessageBus
[MessageQueue.Optional]
# Default MQTT Specific options that need to be here to enable evnironment variable overrides of them
# Client Identifiers
ClientId ="core-data"
# Connection information
Qos = "0" # Quality of Sevice values are 0 (At most once), 1 (At least once) or 2 (Exactly once)
KeepAlive = "10" # Seconds (must be 2 or greater)
Retained = "false"
AutoReconnect = "true"
Qos = "0" # Quality of Sevice values are 0 (At most once), 1 (At least once) or 2 (Exactly once)
KeepAlive = "10" # Seconds (must be 2 or greater)
Retained = "false"
AutoReconnect = "true"
ConnectTimeout = "5" # Seconds
# TLS configuration - Only used if Cert/Key file or Cert/Key PEMblock are specified
SkipCertVerify = "false"
# Additional Default NATS Specific options that need to be here to enable evnironment variable overrides of them
Format = "nats"
RetryOnFailedConnect = "true"
QueueGroup = ""
Durable = ""
AutoProvision = "true"
Deliver = "new"
DefaultPubRetryAttempts = "2"

[SecretStore]
Type = "vault"
Expand Down
4 changes: 3 additions & 1 deletion cmd/core-metadata/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
ARG BUILDER_BASE=golang:1.18-alpine3.16
FROM ${BUILDER_BASE} AS builder

ARG ADD_BUILD_TAGS=""

WORKDIR /edgex-go

# The main mirrors are giving us timeout issues on builds periodically.
Expand All @@ -32,7 +34,7 @@ COPY go.mod vendor* ./
RUN [ ! -d "vendor" ] && go mod download all || echo "skipping..."

COPY . .
RUN make cmd/core-metadata/core-metadata
RUN make -e ADD_BUILD_TAGS=$ADD_BUILD_TAGS cmd/core-metadata/core-metadata

#Next image - Copy built Go binary into new workspace
FROM alpine:3.16
Expand Down
19 changes: 12 additions & 7 deletions cmd/core-metadata/res/configuration.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,21 @@ AuthMode = "usernamepassword" # required for redis messagebus (secure or insecu
SecretName = "redisdb"
[MessageQueue.Optional]
# Default MQTT Specific options that need to be here to enable evnironment variable overrides of them
# Client Identifiers
ClientId ="core-metadata"
# Connection information
Qos = "0" # Quality of Sevice values are 0 (At most once), 1 (At least once) or 2 (Exactly once)
KeepAlive = "10" # Seconds (must be 2 or greater)
Retained = "false"
AutoReconnect = "true"
Qos = "0" # Quality of Sevice values are 0 (At most once), 1 (At least once) or 2 (Exactly once)
KeepAlive = "10" # Seconds (must be 2 or greater)
Retained = "false"
AutoReconnect = "true"
ConnectTimeout = "5" # Seconds
# TLS configuration - Only used if Cert/Key file or Cert/Key PEMblock are specified
SkipCertVerify = "false"
# Additional Default NATS Specific options that need to be here to enable evnironment variable overrides of them
Format = "nats"
RetryOnFailedConnect = "true"
QueueGroup = ""
Durable = ""
AutoProvision = "true"
Deliver = "new"
DefaultPubRetryAttempts = "2"

[SecretStore]
Type = "vault"
Expand Down
2 changes: 2 additions & 0 deletions cmd/support-notifications/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
ARG BUILDER_BASE=golang:1.18-alpine3.16
FROM ${BUILDER_BASE} AS builder

ARG ADD_BUILD_TAGS=""

WORKDIR /edgex-go

# The main mirrors are giving us timeout issues on builds periodically.
Expand Down
2 changes: 2 additions & 0 deletions cmd/support-scheduler/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
ARG BUILDER_BASE=golang:1.18-alpine3.16
FROM ${BUILDER_BASE} AS builder

ARG ADD_BUILD_TAGS=""

WORKDIR /edgex-go

# The main mirrors are giving us timeout issues on builds periodically.
Expand Down

0 comments on commit b714cbf

Please sign in to comment.