From ddc898b3591d4e17093ebd6e14555c1144db5d3b Mon Sep 17 00:00:00 2001 From: Viktor Baranov Date: Tue, 6 Sep 2022 14:15:18 +0300 Subject: [PATCH] Rename account env vars --- .github/workflows/config.yml | 6 +- apps/explorer/lib/explorer/vault.ex | 4 +- config/runtime.exs | 20 +++---- config/runtime/dev.exs | 12 ++-- config/runtime/prod.exs | 4 +- docker-compose/envs/common-blockscout.env | 16 ++++- docker/Makefile | 72 +++++++++++------------ 7 files changed, 73 insertions(+), 61 deletions(-) diff --git a/.github/workflows/config.yml b/.github/workflows/config.yml index 1b723f98b1..7e5d17bcdb 100644 --- a/.github/workflows/config.yml +++ b/.github/workflows/config.yml @@ -9,9 +9,9 @@ env: MIX_ENV: test OTP_VERSION: '24.3.4.1' ELIXIR_VERSION: '1.13.4' - AUTH0_DOMAIN: 'blockscoutcom.us.auth0.com' - AUTH0_LOGOUT_URL: 'https://blockscoutcom.us.auth0.com/v2/logout' - AUTH0_LOGOUT_RETURN_URL: 'https://blockscout.com/auth/logout' + ACCOUNT_AUTH0_DOMAIN: 'blockscoutcom.us.auth0.com' + ACCOUNT_AUTH0_LOGOUT_URL: 'https://blockscoutcom.us.auth0.com/v2/logout' + ACCOUNT_AUTH0_LOGOUT_RETURN_URL: 'https://blockscout.com/auth/logout' jobs: build-and-cache: diff --git a/apps/explorer/lib/explorer/vault.ex b/apps/explorer/lib/explorer/vault.ex index 76565c7ef0..cd8940157d 100644 --- a/apps/explorer/lib/explorer/vault.ex +++ b/apps/explorer/lib/explorer/vault.ex @@ -7,7 +7,9 @@ defmodule Explorer.Vault do @impl GenServer def init(config) do config = - Keyword.put(config, :ciphers, default: {Cloak.Ciphers.AES.GCM, tag: "AES.GCM.V1", key: decode_env!("CLOAK_KEY")}) + Keyword.put(config, :ciphers, + default: {Cloak.Ciphers.AES.GCM, tag: "AES.GCM.V1", key: decode_env!("ACCOUNT_CLOAK_KEY")} + ) {:ok, config} end diff --git a/config/runtime.exs b/config/runtime.exs index a8baa641af..143fe93b39 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -37,14 +37,14 @@ config :block_scout_web, :footer, # Configures Ueberauth's Auth0 auth provider config :ueberauth, Ueberauth.Strategy.Auth0.OAuth, - domain: System.get_env("AUTH0_DOMAIN"), - client_id: System.get_env("AUTH0_CLIENT_ID"), - client_secret: System.get_env("AUTH0_CLIENT_SECRET") + domain: System.get_env("ACCOUNT_AUTH0_DOMAIN"), + client_id: System.get_env("ACCOUNT_AUTH0_CLIENT_ID"), + client_secret: System.get_env("ACCOUNT_AUTH0_CLIENT_SECRET") # Configures Ueberauth local settings config :ueberauth, Ueberauth, - logout_url: System.get_env("AUTH0_LOGOUT_URL"), - logout_return_to_url: System.get_env("AUTH0_LOGOUT_RETURN_URL") + logout_url: System.get_env("ACCOUNT_AUTH0_LOGOUT_URL"), + logout_return_to_url: System.get_env("ACCOUNT_AUTH0_LOGOUT_RETURN_URL") config :block_scout_web, version: System.get_env("BLOCKSCOUT_VERSION"), @@ -320,17 +320,17 @@ config :explorer, Explorer.SmartContract.RustVerifierInterface, enabled: System.get_env("ENABLE_RUST_VERIFICATION_SERVICE") == "true" config :explorer, Explorer.ThirdPartyIntegrations.AirTable, - table_url: System.get_env("PUBLIC_TAGS_AIRTABLE_URL"), - api_key: System.get_env("PUBLIC_TAGS_AIRTABLE_API_KEY") + table_url: System.get_env("ACCOUNT_PUBLIC_TAGS_AIRTABLE_URL"), + api_key: System.get_env("ACCOUNT_PUBLIC_TAGS_AIRTABLE_API_KEY") config :explorer, Explorer.Mailer, adapter: Bamboo.SendGridAdapter, - api_key: System.get_env("SENDGRID_API_KEY") + api_key: System.get_env("ACCOUNT_SENDGRID_API_KEY") config :explorer, Explorer.Account, sendgrid: [ - sender: System.get_env("SENDGRID_SENDER"), - template: System.get_env("SENDGRID_TEMPLATE") + sender: System.get_env("ACCOUNT_SENDGRID_SENDER"), + template: System.get_env("ACCOUNT_SENDGRID_TEMPLATE") ] ############### diff --git a/config/runtime/dev.exs b/config/runtime/dev.exs index 3c69ee9c1a..a4d0d5b6a7 100644 --- a/config/runtime/dev.exs +++ b/config/runtime/dev.exs @@ -74,15 +74,15 @@ config :explorer, Explorer.Repo.Replica1, url: database_api_url, pool_size: pool_size_api -database_account_url = System.get_env("DATABASE_ACCOUNT_URL") || System.get_env("DATABASE_URL") +database_account_url = System.get_env("ACCOUNT_DATABASE_URL") || System.get_env("DATABASE_URL") pool_size_account = - if System.get_env("DATABASE_ACCOUNT_URL"), - do: String.to_integer(System.get_env("POOL_SIZE_ACCOUNT", "10")), - else: String.to_integer(System.get_env("POOL_SIZE_ACCOUNT", "10")) + if System.get_env("ACCOUNT_DATABASE_URL"), + do: String.to_integer(System.get_env("ACCOUNT_POOL_SIZE", "10")), + else: String.to_integer(System.get_env("ACCOUNT_POOL_SIZE", "10")) -database_account = if System.get_env("DATABASE_ACCOUNT_URL"), do: nil, else: database -hostname_account = if System.get_env("DATABASE_ACCOUNT_URL"), do: nil, else: hostname +database_account = if System.get_env("ACCOUNT_DATABASE_URL"), do: nil, else: database +hostname_account = if System.get_env("ACCOUNT_DATABASE_URL"), do: nil, else: hostname # Configure Account database config :explorer, Explorer.Repo.Account, diff --git a/config/runtime/prod.exs b/config/runtime/prod.exs index 43f07fde42..2b15151aab 100644 --- a/config/runtime/prod.exs +++ b/config/runtime/prod.exs @@ -49,8 +49,8 @@ config :explorer, Explorer.Repo.Replica1, pool_size: pool_size_api, ssl: String.equivalent?(System.get_env("ECTO_USE_SSL") || "true", "true") -database_account_url = System.get_env("DATABASE_ACCOUNT_URL") -pool_size_account = String.to_integer(System.get_env("POOL_SIZE_ACCOUNT", "50")) +database_account_url = System.get_env("ACCOUNT_DATABASE_URL") +pool_size_account = String.to_integer(System.get_env("ACCOUNT_POOL_SIZE", "50")) # Configures Account database config :explorer, Explorer.Repo.Account, diff --git a/docker-compose/envs/common-blockscout.env b/docker-compose/envs/common-blockscout.env index e9d79c47b3..4a1fdaa820 100644 --- a/docker-compose/envs/common-blockscout.env +++ b/docker-compose/envs/common-blockscout.env @@ -125,6 +125,16 @@ FETCH_REWARDS_WAY=trace_block ENABLE_RUST_VERIFICATION_SERVICE=true RUST_VERIFICATION_SERVICE_URL=http://host.docker.internal:8043/ # DATABASE_READ_ONLY_API_URL= -# DATABASE_ACCOUNT_URL= -# POOL_SIZE_ACCOUNT= -CLOAK_KEY= +# ACCOUNT_DATABASE_URL= +# ACCOUNT_POOL_SIZE= +# ACCOUNT_AUTH0_DOMAIN= +# ACCOUNT_AUTH0_CLIENT_ID= +# ACCOUNT_AUTH0_CLIENT_SECRET= +# ACCOUNT_AUTH0_LOGOUT_URL= +# ACCOUNT_AUTH0_LOGOUT_RETURN_URL= +# ACCOUNT_PUBLIC_TAGS_AIRTABLE_URL= +# ACCOUNT_PUBLIC_TAGS_AIRTABLE_API_KEY= +# ACCOUNT_SENDGRID_API_KEY= +# ACCOUNT_SENDGRID_SENDER= +# ACCOUNT_SENDGRID_TEMPLATE= +ACCOUNT_CLOAK_KEY= diff --git a/docker/Makefile b/docker/Makefile index 0e30637b17..5678caa01f 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -355,36 +355,6 @@ endif ifdef CACHE_ADDRESS_TOKEN_TRANSFERS_COUNTER_PERIOD BLOCKSCOUT_CONTAINER_PARAMS += -e 'CACHE_ADDRESS_TOKEN_TRANSFERS_COUNTER_PERIOD=$(CACHE_ADDRESS_TOKEN_TRANSFERS_COUNTER_PERIOD)' endif -ifdef AUTH0_DOMAIN - BLOCKSCOUT_CONTAINER_PARAMS += -e 'AUTH0_DOMAIN=$(AUTH0_DOMAIN)' -endif -ifdef AUTH0_CLIENT_ID - BLOCKSCOUT_CONTAINER_PARAMS += -e 'AUTH0_CLIENT_ID=$(AUTH0_CLIENT_ID)' -endif -ifdef AUTH0_CLIENT_SECRET - BLOCKSCOUT_CONTAINER_PARAMS += -e 'AUTH0_CLIENT_SECRET=$(AUTH0_CLIENT_SECRET)' -endif -ifdef AUTH0_LOGOUT_RETURN_URL - BLOCKSCOUT_CONTAINER_PARAMS += -e 'AUTH0_LOGOUT_RETURN_URL=$(AUTH0_LOGOUT_RETURN_URL)' -endif -ifdef AUTH0_LOGOUT_URL - BLOCKSCOUT_CONTAINER_PARAMS += -e 'AUTH0_LOGOUT_URL=$(AUTH0_LOGOUT_URL)' -endif -ifdef SENDGRID_API_KEY - BLOCKSCOUT_CONTAINER_PARAMS += -e 'SENDGRID_API_KEY=$(SENDGRID_API_KEY)' -endif -ifdef SENDGRID_SENDER - BLOCKSCOUT_CONTAINER_PARAMS += -e 'SENDGRID_SENDER=$(SENDGRID_SENDER)' -endif -ifdef SENDGRID_TEMPLATE - BLOCKSCOUT_CONTAINER_PARAMS += -e 'SENDGRID_TEMPLATE=$(SENDGRID_TEMPLATE)' -endif -ifdef PUBLIC_TAGS_AIRTABLE_URL - BLOCKSCOUT_CONTAINER_PARAMS += -e 'PUBLIC_TAGS_AIRTABLE_URL=$(PUBLIC_TAGS_AIRTABLE_URL)' -endif -ifdef PUBLIC_TAGS_AIRTABLE_API_KEY - BLOCKSCOUT_CONTAINER_PARAMS += -e 'PUBLIC_TAGS_AIRTABLE_API_KEY=$(PUBLIC_TAGS_AIRTABLE_API_KEY)' -endif ifdef API_RATE_LIMIT BLOCKSCOUT_CONTAINER_PARAMS += -e 'API_RATE_LIMIT=$(API_RATE_LIMIT)' endif @@ -499,14 +469,44 @@ endif ifdef RUST_VERIFICATION_SERVICE_URL BLOCKSCOUT_CONTAINER_PARAMS += -e 'RUST_VERIFICATION_SERVICE_URL=$(RUST_VERIFICATION_SERVICE_URL)' endif -ifdef DATABASE_ACCOUNT_URL - BLOCKSCOUT_CONTAINER_PARAMS += -e 'DATABASE_ACCOUNT_URL=$(DATABASE_ACCOUNT_URL)' +ifdef ACCOUNT_AUTH0_DOMAIN + BLOCKSCOUT_CONTAINER_PARAMS += -e 'ACCOUNT_AUTH0_DOMAIN=$(ACCOUNT_AUTH0_DOMAIN)' +endif +ifdef ACCOUNT_AUTH0_CLIENT_ID + BLOCKSCOUT_CONTAINER_PARAMS += -e 'ACCOUNT_AUTH0_CLIENT_ID=$(ACCOUNT_AUTH0_CLIENT_ID)' +endif +ifdef ACCOUNT_AUTH0_CLIENT_SECRET + BLOCKSCOUT_CONTAINER_PARAMS += -e 'ACCOUNT_AUTH0_CLIENT_SECRET=$(ACCOUNT_AUTH0_CLIENT_SECRET)' +endif +ifdef ACCOUNT_AUTH0_LOGOUT_RETURN_URL + BLOCKSCOUT_CONTAINER_PARAMS += -e 'ACCOUNT_AUTH0_LOGOUT_RETURN_URL=$(ACCOUNT_AUTH0_LOGOUT_RETURN_URL)' +endif +ifdef ACCOUNT_AUTH0_LOGOUT_URL + BLOCKSCOUT_CONTAINER_PARAMS += -e 'ACCOUNT_AUTH0_LOGOUT_URL=$(ACCOUNT_AUTH0_LOGOUT_URL)' +endif +ifdef ACCOUNT_SENDGRID_API_KEY + BLOCKSCOUT_CONTAINER_PARAMS += -e 'ACCOUNT_SENDGRID_API_KEY=$(ACCOUNT_SENDGRID_API_KEY)' +endif +ifdef ACCOUNT_SENDGRID_SENDER + BLOCKSCOUT_CONTAINER_PARAMS += -e 'ACCOUNT_SENDGRID_SENDER=$(ACCOUNT_SENDGRID_SENDER)' +endif +ifdef ACCOUNT_SENDGRID_TEMPLATE + BLOCKSCOUT_CONTAINER_PARAMS += -e 'ACCOUNT_SENDGRID_TEMPLATE=$(ACCOUNT_SENDGRID_TEMPLATE)' +endif +ifdef ACCOUNT_PUBLIC_TAGS_AIRTABLE_URL + BLOCKSCOUT_CONTAINER_PARAMS += -e 'ACCOUNT_PUBLIC_TAGS_AIRTABLE_URL=$(ACCOUNT_PUBLIC_TAGS_AIRTABLE_URL)' +endif +ifdef ACCOUNT_PUBLIC_TAGS_AIRTABLE_API_KEY + BLOCKSCOUT_CONTAINER_PARAMS += -e 'ACCOUNT_PUBLIC_TAGS_AIRTABLE_API_KEY=$(ACCOUNT_PUBLIC_TAGS_AIRTABLE_API_KEY)' +endif +ifdef ACCOUNT_DATABASE_URL + BLOCKSCOUT_CONTAINER_PARAMS += -e 'ACCOUNT_DATABASE_URL=$(ACCOUNT_DATABASE_URL)' endif -ifdef POOL_SIZE_ACCOUNT - BLOCKSCOUT_CONTAINER_PARAMS += -e 'POOL_SIZE_ACCOUNT=$(POOL_SIZE_ACCOUNT)' +ifdef ACCOUNT_POOL_SIZE + BLOCKSCOUT_CONTAINER_PARAMS += -e 'ACCOUNT_POOL_SIZE=$(ACCOUNT_POOL_SIZE)' endif -ifdef CLOAK_KEY - BLOCKSCOUT_CONTAINER_PARAMS += -e 'CLOAK_KEY=$(CLOAK_KEY)' +ifdef ACCOUNT_CLOAK_KEY + BLOCKSCOUT_CONTAINER_PARAMS += -e 'ACCOUNT_CLOAK_KEY=$(ACCOUNT_CLOAK_KEY)' endif HAS_BLOCKSCOUT_IMAGE := $(shell docker images | grep -sw "${BS_CONTAINER_IMAGE} ")