mirror of
https://github.com/postmannen/ctrl.git
synced 2024-12-14 12:37:31 +00:00
updated docker compose scripts and dockerfile flags
This commit is contained in:
parent
def4bd8e58
commit
e421f359cd
6 changed files with 70 additions and 16 deletions
46
Dockerfile
46
Dockerfile
|
@ -17,6 +17,7 @@ RUN apk update && apk add curl && apk add nmap
|
|||
WORKDIR /app
|
||||
COPY --from=build-env /build/cmd/steward/steward /app/
|
||||
|
||||
ENV RING_BUFFER_SIZE "1000"
|
||||
ENV CONFIG_FOLDER "./etc"
|
||||
ENV SOCKET_FOLDER "./tmp"
|
||||
ENV TCP_LISTENER ""
|
||||
|
@ -24,18 +25,29 @@ ENV HTTP_LISTENER "localhost:8091"
|
|||
ENV DATABASE_FOLDER "./var/lib"
|
||||
ENV NODE_NAME ""
|
||||
ENV BROKER_ADDRESS "127.0.0.1:4222"
|
||||
ENV NATS_CONN_OPT_TIMEOUT "20"
|
||||
ENV NATS_CONNECT_RETRY_INTERVAL "10"
|
||||
ENV NATS_RECONNECT_JITTER "100"
|
||||
ENV NATS_RECONNECT_JITTER_TLS "1"
|
||||
ENV PROFILING_PORT ""
|
||||
ENV PROM_HOST_AND_PORT "127.0.0.1:2111"
|
||||
ENV DEFAULT_MESSAGE_TIMEOUT 10
|
||||
ENV DEFAULT_MESSAGE_RETRIES 3
|
||||
ENV ERROR_MESSAGE_RETRIES 3
|
||||
ENV ERROR_MESSAGE_TIMEOUT 10
|
||||
ENV DEFAULT_METHOD_TIMEOUT 10
|
||||
ENV SUBSCRIBERS_DATA_FOLDER "./var"
|
||||
ENV EXPOSE_DATA_FOLDER "127.0.0.1:8090"
|
||||
ENV CENTRAL_NODE_NAME ""
|
||||
ENV ROOT_CA_PATH ""
|
||||
ENV NKEY_SEED_FILE ""
|
||||
ENV EXPOSE_DATA_FOLDER "127.0.0.1:8090"
|
||||
ENV ERROR_MESSAGE_RETRIES 3
|
||||
ENV ERROR_MESSAGE_TIMEOUT 10
|
||||
ENV COMPRESSION ""
|
||||
ENV SERIALIZATION ""
|
||||
ENV SET_BLOCK_PROFILE_RATE "0"
|
||||
ENV ENABLE_SOCKET "1"
|
||||
ENV ENABLE_TUI "0"
|
||||
ENV ENABLE_SIGNATURE_CHECK "0"
|
||||
ENV IS_CENTRAL_AUTH "0"
|
||||
|
||||
ENV START_PUB_REQ_HELLO 60
|
||||
|
||||
|
@ -43,49 +55,63 @@ 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_COPY_FILE_FROM ""
|
||||
ENV START_SUB_REQ_COPY_FILE_TO ""
|
||||
ENV START_SUB_REQ_PING ""
|
||||
ENV START_SUB_REQ_PONG ""
|
||||
ENV START_SUB_REQ_CLI_COMMAND ""
|
||||
ENV START_SUB_REQ_TO_CONSOLE ""
|
||||
ENV START_SUB_REQ_HTTP_GET ""
|
||||
ENV START_SUB_REQ_HTTP_GET_SCHEDULED ""
|
||||
ENV START_SUB_REQ_TAIL_FILE ""
|
||||
ENV START_SUB_REQ_CLI_COMMAND_CONT ""
|
||||
ENV START_SUB_REQ_COPY_FILE_FROM ""
|
||||
ENV START_SUB_REQ_COPY_FILE_TO ""
|
||||
ENV START_SUB_REQ_RELAY ""
|
||||
|
||||
CMD ["ash","-c","env CONFIGFOLDER=./etc/ /app/steward\
|
||||
-ringBufferSize=$RING_BUFFER_SIZE\
|
||||
-socketFolder=$SOCKET_FOLDER\
|
||||
-tcpListener=$TCP_LISTENER\
|
||||
-httpListener=$HTTP_LISTENER\
|
||||
-databaseFolder=$DATABASE_FOLDER\
|
||||
-nodeName=$NODE_NAME\
|
||||
-brokerAddress=$BROKER_ADDRESS\
|
||||
-natsConnOptTimeout=$NATS_CONN_OPT_TIMEOUT\
|
||||
-natsConnectRetryInterval=$NATS_CONNECT_RETRY_INTERVAL\
|
||||
-natsReconnectJitter=$NATS_RECONNECT_JITTER\
|
||||
-natsReconnectJitterTLS=$NATS_RECONNECT_JITTER_TLS\
|
||||
-profilingPort=$PROFILING_PORT\
|
||||
-promHostAndPort=$PROM_HOST_AND_PORT\
|
||||
-defaultMessageTimeout=$DEFAULT_MESSAGE_TIMEOUT\
|
||||
-defaultMessageRetries=$DEFAULT_MESSAGE_RETRIES\
|
||||
-errorMessageRetries=$ERROR_MESSAGE_RETRIES\
|
||||
-errorMessageTimeout=$ERROR_MESSAGE_TIMEOUT\
|
||||
-defaultMethodTimeout=$DEFAULT_METHOD_TIMEOUT\
|
||||
-subscribersDataFolder=$SUBSCRIBERS_DATA_FOLDER\
|
||||
-exposeDataFolder=$EXPOSE_DATA_FOLDER\
|
||||
-centralNodeName=$CENTRAL_NODE_NAME\
|
||||
-rootCAPath=$ROOT_CA_PATH\
|
||||
-nkeySeedFile=$NKEY_SEED_FILE\
|
||||
-exposeDataFolder=$EXPOSE_DATA_FOLDER\
|
||||
-errorMessageRetries=$ERROR_MESSAGE_RETRIES\
|
||||
-errorMessageTimeout=$ERROR_MESSAGE_TIMEOUT\
|
||||
-compression=$COMPRESSION\
|
||||
-serialization=$SERIALIZATION\
|
||||
-SetBlockProfileRate=$SET_BLOCK_PROFILE_RATE\
|
||||
-enableSocket=$ENABLE_SOCKET\
|
||||
-enableTUI=$ENABLE_TUI\
|
||||
-enableSignatureCheck=$ENABLE_SIGNATURE_CHECK\
|
||||
-isCentralAuth=$IS_CENTRAL_AUTH\
|
||||
-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\
|
||||
-startSubREQCopyFileFrom=$START_SUB_REQ_COPY_FILE_FROM\
|
||||
-startSubREQCopyFileTo=$START_SUB_REQ_COPY_FILE_TO\
|
||||
-startSubREQPing=$START_SUB_REQ_PING\
|
||||
-startSubREQPong=$START_SUB_REQ_PONG\
|
||||
-startSubREQCliCommand=$START_SUB_REQ_CLI_COMMAND\
|
||||
-startSubREQToConsole=$START_SUB_REQ_TO_CONSOLE\
|
||||
-startSubREQHttpGet=$START_SUB_REQ_HTTP_GET\
|
||||
-startSubREQHttpGetScheduled=$START_SUB_REQ_HTTP_GET_SCHEDULED\
|
||||
-startSubREQTailFile=$START_SUB_REQ_TAIL_FILE\
|
||||
-startSubREQCliCommandCont=$START_SUB_REQ_CLI_COMMAND_CONT\
|
||||
-startSubREQCopyFileFrom=$START_SUB_REQ_COPY_FILE_FROM\
|
||||
-startSubREQCopyFileTo=$START_SUB_REQ_COPY_FILE_TO\
|
||||
-startSubREQRelay=$START_SUB_REQ_RELAY\
|
||||
"]
|
||||
|
|
|
@ -120,8 +120,8 @@ type Configuration struct {
|
|||
// configuration values from file, so we are able to detect
|
||||
// if a value were given or not when parsing.
|
||||
type ConfigurationFromFile struct {
|
||||
RingBufferSize *int
|
||||
ConfigFolder *string
|
||||
RingBufferSize *int
|
||||
SocketFolder *string
|
||||
TCPListener *string
|
||||
HTTPListener *string
|
||||
|
@ -179,12 +179,13 @@ func NewConfiguration() *Configuration {
|
|||
// Get a Configuration struct with the default values set.
|
||||
func newConfigurationDefaults() Configuration {
|
||||
c := Configuration{
|
||||
RingBufferSize: 1000,
|
||||
ConfigFolder: "./etc/",
|
||||
RingBufferSize: 1000,
|
||||
SocketFolder: "./tmp",
|
||||
TCPListener: "",
|
||||
HTTPListener: "",
|
||||
DatabaseFolder: "./var/lib",
|
||||
NodeName: "",
|
||||
BrokerAddress: "127.0.0.1:4222",
|
||||
NatsConnOptTimeout: 20,
|
||||
NatsConnectRetryInterval: 10,
|
||||
|
@ -195,7 +196,6 @@ func newConfigurationDefaults() Configuration {
|
|||
DefaultMessageTimeout: 10,
|
||||
DefaultMessageRetries: 1,
|
||||
DefaultMethodTimeout: 10,
|
||||
StartPubREQHello: 30,
|
||||
SubscribersDataFolder: "./data",
|
||||
CentralNodeName: "",
|
||||
RootCAPath: "",
|
||||
|
@ -211,6 +211,7 @@ func newConfigurationDefaults() Configuration {
|
|||
EnableSignatureCheck: false,
|
||||
IsCentralAuth: false,
|
||||
|
||||
StartPubREQHello: 30,
|
||||
StartSubREQErrorLog: true,
|
||||
StartSubREQHello: true,
|
||||
StartSubREQToFileAppend: true,
|
||||
|
|
|
@ -2,6 +2,7 @@ version: "3"
|
|||
|
||||
services:
|
||||
nats-server:
|
||||
container_name: {{.ContainerName}}
|
||||
build: .
|
||||
env_file:
|
||||
- env.env
|
||||
|
@ -12,4 +13,9 @@ services:
|
|||
volumes:
|
||||
- {{.NatsConfPath}}:/app/nats-server.conf
|
||||
- {{.LeCertPath}}:/app/le.crt
|
||||
- {{.LeKeyPath}}:/app/le.key
|
||||
- {{.LeKeyPath}}:/app/le.key
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "10"
|
|
@ -55,6 +55,7 @@ func generateDockerCompose(templateFile string, cData composeData) error {
|
|||
}
|
||||
|
||||
type composeData struct {
|
||||
ContainerName string
|
||||
ImageAndVersion string
|
||||
NatsConfPath string
|
||||
LeCertPath string
|
||||
|
@ -68,6 +69,7 @@ type envData struct {
|
|||
}
|
||||
|
||||
func main() {
|
||||
containerName := flag.String("containerName", "", "Name of the docker container")
|
||||
imageAndVersion := flag.String("imageAndVersion", "", "The name:version of the docker image to use")
|
||||
natsConfPath := flag.String("natsConfPath", "./nats.conf", "the full path of the nats.conf file")
|
||||
leCertPath := flag.String("leCertPath", "", "the full path to the LetsEncrypt crt file")
|
||||
|
@ -81,6 +83,7 @@ func main() {
|
|||
flag.Parse()
|
||||
|
||||
cData := composeData{
|
||||
ContainerName: *containerName,
|
||||
ImageAndVersion: *imageAndVersion,
|
||||
NatsConfPath: *natsConfPath,
|
||||
LeCertPath: *leCertPath,
|
||||
|
@ -92,6 +95,10 @@ func main() {
|
|||
Flags: *flags,
|
||||
}
|
||||
|
||||
if cData.ContainerName == "" {
|
||||
log.Printf("error: -containerName flag can not be empty\n")
|
||||
return
|
||||
}
|
||||
if cData.ImageAndVersion == "" {
|
||||
log.Printf("error: -imageAndVersion flag can not be empty\n")
|
||||
return
|
||||
|
|
|
@ -4,6 +4,7 @@ version: "3.1"
|
|||
|
||||
services:
|
||||
steward:
|
||||
container_name: {{.ContainerName}}
|
||||
build: .
|
||||
env_file:
|
||||
- env.env
|
||||
|
@ -30,6 +31,11 @@ services:
|
|||
volumes:
|
||||
# - {{.NkeySeedFile}}:/app/seed.txt
|
||||
- {{.SocketFolder}}:/app/tmp/:rw
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "10"
|
||||
|
||||
secrets:
|
||||
seed:
|
||||
|
|
|
@ -95,13 +95,14 @@ func generateEnv(fileDir string, templateDir string, brokerAddress string) error
|
|||
}
|
||||
|
||||
// generateDockerCompose will generate the docker-compose.yml file.
|
||||
func generateDockerCompose(fileDir string, templateFile string, imageAndVersion string, exposedProfilingPort string, exposedPrometheusPort string, exposedDataFolderPort string, exposedTcpListenerPort string, exposedHttpListenerPort string, nkeySeedFile string, socketFolder string) error {
|
||||
func generateDockerCompose(containerName, fileDir string, templateFile string, imageAndVersion string, exposedProfilingPort string, exposedPrometheusPort string, exposedDataFolderPort string, exposedTcpListenerPort string, exposedHttpListenerPort string, nkeySeedFile string, socketFolder string) error {
|
||||
tpl, err := template.ParseFiles(templateFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error: parsing template file, you might need to set the -templateDir flag : %v, err: %v", templateFile, err)
|
||||
}
|
||||
|
||||
data := struct {
|
||||
ContainerName string
|
||||
ImageAndVersion string
|
||||
ExposedProfilingPort string
|
||||
ExposedPrometheusPort string
|
||||
|
@ -111,6 +112,7 @@ func generateDockerCompose(fileDir string, templateFile string, imageAndVersion
|
|||
NkeySeedFile string
|
||||
SocketFolder string
|
||||
}{
|
||||
ContainerName: containerName,
|
||||
ImageAndVersion: imageAndVersion,
|
||||
ExposedProfilingPort: exposedProfilingPort,
|
||||
ExposedPrometheusPort: exposedPrometheusPort,
|
||||
|
@ -137,6 +139,7 @@ func generateDockerCompose(fileDir string, templateFile string, imageAndVersion
|
|||
}
|
||||
|
||||
func main() {
|
||||
containerName := flag.String("containerName", "", "name of the container")
|
||||
fileDir := flag.String("fileDir", "./", "the directory path for where to store the files")
|
||||
|
||||
brokerAddress := flag.String("brokerAddress", "", "the address:port of the broker to connect to")
|
||||
|
@ -153,6 +156,11 @@ func main() {
|
|||
|
||||
flag.Parse()
|
||||
|
||||
if *containerName == "" {
|
||||
log.Printf("error: -containerName flag can not be empty\n")
|
||||
return
|
||||
}
|
||||
|
||||
if *brokerAddress == "" {
|
||||
log.Printf("error: -brokerAddress flag can not be empty\n")
|
||||
return
|
||||
|
@ -176,7 +184,7 @@ func main() {
|
|||
|
||||
{
|
||||
template := path.Join(*templateDir, "docker-compose.yml.tpl")
|
||||
err := generateDockerCompose(*fileDir, template, *imageAndVersion, *exposedProfilingPort, *exposedPrometheusPort, *exposedDataFolderPort, *exposedTcpListenerPort, *exposedHttpListenerPort, *nkeySeedFile, *socketFolder)
|
||||
err := generateDockerCompose(*containerName, *fileDir, template, *imageAndVersion, *exposedProfilingPort, *exposedPrometheusPort, *exposedDataFolderPort, *exposedTcpListenerPort, *exposedHttpListenerPort, *nkeySeedFile, *socketFolder)
|
||||
if err != nil {
|
||||
log.Printf("%v\n", err)
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue