From 578535888e589b6d8fe822a5b02e6449104b0b38 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 12 Oct 2023 15:43:25 +0530 Subject: [PATCH] Support env variables for Nitro config --- Dockerfile | 4 ++-- environments/example.toml | 8 ++++++++ pkg/serve/config.go | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 031cd0c5..f1aa8605 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM golang:1.19-alpine as debugger +FROM golang:1.21-alpine as debugger # Include dlv RUN go install github.com/go-delve/delve/cmd/dlv@latest -FROM golang:1.19-alpine as builder +FROM golang:1.21-alpine as builder RUN apk --update --no-cache add gcc musl-dev binutils-gold git diff --git a/environments/example.toml b/environments/example.toml index ab22f330..ca1624b5 100644 --- a/environments/example.toml +++ b/environments/example.toml @@ -31,3 +31,11 @@ clientName = "Geth" # $ETH_CLIENT_NAME genesisBlock = "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" # $ETH_GENESIS_BLOCK networkID = "1" # $ETH_NETWORK_ID + +[nitro] + pk = "" + chainPk = "" + chainUrl = "" + naAddress = "" + vpaAddress = "" + caAddress = "" diff --git a/pkg/serve/config.go b/pkg/serve/config.go index 08bc06ec..3a123997 100644 --- a/pkg/serve/config.go +++ b/pkg/serve/config.go @@ -79,6 +79,13 @@ const ( DATABASE_MAX_IDLE_CONNECTIONS = "DATABASE_MAX_IDLE_CONNECTIONS" DATABASE_MAX_OPEN_CONNECTIONS = "DATABASE_MAX_OPEN_CONNECTIONS" DATABASE_MAX_CONN_LIFETIME = "DATABASE_MAX_CONN_LIFETIME" + + NITRO_PK = "NITRO_PK" + NITRO_CHAIN_PK = "NITRO_CHAIN_PK" + NITRO_CHAIN_URL = "NITRO_CHAIN_URL" + NITRO_NA_ADDRESS = "NITRO_NA_ADDRESS" + NITRO_VPA_ADDRESS = "NITRO_VPA_ADDRESS" + NITRO_CA_ADDRESS = "NITRO_CA_ADDRESS" ) type NitroConfig struct { @@ -296,6 +303,13 @@ func (c *Config) dbInit() { func (c *Config) loadNitroConfig() { c.Nitro = &NitroConfig{} + viper.BindEnv("nitro.pk", NITRO_PK) + viper.BindEnv("nitro.chainPk", NITRO_CHAIN_PK) + viper.BindEnv("nitro.chainUrl", NITRO_CHAIN_URL) + viper.BindEnv("nitro.naAddress", NITRO_NA_ADDRESS) + viper.BindEnv("nitro.vpaAddress", NITRO_VPA_ADDRESS) + viper.BindEnv("nitro.caAddress", NITRO_CA_ADDRESS) + c.Nitro.Pk = viper.GetString("nitro.pk") c.Nitro.ChainPk = viper.GetString("nitro.chainPk") c.Nitro.ChainUrl = viper.GetString("nitro.chainUrl")