From 4ba3a599a4d0b3d044f05a8b34732d5fd6581adf Mon Sep 17 00:00:00 2001 From: postmannen Date: Fri, 14 May 2021 15:23:04 +0200 Subject: [PATCH] added docker file and flag for nkey seed file --- Dockerfile | 69 ++++++++++++++++++++++++++++++++++++++++++ configuration_flags.go | 6 +++- 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ed25727 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,69 @@ +# build stage +FROM golang:alpine AS build-env +RUN apk --no-cache add build-base git gcc +RUN git clone https://github.com/RaaLabs/steward.git +WORKDIR /go/steward/cmd +RUN go build -o steward + +# final stage +FROM alpine +WORKDIR /app +COPY --from=build-env /go/steward/cmd/steward /app/ + +ENV CONFIG_FOLDER "./etc" +ENV SOCKET_FOLDER "./tmp" +ENV DATABASE_FOLDER "./var/lib" +ENV NODE_NAME "" +ENV BROKER_ADDRESS "127.0.0.1:4222" +ENV PROFILING_PORT "" +ENV PROM_HOST_AND_PORT "" +ENV DEFAULT_MESSAGE_TIMEOUT 10 +ENV DEFAULT_MESSAGE_RETRIES 3 +ENV SUBSCRIBERS_DATA_FOLDER "./var" +ENV CENTRAL_NODE_NAME "" +ENV ROOT_CA_PATH "" +ENV NKEY_SEED_FILE "" + +ENV START_PUB_REQ_HELLO 60 + +ENV START_SUB_REQ_ERROR_LOG "" +ENV START_SUB_REQ_HELLO "" +ENV START_SUB_REQ_TO_FILE_APPEND "" +ENV START_SUB_REQ_TO_FILE "" +ENV START_SUB_REQ_PING "" +ENV START_SUB_REQ_PONG "" +ENV START_SUB_REQ_CLI_COMMAND "" +ENV START_SUB_REQN_CLI_COMMAND "" +ENV START_SUB_REQ_TO_CONSOLE "" +ENV START_SUB_REQ_HTTP_GET "" +ENV START_SUB_REQ_TAIL_FILE "" + +CMD ["ash","-c","/app/steward\ + -configFolder=$CONFIG_FOLDER\ + -socketFolder=$SOCKET_FOLDER\ + -databaseFolder=$DATABASE_FOLDER\ + -nodeName=$NODE_NAME\ + -brokerAddress=$BROKER_ADDRESS\ + -profilingPort=$PROFILING_PORT\ + -promHostAndPort=$PROM_HOST_AND_PORT\ + -defaultMessageTimeout=$DEFAULT_MESSAGE_TIMEOUT\ + -defaultMessageRetries=$DEFAULT_MESSAGE_RETRIES\ + -subscribersDataFolder=SUBSCRIBERS_DATA_FOLDER\ + -centralNodeName=$CENTRAL_NODE_NAME\ + -rootCAPath=$ROOT_CA_PATH\ + -nkeySeedFile=$NKEY_SEED_FILE\ + + -startPubREQHello=$START_PUB_REQ_HELLO\ + + -startSubREQErrorLog=$START_SUB_REQ_ERROR_LOG\ + -startSubREQHello=$START_SUB_REQ_HELLO\ + -startSubREQToFileAppend=$START_SUB_REQ_TO_FILE_APPEND\ + -startSubREQToFile=$START_SUB_REQ_TO_FILE\ + -startSubREQPing=$START_SUB_REQ_PING\ + -startSubREQPong=$START_SUB_REQ_PONG\ + -startSubREQCliCommand=$START_SUB_REQ_CLI_COMMAND\ + -startSubREQnCliCommand=$START_SUB_REQN_CLI_COMMAND\ + -startSubREQToConsole=$START_SUB_REQ_TO_CONSOLE\ + -startSubREQHttpGet=$START_SUB_REQ_HTTP_GET\ + -startSubREQTailFile=$START_SUB_REQ_TAIL_FILE\ + "] \ No newline at end of file diff --git a/configuration_flags.go b/configuration_flags.go index 30d7bf7..a8a4bbc 100644 --- a/configuration_flags.go +++ b/configuration_flags.go @@ -102,9 +102,11 @@ type Configuration struct { // Path to the certificate of the root CA RootCAPath string + // Full path to the NKEY's seed file + NkeySeedFile string + // Make the current node send hello messages to central at given interval in seconds StartPubREQHello int - // Start the central error logger. // Takes a comma separated string of nodes to receive from or "*" for all nodes. StartSubREQErrorLog flagNodeSlice @@ -152,6 +154,7 @@ func newConfigurationDefaults() Configuration { SubscribersDataFolder: "./var", CentralNodeName: "", RootCAPath: "", + NkeySeedFile: "", StartSubREQErrorLog: flagNodeSlice{Values: []node{}}, StartSubREQHello: flagNodeSlice{OK: true, Values: []node{"*"}}, StartSubREQToFileAppend: flagNodeSlice{OK: true, Values: []node{"*"}}, @@ -195,6 +198,7 @@ func (c *Configuration) CheckFlags() error { flag.StringVar(&c.SubscribersDataFolder, "subscribersDataFolder", fc.SubscribersDataFolder, "The data folder where subscribers are allowed to write their data if needed") flag.StringVar(&c.CentralNodeName, "centralNodeName", fc.CentralNodeName, "The name of the central node to receive messages published by this node") flag.StringVar(&c.RootCAPath, "rootCAPath", fc.RootCAPath, "If TLS, enter the path for where to find the root CA certificate") + flag.StringVar(&c.NkeySeedFile, "nkeySeedFile", fc.NkeySeedFile, "The full path of the nkeys seed file") flag.IntVar(&c.StartPubREQHello, "startPubREQHello", fc.StartPubREQHello, "Make the current node send hello messages to central at given interval in seconds")