From c39ee19b5c265b0c58cc4e4c7ec2821bb7bf2208 Mon Sep 17 00:00:00 2001 From: nyagamunene Date: Tue, 14 Jan 2025 19:32:57 +0300 Subject: [PATCH] revert to a toml file Signed-off-by: nyagamunene --- .gitignore | 2 - cli/provision.go | 38 +++---- cmd/manager/main.go | 27 +++-- cmd/proplet/main.go | 31 ++++-- cmd/proxy/main.go | 31 ++++-- docker/.env | 242 +------------------------------------------- docker/compose.yaml | 152 ---------------------------- go.mod | 1 - go.sum | 10 +- 9 files changed, 86 insertions(+), 448 deletions(-) diff --git a/.gitignore b/.gitignore index d63ce93..0e2f099 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ # Propellerd Build build config.toml - -.env diff --git a/cli/provision.go b/cli/provision.go index a0273b4..88726f6 100644 --- a/cli/provision.go +++ b/cli/provision.go @@ -137,22 +137,22 @@ var provisionCmd = &cobra.Command{ PropletChannel: managerChannel, } - configContent := fmt.Sprintf(`# SuperMQ Environment Configuration - -# Manager Configuration -MANAGER_THING_ID=%s -MANAGER_THING_KEY=%s -MANAGER_CHANNEL_ID=%s - -# Proplet Configuration -PROPLET_THING_ID=%s -PROPLET_THING_KEY=%s -PROPLET_CHANNEL_ID=%s - -# Proxy Configuration -PROXY_THING_ID=%s -PROXY_THING_KEY=%s -PROXY_CHANNEL_ID=%s`, + configContent := fmt.Sprintf(`# SuperMQ Configuration + +[manager] +thing_id = "%s" +thing_key = "%s" +channel_id = "%s" + +[proplet] +thing_id = "%s" +thing_key = "%s" +channel_id = "%s" + +[proxy] +thing_id = "%s" +thing_key = "%s" +channel_id = "%s"`, managerThing.ID, managerThing.Credentials.Secret, managerChannel.ID, @@ -164,12 +164,12 @@ PROXY_CHANNEL_ID=%s`, managerChannel.ID, ) - if err := os.WriteFile(".env", []byte(configContent), filePermission); err != nil { - logErrorCmd(*cmd, errors.New("failed to create .env file")) + if err := os.WriteFile("config.toml", []byte(configContent), filePermission); err != nil { + logErrorCmd(*cmd, errors.New("failed to create config.toml file")) return } - logSuccessCmd(*cmd, "Successfully created .env file") + logSuccessCmd(*cmd, "Successfully created config.toml file") logJSONCmd(*cmd, res) }, diff --git a/cmd/manager/main.go b/cmd/manager/main.go index c17915c..6648f15 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -16,12 +16,12 @@ import ( "github.com/absmach/propeller/manager" "github.com/absmach/propeller/manager/api" "github.com/absmach/propeller/manager/middleware" + "github.com/absmach/propeller/pkg/config" "github.com/absmach/propeller/pkg/mqtt" "github.com/absmach/propeller/pkg/scheduler" "github.com/absmach/propeller/pkg/storage" "github.com/caarlos0/env/v11" "github.com/google/uuid" - "github.com/joho/godotenv" "go.opentelemetry.io/otel/trace" "go.opentelemetry.io/otel/trace/noop" "golang.org/x/sync/errgroup" @@ -31,7 +31,7 @@ const ( svcName = "manager" defHTTPPort = "7070" envPrefixHTTP = "MANAGER_HTTP_" - pathEnv = ".env" + configPath = "config.toml" ) type envConfig struct { @@ -40,9 +40,6 @@ type envConfig struct { MQTTAddress string `env:"MANAGER_MQTT_ADDRESS" envDefault:"tcp://localhost:1883"` MQTTQoS uint8 `env:"MANAGER_MQTT_QOS" envDefault:"2"` MQTTTimeout time.Duration `env:"MANAGER_MQTT_TIMEOUT" envDefault:"30s"` - ThingID string `env:"MANAGER_THING_ID"` - ThingKey string `env:"MANAGER_THING_KEY"` - ChannelID string `env:"MANAGER_CHANNEL_ID"` Server server.Config OTELURL url.URL `env:"MANAGER_OTEL_URL"` TraceRatio float64 `env:"MANAGER_TRACE_RATIO" envDefault:"0"` @@ -52,8 +49,13 @@ func main() { ctx, cancel := context.WithCancel(context.Background()) g, ctx := errgroup.WithContext(ctx) - if _, err := os.Stat(pathEnv); err == nil { - _ = godotenv.Load(pathEnv) + var conf *config.Config + if _, err := os.Stat(configPath); err == nil { + var err error + conf, err = config.LoadConfig(configPath) + if err != nil { + log.Fatalf("failed to load TOML configuration: %s", err.Error()) + } } cfg := envConfig{} @@ -95,7 +97,14 @@ func main() { } tracer := tp.Tracer(svcName) - mqttPubSub, err := mqtt.NewPubSub(cfg.MQTTAddress, cfg.MQTTQoS, svcName, cfg.ThingID, cfg.ThingKey, cfg.ChannelID, cfg.MQTTTimeout, logger) + var thingID, thingKey, channelID string + if conf != nil { + thingID = conf.Manager.ThingID + thingKey = conf.Manager.ThingKey + channelID = conf.Manager.ChannelID + } + + mqttPubSub, err := mqtt.NewPubSub(cfg.MQTTAddress, cfg.MQTTQoS, svcName, thingID, thingKey, channelID, cfg.MQTTTimeout, logger) if err != nil { logger.Error("failed to initialize mqtt pubsub", slog.String("error", err.Error())) @@ -108,7 +117,7 @@ func main() { storage.NewInMemoryStorage(), scheduler.NewRoundRobin(), mqttPubSub, - cfg.ChannelID, + channelID, logger, ) svc = middleware.Logging(logger, svc) diff --git a/cmd/proplet/main.go b/cmd/proplet/main.go index f36e95f..a156112 100644 --- a/cmd/proplet/main.go +++ b/cmd/proplet/main.go @@ -9,17 +9,17 @@ import ( "time" "github.com/absmach/magistrala/pkg/server" + "github.com/absmach/propeller/pkg/config" "github.com/absmach/propeller/pkg/mqtt" "github.com/absmach/propeller/proplet" "github.com/caarlos0/env/v11" "github.com/google/uuid" - "github.com/joho/godotenv" "golang.org/x/sync/errgroup" ) const ( - svcName = "proplet" - pathEnv = ".env" + svcName = "proplet" + configPath = "config.toml" ) type envConfig struct { @@ -29,17 +29,19 @@ type envConfig struct { MQTTTimeout time.Duration `env:"PROPLET_MQTT_TIMEOUT" envDefault:"30s"` MQTTQoS byte `env:"PROPLET_MQTT_QOS" envDefault:"2"` LivelinessInterval time.Duration `env:"PROPLET_LIVELINESS_INTERVAL" envDefault:"10s"` - ThingID string `env:"PROPLET_THING_ID"` - ThingKey string `env:"PROPLET_THING_KEY"` - ChannelID string `env:"PROPLET_CHANNEL_ID"` } func main() { ctx, cancel := context.WithCancel(context.Background()) g, ctx := errgroup.WithContext(ctx) - if _, err := os.Stat(pathEnv); err == nil { - _ = godotenv.Load(pathEnv) + var conf *config.Config + if _, err := os.Stat(configPath); err == nil { + var err error + conf, err = config.LoadConfig(configPath) + if err != nil { + log.Fatalf("failed to load TOML configuration: %s", err.Error()) + } } cfg := envConfig{} @@ -61,15 +63,22 @@ func main() { logger := slog.New(logHandler) slog.SetDefault(logger) - mqttPubSub, err := mqtt.NewPubSub(cfg.MQTTAddress, cfg.MQTTQoS, cfg.InstanceID, cfg.ThingID, cfg.ThingKey, cfg.ChannelID, cfg.MQTTTimeout, logger) + var thingID, thingKey, channelID string + if conf != nil { + thingID = conf.Proplet.ThingID + thingKey = conf.Proplet.ThingKey + channelID = conf.Proplet.ChannelID + } + + mqttPubSub, err := mqtt.NewPubSub(cfg.MQTTAddress, cfg.MQTTQoS, cfg.InstanceID, thingID, thingKey, channelID, cfg.MQTTTimeout, logger) if err != nil { logger.Error("failed to initialize mqtt client", slog.Any("error", err)) return } - wazero := proplet.NewWazeroRuntime(logger, mqttPubSub, cfg.ChannelID) + wazero := proplet.NewWazeroRuntime(logger, mqttPubSub, channelID) - service, err := proplet.NewService(ctx, cfg.ChannelID, cfg.ThingID, cfg.ThingKey, cfg.LivelinessInterval, mqttPubSub, logger, wazero) + service, err := proplet.NewService(ctx, channelID, thingID, thingKey, cfg.LivelinessInterval, mqttPubSub, logger, wazero) if err != nil { logger.Error("failed to initialize service", slog.Any("error", err)) diff --git a/cmd/proxy/main.go b/cmd/proxy/main.go index 2a62515..86e1860 100644 --- a/cmd/proxy/main.go +++ b/cmd/proxy/main.go @@ -8,24 +8,21 @@ import ( "os" "time" + "github.com/absmach/propeller/pkg/config" "github.com/absmach/propeller/proxy" "github.com/caarlos0/env/v11" - "github.com/joho/godotenv" "golang.org/x/sync/errgroup" ) const ( - svcName = "proxy" - pathEnv = ".env" + svcName = "proxy" + configPath = "config.toml" ) type envConfig struct { LogLevel string `env:"PROXY_LOG_LEVEL" envDefault:"info"` MQTTAddress string `env:"PROXY_MQTT_ADDRESS" envDefault:"tcp://localhost:1883"` MQTTTimeout time.Duration `env:"PROXY_MQTT_TIMEOUT" envDefault:"30s"` - ThingID string `env:"PROXY_THING_ID"` - ThingKey string `env:"PROXY_THING_KEY"` - ChannelID string `env:"PROXY_CHANNEL_ID"` // HTTP Registry configuration ChunkSize int `env:"PROXY_CHUNK_SIZE" envDefault:"512000"` @@ -39,8 +36,13 @@ type envConfig struct { func main() { g, ctx := errgroup.WithContext(context.Background()) - if _, err := os.Stat(pathEnv); err == nil { - _ = godotenv.Load(pathEnv) + var conf *config.Config + if _, err := os.Stat(configPath); err == nil { + var err error + conf, err = config.LoadConfig(configPath) + if err != nil { + log.Fatalf("failed to load TOML configuration: %s", err.Error()) + } } cfg := envConfig{} @@ -58,11 +60,18 @@ func main() { logger := slog.New(logHandler) slog.SetDefault(logger) + var thingID, thingKey, channelID string + if conf != nil { + thingID = conf.Proxy.ThingID + thingKey = conf.Proxy.ThingKey + channelID = conf.Proxy.ChannelID + } + mqttCfg := proxy.MQTTProxyConfig{ BrokerURL: cfg.MQTTAddress, - Password: cfg.ThingKey, - PropletID: cfg.ThingID, - ChannelID: cfg.ChannelID, + Password: thingKey, + PropletID: thingID, + ChannelID: channelID, } httpCfg := proxy.HTTPProxyConfig{ diff --git a/docker/.env b/docker/.env index 39ecb95..bd41ca4 100644 --- a/docker/.env +++ b/docker/.env @@ -135,33 +135,6 @@ MG_INVITATIONS_DB_SSL_KEY= MG_INVITATIONS_DB_SSL_ROOT_CERT= MG_INVITATIONS_INSTANCE_ID= -### UI -MG_UI_LOG_LEVEL=debug -MG_UI_PORT=9095 -MG_HTTP_ADAPTER_URL=http://http-adapter:8008 -MG_READER_URL=http://timescale-reader:9011 -MG_THINGS_URL=http://things:9000 -MG_USERS_URL=http://users:9002 -MG_INVITATIONS_URL=http://invitations:9020 -MG_DOMAINS_URL=http://auth:8189 -MG_BOOTSTRAP_URL=http://bootstrap:9013 -MG_UI_HOST_URL=http://localhost:9095 -MG_UI_VERIFICATION_TLS=false -MG_UI_CONTENT_TYPE=application/senml+json -MG_UI_INSTANCE_ID= -MG_UI_DB_HOST=ui-db -MG_UI_DB_PORT=5432 -MG_UI_DB_USER=magistrala -MG_UI_DB_PASS=magistrala -MG_UI_DB_NAME=ui -MG_UI_DB_SSL_MODE=disable -MG_UI_DB_SSL_CERT= -MG_UI_DB_SSL_KEY= -MG_UI_DB_SSL_ROOT_CERT= -MG_UI_HASH_KEY=5jx4x2Qg9OUmzpP5dbveWQ -MG_UI_BLOCK_KEY=UtgZjr92jwRY6SPUndHXiyl9QY8qTUyZ -MG_UI_PATH_PREFIX=/ui - ### Users MG_USERS_LOG_LEVEL=debug MG_USERS_SECRET_KEY=HyE2D4RUt9nnKG6v8zKEqAp6g6ka8hhZsqUpzgKvnwpXrNVQSH @@ -190,6 +163,7 @@ MG_USERS_DB_SSL_ROOT_CERT= MG_USERS_RESET_PWD_TEMPLATE=users.tmpl MG_USERS_INSTANCE_ID= MG_USERS_ALLOW_SELF_REGISTER=true +MG_UI_PATH_PREFIX= MG_OAUTH_UI_REDIRECT_URL=http://localhost:9095${MG_UI_PATH_PREFIX}/tokens/secure MG_OAUTH_UI_ERROR_URL=http://localhost:9095${MG_UI_PATH_PREFIX}/error MG_USERS_DELETE_INTERVAL=24h @@ -259,219 +233,5 @@ MG_MQTT_ADAPTER_INSTANCE= MG_MQTT_ADAPTER_INSTANCE_ID= MG_MQTT_ADAPTER_ES_DB=0 -### CoAP -MG_COAP_ADAPTER_LOG_LEVEL=debug -MG_COAP_ADAPTER_HOST=coap-adapter -MG_COAP_ADAPTER_PORT=5683 -MG_COAP_ADAPTER_SERVER_CERT= -MG_COAP_ADAPTER_SERVER_KEY= -MG_COAP_ADAPTER_HTTP_HOST=coap-adapter -MG_COAP_ADAPTER_HTTP_PORT=5683 -MG_COAP_ADAPTER_HTTP_SERVER_CERT= -MG_COAP_ADAPTER_HTTP_SERVER_KEY= -MG_COAP_ADAPTER_INSTANCE_ID= - -### WS -MG_WS_ADAPTER_LOG_LEVEL=debug -MG_WS_ADAPTER_HTTP_HOST=ws-adapter -MG_WS_ADAPTER_HTTP_PORT=8186 -MG_WS_ADAPTER_HTTP_SERVER_CERT= -MG_WS_ADAPTER_HTTP_SERVER_KEY= -MG_WS_ADAPTER_INSTANCE_ID= - -## Addons Services -### Bootstrap -MG_BOOTSTRAP_LOG_LEVEL=debug -MG_BOOTSTRAP_ENCRYPT_KEY=v7aT0HGxJxt2gULzr3RHwf4WIf6DusPp -MG_BOOTSTRAP_EVENT_CONSUMER=bootstrap -MG_BOOTSTRAP_HTTP_HOST=bootstrap -MG_BOOTSTRAP_HTTP_PORT=9013 -MG_BOOTSTRAP_HTTP_SERVER_CERT= -MG_BOOTSTRAP_HTTP_SERVER_KEY= -MG_BOOTSTRAP_DB_HOST=bootstrap-db -MG_BOOTSTRAP_DB_PORT=5432 -MG_BOOTSTRAP_DB_USER=magistrala -MG_BOOTSTRAP_DB_PASS=magistrala -MG_BOOTSTRAP_DB_NAME=bootstrap -MG_BOOTSTRAP_DB_SSL_MODE=disable -MG_BOOTSTRAP_DB_SSL_CERT= -MG_BOOTSTRAP_DB_SSL_KEY= -MG_BOOTSTRAP_DB_SSL_ROOT_CERT= -MG_BOOTSTRAP_INSTANCE_ID= - -### Provision -MG_PROVISION_CONFIG_FILE=/configs/config.toml -MG_PROVISION_LOG_LEVEL=debug -MG_PROVISION_HTTP_PORT=9016 -MG_PROVISION_ENV_CLIENTS_TLS=false -MG_PROVISION_SERVER_CERT= -MG_PROVISION_SERVER_KEY= -MG_PROVISION_USERS_LOCATION=http://users:9002 -MG_PROVISION_THINGS_LOCATION=http://things:9000 -MG_PROVISION_USER= -MG_PROVISION_USERNAME= -MG_PROVISION_PASS= -MG_PROVISION_API_KEY= -MG_PROVISION_CERTS_SVC_URL=http://certs:9019 -MG_PROVISION_X509_PROVISIONING=false -MG_PROVISION_BS_SVC_URL=http://bootstrap:9013 -MG_PROVISION_BS_CONFIG_PROVISIONING=true -MG_PROVISION_BS_AUTO_WHITELIST=true -MG_PROVISION_BS_CONTENT= -MG_PROVISION_CERTS_HOURS_VALID=2400h -MG_PROVISION_CERTS_RSA_BITS=2048 -MG_PROVISION_INSTANCE_ID= - -### Vault -MG_VAULT_HOST=vault -MG_VAULT_PORT=8200 -MG_VAULT_ADDR=http://vault:8200 -MG_VAULT_NAMESPACE=magistrala -MG_VAULT_UNSEAL_KEY_1= -MG_VAULT_UNSEAL_KEY_2= -MG_VAULT_UNSEAL_KEY_3= -MG_VAULT_TOKEN= - -MG_VAULT_PKI_PATH=pki -MG_VAULT_PKI_ROLE_NAME=magistrala_int_ca -MG_VAULT_PKI_FILE_NAME=mg_root -MG_VAULT_PKI_CA_CN='Magistrala Root Certificate Authority' -MG_VAULT_PKI_CA_OU='Magistrala' -MG_VAULT_PKI_CA_O='Magistrala' -MG_VAULT_PKI_CA_C='FRANCE' -MG_VAULT_PKI_CA_L='PARIS' -MG_VAULT_PKI_CA_ST='PARIS' -MG_VAULT_PKI_CA_ADDR='5 Av. Anatole' -MG_VAULT_PKI_CA_PO='75007' -MG_VAULT_PKI_CLUSTER_PATH=http://localhost -MG_VAULT_PKI_CLUSTER_AIA_PATH=http://localhost - -MG_VAULT_PKI_INT_PATH=pki_int -MG_VAULT_PKI_INT_SERVER_CERTS_ROLE_NAME=magistrala_server_certs -MG_VAULT_PKI_INT_THINGS_CERTS_ROLE_NAME=magistrala_things_certs -MG_VAULT_PKI_INT_FILE_NAME=mg_int -MG_VAULT_PKI_INT_CA_CN='Magistrala Intermediate Certificate Authority' -MG_VAULT_PKI_INT_CA_OU='Magistrala' -MG_VAULT_PKI_INT_CA_O='Magistrala' -MG_VAULT_PKI_INT_CA_C='FRANCE' -MG_VAULT_PKI_INT_CA_L='PARIS' -MG_VAULT_PKI_INT_CA_ST='PARIS' -MG_VAULT_PKI_INT_CA_ADDR='5 Av. Anatole' -MG_VAULT_PKI_INT_CA_PO='75007' -MG_VAULT_PKI_INT_CLUSTER_PATH=http://localhost -MG_VAULT_PKI_INT_CLUSTER_AIA_PATH=http://localhost - -MG_VAULT_THINGS_CERTS_ISSUER_ROLEID=magistrala -MG_VAULT_THINGS_CERTS_ISSUER_SECRET=magistrala - -# Certs -MG_CERTS_LOG_LEVEL=debug -MG_CERTS_SIGN_CA_PATH=/etc/ssl/certs/ca.crt -MG_CERTS_SIGN_CA_KEY_PATH=/etc/ssl/certs/ca.key -MG_CERTS_VAULT_HOST=${MG_VAULT_ADDR} -MG_CERTS_VAULT_NAMESPACE=${MG_VAULT_NAMESPACE} -MG_CERTS_VAULT_APPROLE_ROLEID=${MG_VAULT_THINGS_CERTS_ISSUER_ROLEID} -MG_CERTS_VAULT_APPROLE_SECRET=${MG_VAULT_THINGS_CERTS_ISSUER_SECRET} -MG_CERTS_VAULT_THINGS_CERTS_PKI_PATH=${MG_VAULT_PKI_INT_PATH} -MG_CERTS_VAULT_THINGS_CERTS_PKI_ROLE_NAME=${MG_VAULT_PKI_INT_THINGS_CERTS_ROLE_NAME} -MG_CERTS_HTTP_HOST=certs -MG_CERTS_HTTP_PORT=9019 -MG_CERTS_HTTP_SERVER_CERT= -MG_CERTS_HTTP_SERVER_KEY= -MG_CERTS_GRPC_HOST= -MG_CERTS_GRPC_PORT= -MG_CERTS_DB_HOST=am-certs-db -MG_CERTS_DB_PORT=5432 -MG_CERTS_DB_USER=magistrala -MG_CERTS_DB_PASS=magistrala -MG_CERTS_DB_NAME=certs -MG_CERTS_DB_SSL_MODE= -MG_CERTS_DB_SSL_CERT= -MG_CERTS_DB_SSL_KEY= -MG_CERTS_DB_SSL_ROOT_CERT= -MG_CERTS_INSTANCE_ID= -MG_CERTS_SDK_HOST=http://magistrala-am-certs -MG_CERTS_SDK_CERTS_URL=${MG_CERTS_SDK_HOST}:9010 -MG_CERTS_SDK_TLS_VERIFICATION=false - -### Postgres -MG_POSTGRES_HOST=magistrala-postgres -MG_POSTGRES_PORT=5432 -MG_POSTGRES_USER=magistrala -MG_POSTGRES_PASS=magistrala -MG_POSTGRES_NAME=messages -MG_POSTGRES_SSL_MODE=disable -MG_POSTGRES_SSL_CERT= -MG_POSTGRES_SSL_KEY= -MG_POSTGRES_SSL_ROOT_CERT= - -### Postgres Writer -MG_POSTGRES_WRITER_LOG_LEVEL=debug -MG_POSTGRES_WRITER_CONFIG_PATH=/config.toml -MG_POSTGRES_WRITER_HTTP_HOST=postgres-writer -MG_POSTGRES_WRITER_HTTP_PORT=9010 -MG_POSTGRES_WRITER_HTTP_SERVER_CERT= -MG_POSTGRES_WRITER_HTTP_SERVER_KEY= -MG_POSTGRES_WRITER_INSTANCE_ID= - -### Postgres Reader -MG_POSTGRES_READER_LOG_LEVEL=debug -MG_POSTGRES_READER_HTTP_HOST=postgres-reader -MG_POSTGRES_READER_HTTP_PORT=9009 -MG_POSTGRES_READER_HTTP_SERVER_CERT= -MG_POSTGRES_READER_HTTP_SERVER_KEY= -MG_POSTGRES_READER_INSTANCE_ID= - -### Timescale -MG_TIMESCALE_HOST=magistrala-timescale -MG_TIMESCALE_PORT=5432 -MG_TIMESCALE_USER=magistrala -MG_TIMESCALE_PASS=magistrala -MG_TIMESCALE_NAME=magistrala -MG_TIMESCALE_SSL_MODE=disable -MG_TIMESCALE_SSL_CERT= -MG_TIMESCALE_SSL_KEY= -MG_TIMESCALE_SSL_ROOT_CERT= - -### Timescale Writer -MG_TIMESCALE_WRITER_LOG_LEVEL=debug -MG_TIMESCALE_WRITER_CONFIG_PATH=/config.toml -MG_TIMESCALE_WRITER_HTTP_HOST=timescale-writer -MG_TIMESCALE_WRITER_HTTP_PORT=9012 -MG_TIMESCALE_WRITER_HTTP_SERVER_CERT= -MG_TIMESCALE_WRITER_HTTP_SERVER_KEY= -MG_TIMESCALE_WRITER_INSTANCE_ID= - -### Timescale Reader -MG_TIMESCALE_READER_LOG_LEVEL=debug -MG_TIMESCALE_READER_HTTP_HOST=timescale-reader -MG_TIMESCALE_READER_HTTP_PORT=9011 -MG_TIMESCALE_READER_HTTP_SERVER_CERT= -MG_TIMESCALE_READER_HTTP_SERVER_KEY= -MG_TIMESCALE_READER_INSTANCE_ID= - -### Journal -MG_JOURNAL_LOG_LEVEL=info -MG_JOURNAL_HTTP_HOST=journal -MG_JOURNAL_HTTP_PORT=9021 -MG_JOURNAL_HTTP_SERVER_CERT= -MG_JOURNAL_HTTP_SERVER_KEY= -MG_JOURNAL_DB_HOST=journal-db -MG_JOURNAL_DB_PORT=5432 -MG_JOURNAL_DB_USER=magistrala -MG_JOURNAL_DB_PASS=magistrala -MG_JOURNAL_DB_NAME=journal -MG_JOURNAL_DB_SSL_MODE=disable -MG_JOURNAL_DB_SSL_CERT= -MG_JOURNAL_DB_SSL_KEY= -MG_JOURNAL_DB_SSL_ROOT_CERT= -MG_JOURNAL_INSTANCE_ID= - -### GRAFANA and PROMETHEUS -MG_PROMETHEUS_PORT=9090 -MG_GRAFANA_PORT=3000 -MG_GRAFANA_ADMIN_USER=magistrala -MG_GRAFANA_ADMIN_PASSWORD=magistrala - # Docker image tag MG_RELEASE_TAG=v0.15.1 diff --git a/docker/compose.yaml b/docker/compose.yaml index 7021345..1fde0a3 100644 --- a/docker/compose.yaml +++ b/docker/compose.yaml @@ -168,61 +168,6 @@ services: volumes: - magistrala-invitations-db-volume:/var/lib/postgresql/data - invitations: - image: magistrala/invitations:${MG_RELEASE_TAG} - container_name: magistrala-invitations - restart: on-failure - depends_on: - - auth - - invitations-db - environment: - MG_INVITATIONS_LOG_LEVEL: ${MG_INVITATIONS_LOG_LEVEL} - MG_USERS_URL: ${MG_USERS_URL} - MG_DOMAINS_URL: ${MG_DOMAINS_URL} - MG_INVITATIONS_HTTP_HOST: ${MG_INVITATIONS_HTTP_HOST} - MG_INVITATIONS_HTTP_PORT: ${MG_INVITATIONS_HTTP_PORT} - MG_INVITATIONS_HTTP_SERVER_CERT: ${MG_INVITATIONS_HTTP_SERVER_CERT} - MG_INVITATIONS_HTTP_SERVER_KEY: ${MG_INVITATIONS_HTTP_SERVER_KEY} - MG_INVITATIONS_DB_HOST: ${MG_INVITATIONS_DB_HOST} - MG_INVITATIONS_DB_USER: ${MG_INVITATIONS_DB_USER} - MG_INVITATIONS_DB_PASS: ${MG_INVITATIONS_DB_PASS} - MG_INVITATIONS_DB_PORT: ${MG_INVITATIONS_DB_PORT} - MG_INVITATIONS_DB_NAME: ${MG_INVITATIONS_DB_NAME} - MG_INVITATIONS_DB_SSL_MODE: ${MG_INVITATIONS_DB_SSL_MODE} - MG_INVITATIONS_DB_SSL_CERT: ${MG_INVITATIONS_DB_SSL_CERT} - MG_INVITATIONS_DB_SSL_KEY: ${MG_INVITATIONS_DB_SSL_KEY} - MG_INVITATIONS_DB_SSL_ROOT_CERT: ${MG_INVITATIONS_DB_SSL_ROOT_CERT} - MG_AUTH_GRPC_URL: ${MG_AUTH_GRPC_URL} - MG_AUTH_GRPC_TIMEOUT: ${MG_AUTH_GRPC_TIMEOUT} - MG_AUTH_GRPC_CLIENT_CERT: ${MG_AUTH_GRPC_CLIENT_CERT:+/auth-grpc-client.crt} - MG_AUTH_GRPC_CLIENT_KEY: ${MG_AUTH_GRPC_CLIENT_KEY:+/auth-grpc-client.key} - MG_AUTH_GRPC_SERVER_CA_CERTS: ${MG_AUTH_GRPC_SERVER_CA_CERTS:+/auth-grpc-server-ca.crt} - MG_JAEGER_URL: ${MG_JAEGER_URL} - MG_JAEGER_TRACE_RATIO: ${MG_JAEGER_TRACE_RATIO} - MG_SEND_TELEMETRY: ${MG_SEND_TELEMETRY} - MG_INVITATIONS_INSTANCE_ID: ${MG_INVITATIONS_INSTANCE_ID} - ports: - - ${MG_INVITATIONS_HTTP_PORT}:${MG_INVITATIONS_HTTP_PORT} - networks: - - magistrala-base-net - volumes: - # Auth gRPC client certificates - - type: bind - source: ${MG_AUTH_GRPC_CLIENT_CERT:-ssl/certs/dummy/client_cert} - target: /auth-grpc-client${MG_AUTH_GRPC_CLIENT_CERT:+.crt} - bind: - create_host_path: true - - type: bind - source: ${MG_AUTH_GRPC_CLIENT_KEY:-ssl/certs/dummy/client_key} - target: /auth-grpc-client${MG_AUTH_GRPC_CLIENT_KEY:+.key} - bind: - create_host_path: true - - type: bind - source: ${MG_AUTH_GRPC_SERVER_CA_CERTS:-ssl/certs/dummy/server_ca} - target: /auth-grpc-server-ca${MG_AUTH_GRPC_SERVER_CA_CERTS:+.crt} - bind: - create_host_path: true - nginx: image: nginx:1.25.4-alpine container_name: magistrala-nginx @@ -259,8 +204,6 @@ services: - users - mqtt-adapter - http-adapter - - ws-adapter - - coap-adapter things-db: image: postgres:16.2-alpine @@ -589,101 +532,6 @@ services: bind: create_host_path: true - coap-adapter: - image: magistrala/coap:${MG_RELEASE_TAG} - container_name: magistrala-coap - depends_on: - - things - - nats - restart: on-failure - environment: - MG_COAP_ADAPTER_LOG_LEVEL: ${MG_COAP_ADAPTER_LOG_LEVEL} - MG_COAP_ADAPTER_HOST: ${MG_COAP_ADAPTER_HOST} - MG_COAP_ADAPTER_PORT: ${MG_COAP_ADAPTER_PORT} - MG_COAP_ADAPTER_SERVER_CERT: ${MG_COAP_ADAPTER_SERVER_CERT} - MG_COAP_ADAPTER_SERVER_KEY: ${MG_COAP_ADAPTER_SERVER_KEY} - MG_COAP_ADAPTER_HTTP_HOST: ${MG_COAP_ADAPTER_HTTP_HOST} - MG_COAP_ADAPTER_HTTP_PORT: ${MG_COAP_ADAPTER_HTTP_PORT} - MG_COAP_ADAPTER_HTTP_SERVER_CERT: ${MG_COAP_ADAPTER_HTTP_SERVER_CERT} - MG_COAP_ADAPTER_HTTP_SERVER_KEY: ${MG_COAP_ADAPTER_HTTP_SERVER_KEY} - MG_THINGS_AUTH_GRPC_URL: ${MG_THINGS_AUTH_GRPC_URL} - MG_THINGS_AUTH_GRPC_TIMEOUT: ${MG_THINGS_AUTH_GRPC_TIMEOUT} - MG_THINGS_AUTH_GRPC_CLIENT_CERT: ${MG_THINGS_AUTH_GRPC_CLIENT_CERT:+/things-grpc-client.crt} - MG_THINGS_AUTH_GRPC_CLIENT_KEY: ${MG_THINGS_AUTH_GRPC_CLIENT_KEY:+/things-grpc-client.key} - MG_THINGS_AUTH_GRPC_SERVER_CA_CERTS: ${MG_THINGS_AUTH_GRPC_SERVER_CA_CERTS:+/things-grpc-server-ca.crt} - MG_MESSAGE_BROKER_URL: ${MG_MESSAGE_BROKER_URL} - MG_JAEGER_URL: ${MG_JAEGER_URL} - MG_JAEGER_TRACE_RATIO: ${MG_JAEGER_TRACE_RATIO} - MG_SEND_TELEMETRY: ${MG_SEND_TELEMETRY} - MG_COAP_ADAPTER_INSTANCE_ID: ${MG_COAP_ADAPTER_INSTANCE_ID} - ports: - - ${MG_COAP_ADAPTER_PORT}:${MG_COAP_ADAPTER_PORT}/udp - - ${MG_COAP_ADAPTER_HTTP_PORT}:${MG_COAP_ADAPTER_HTTP_PORT}/tcp - networks: - - magistrala-base-net - volumes: - # Things gRPC mTLS client certificates - - type: bind - source: ${MG_THINGS_AUTH_GRPC_CLIENT_CERT:-ssl/certs/dummy/client_cert} - target: /things-grpc-client${MG_THINGS_AUTH_GRPC_CLIENT_CERT:+.crt} - bind: - create_host_path: true - - type: bind - source: ${MG_THINGS_AUTH_GRPC_CLIENT_KEY:-ssl/certs/dummy/client_key} - target: /things-grpc-client${MG_THINGS_AUTH_GRPC_CLIENT_KEY:+.key} - bind: - create_host_path: true - - type: bind - source: ${MG_THINGS_AUTH_GRPC_SERVER_CA_CERTS:-ssl/certs/dummy/server_ca} - target: /things-grpc-server-ca${MG_THINGS_AUTH_GRPC_SERVER_CA_CERTS:+.crt} - bind: - create_host_path: true - - ws-adapter: - image: magistrala/ws:${MG_RELEASE_TAG} - container_name: magistrala-ws - depends_on: - - things - - nats - restart: on-failure - environment: - MG_WS_ADAPTER_LOG_LEVEL: ${MG_WS_ADAPTER_LOG_LEVEL} - MG_WS_ADAPTER_HTTP_HOST: ${MG_WS_ADAPTER_HTTP_HOST} - MG_WS_ADAPTER_HTTP_PORT: ${MG_WS_ADAPTER_HTTP_PORT} - MG_WS_ADAPTER_HTTP_SERVER_CERT: ${MG_WS_ADAPTER_HTTP_SERVER_CERT} - MG_WS_ADAPTER_HTTP_SERVER_KEY: ${MG_WS_ADAPTER_HTTP_SERVER_KEY} - MG_THINGS_AUTH_GRPC_URL: ${MG_THINGS_AUTH_GRPC_URL} - MG_THINGS_AUTH_GRPC_TIMEOUT: ${MG_THINGS_AUTH_GRPC_TIMEOUT} - MG_THINGS_AUTH_GRPC_CLIENT_CERT: ${MG_THINGS_AUTH_GRPC_CLIENT_CERT:+/things-grpc-client.crt} - MG_THINGS_AUTH_GRPC_CLIENT_KEY: ${MG_THINGS_AUTH_GRPC_CLIENT_KEY:+/things-grpc-client.key} - MG_THINGS_AUTH_GRPC_SERVER_CA_CERTS: ${MG_THINGS_AUTH_GRPC_SERVER_CA_CERTS:+/things-grpc-server-ca.crt} - MG_MESSAGE_BROKER_URL: ${MG_MESSAGE_BROKER_URL} - MG_JAEGER_URL: ${MG_JAEGER_URL} - MG_JAEGER_TRACE_RATIO: ${MG_JAEGER_TRACE_RATIO} - MG_SEND_TELEMETRY: ${MG_SEND_TELEMETRY} - MG_WS_ADAPTER_INSTANCE_ID: ${MG_WS_ADAPTER_INSTANCE_ID} - ports: - - ${MG_WS_ADAPTER_HTTP_PORT}:${MG_WS_ADAPTER_HTTP_PORT} - networks: - - magistrala-base-net - volumes: - # Things gRPC mTLS client certificates - - type: bind - source: ${MG_THINGS_AUTH_GRPC_CLIENT_CERT:-ssl/certs/dummy/client_cert} - target: /things-grpc-client${MG_THINGS_AUTH_GRPC_CLIENT_CERT:+.crt} - bind: - create_host_path: true - - type: bind - source: ${MG_THINGS_AUTH_GRPC_CLIENT_KEY:-ssl/certs/dummy/client_key} - target: /things-grpc-client${MG_THINGS_AUTH_GRPC_CLIENT_KEY:+.key} - bind: - create_host_path: true - - type: bind - source: ${MG_THINGS_AUTH_GRPC_SERVER_CA_CERTS:-ssl/certs/dummy/server_ca} - target: /things-grpc-server-ca${MG_THINGS_AUTH_GRPC_SERVER_CA_CERTS:+.crt} - bind: - create_host_path: true - vernemq: image: magistrala/vernemq:${MG_RELEASE_TAG} container_name: magistrala-vernemq diff --git a/go.mod b/go.mod index 3360a06..c1b4420 100644 --- a/go.mod +++ b/go.mod @@ -63,7 +63,6 @@ require ( require ( github.com/absmach/senml v1.0.6 // indirect github.com/fxamacker/cbor/v2 v2.7.0 // indirect - github.com/joho/godotenv v1.5.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/smartystreets/goconvey v1.8.1 // indirect github.com/x448/float16 v0.8.4 // indirect diff --git a/go.sum b/go.sum index ff704ae..cffaa8d 100644 --- a/go.sum +++ b/go.sum @@ -74,8 +74,6 @@ github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o= github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY= -github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= -github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= @@ -89,6 +87,12 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/nats-io/nats.go v1.38.0 h1:A7P+g7Wjp4/NWqDOOP/K6hfhr54DvdDQUznt5JFg9XA= +github.com/nats-io/nats.go v1.38.0/go.mod h1:IGUM++TwokGnXPs82/wCuiHS02/aKrdYUQkU8If6yjw= +github.com/nats-io/nkeys v0.4.9 h1:qe9Faq2Gxwi6RZnZMXfmGMZkg3afLLOtrU+gDZJ35b0= +github.com/nats-io/nkeys v0.4.9/go.mod h1:jcMqs+FLG+W5YO36OX6wFIFcmpdAns+w1Wm6D3I/evE= +github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= +github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= @@ -105,6 +109,8 @@ github.com/prometheus/common v0.61.0 h1:3gv/GThfX0cV2lpO7gkTUwZru38mxevy90Bj8YFS github.com/prometheus/common v0.61.0/go.mod h1:zr29OCN/2BsJRaFwG8QOBr41D6kkchKbpeNH7pAjb/s= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= +github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw= +github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o= github.com/rubenv/sql-migrate v1.7.1 h1:f/o0WgfO/GqNuVg+6801K/KW3WdDSupzSjDYODmiUq4= github.com/rubenv/sql-migrate v1.7.1/go.mod h1:Ob2Psprc0/3ggbM6wCzyYVFFuc6FyZrb2AS+ezLDFb4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=