-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(env): implement unified file loading in console-web
refs #313
- Loading branch information
1 parent
1fec106
commit 20ebd93
Showing
103 changed files
with
762 additions
and
551 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,3 +44,5 @@ sentry.properties | |
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ | ||
|
||
env-config.schema.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,21 +14,33 @@ The website should be accessible: [http://localhost:3000/](http://localhost:3000 | |
|
||
## Environment Variables | ||
|
||
When running the api locally the following environment variables can be set in a `.env.local` file. | ||
|
||
It is possible to run the website locally without any environment variables, but the login feature will be unavailable. | ||
|
||
|Name|Value|Note| | ||
|-|-|- | ||
|NEXT_PUBLIC_GA_MEASUREMENT_ID|ex: `G-87H3KK3D`|Google Analytics ID | ||
|NEXT_PUBLIC_SENTRY_DSN|ex: `"https://[email protected]/1234"`|[Sentry DSN](https://docs.sentry.io/product/sentry-basics/dsn-explainer/) used when initializing Sentry in [sentry.client.config.js](./sentry.client.config.js) and [sentry.server.config.js](./sentry.server.config.js) | ||
|AUTH0_SECRET|| | ||
|AUTH0_BASE_URL|| | ||
|AUTH0_ISSUER_BASE_URL|| | ||
|AUTH0_CLIENT_ID|| | ||
|AUTH0_CLIENT_SECRET|| | ||
|AUTH0_AUDIENCE|| | ||
|AUTH0_SCOPE|| | ||
|AUTH0_M2M_DOMAIN|| | ||
|AUTH0_M2M_CLIENT_ID|| | ||
|AUTH0_M2M_CLIENT_SECRET|| | ||
### Overview | ||
Environment variables in this Next.js app follow the standard Next.js behavior, as documented in the [Next.js environment variables documentation](https://nextjs.org/docs/basic-features/environment-variables). This means that files like `.env.local` or `.env.production` will be automatically loaded based on the environment in which the app is running. | ||
|
||
However, we have extended this functionality to support more granular environment-specific configurations. Environment variables are stored in the `./env` directory, where multiple `.env` files exist for different deployment environments (stages): | ||
|
||
- `.env` - Loaded for any environment | ||
- `.env.production` - Loaded for the production stage | ||
- `.env.staging` - Loaded for the staging stage | ||
|
||
### How Environment Variables Are Loaded | ||
We use **dotenvx** to manage and load environment variables. This allows us to take advantage of its features, such as **variable interpolation** (i.e., using other environment variables within variable values). | ||
|
||
### Validation with Zod | ||
Environment variables are validated using **Zod** schemas, ensuring that all required variables are present and have valid values. The validation logic can be found in the file `src/config/env-config.schema.ts`. | ||
|
||
We use two separate Zod schemas: | ||
- **Static Build-Time Schema**: Validates variables at build time. If any variables are missing or invalid during the build process, the build will fail. | ||
- **Dynamic Server Runtime Schema**: Validates variables at server startup. If any variables are missing or invalid at this stage, the server will fail to start. | ||
|
||
This validation ensures that both build and runtime configurations are secure and complete before the app runs. | ||
|
||
### App Configuration | ||
App configurations, including environment variables, are located in the `src/config` directory. In our setup: | ||
- **Environment configs** are handled separately from **hardcoded configs**. | ||
- Hardcoded configs are organized by domain to maintain a clear structure and separation of concerns. | ||
|
||
### Sample Environment Variables | ||
All environment variables required for the app, along with their expected structure and types, can be found in the `env/.env.sample` file. This sample file serves as a template for setting up your environment variables and ensures that all necessary variables are accounted for in each environment. | ||
|
||
By organizing environment variables and configuration this way, we ensure a consistent, safe, and scalable approach to managing different deployment environments. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
AUTH0_AUDIENCE=https://api.cloudmos.io | ||
AUTH0_SCOPE=openid profile email offline_access |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
AUTH0_BASE_URL=https://console.akash.network | ||
AUTH0_ISSUER_BASE_URL=https://auth.cloudmos.io | ||
|
||
NEXT_PUBLIC_BILLING_ENABLED=false | ||
NEXT_PUBLIC_MANAGED_WALLET_NETWORK_ID=mainnet | ||
NEXT_PUBLIC_MANAGED_WALLET_DENOM=usdc | ||
# TODO: replace with a fresh master wallet before release | ||
NEXT_PUBLIC_MASTER_WALLET_ADDRESS=akash1ss0d2yw38r6e7ew8ndye9h7kg62sem36zak4d5 | ||
|
||
NEXT_PUBLIC_STATS_APP_URL=https://stats.akash.network | ||
NEXT_PUBLIC_PROVIDER_PROXY_URL=https://providerproxy.cloudmos.io | ||
NEXT_PUBLIC_PROVIDER_PROXY_URL_WS=wss://providerproxy.cloudmos.io | ||
NEXT_PUBLIC_NODE_ENV=$NODE_ENV | ||
NEXT_PUBLIC_BASE_API_MAINNET_URL=https://api.cloudmos.io | ||
NEXT_PUBLIC_BASE_API_SANDBOX_URL=https://api-sandbox.cloudmos.io | ||
NEXT_PUBLIC_BASE_API_TESTNET_URL=https://api-testnet.cloudmos.io | ||
NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_BASE_API_MAINNET_URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
DEPLOYMENT_ENV | ||
|
||
AUTH0_BASE_URL= | ||
AUTH0_ISSUER_BASE_URL= | ||
AUTH0_SECRET | ||
AUTH0_CLIENT_ID | ||
AUTH0_CLIENT_SECRET | ||
|
||
NEXT_PUBLIC_BILLING_ENABLED= | ||
NEXT_PUBLIC_MANAGED_WALLET_NETWORK_ID= | ||
NEXT_PUBLIC_MANAGED_WALLET_DENOM= | ||
NEXT_PUBLIC_MASTER_WALLET_ADDRESS= | ||
NEXT_PUBLIC_STATS_APP_URL= | ||
NEXT_PUBLIC_PROVIDER_PROXY_URL= | ||
NEXT_PUBLIC_PROVIDER_PROXY_URL_WS= | ||
NEXT_PUBLIC_NODE_ENV= | ||
NEXT_PUBLIC_BASE_API_MAINNET_URL= | ||
NEXT_PUBLIC_BASE_API_SANDBOX_URL= | ||
NEXT_PUBLIC_BASE_API_TESTNET_URL= | ||
NEXT_PUBLIC_API_BASE_URL= | ||
NEXT_PUBLIC_SENTRY_DSN= | ||
NEXT_PUBLIC_SENTRY_SERVER_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
AUTH0_BASE_URL=https://console-beta.akash.network | ||
AUTH0_ISSUER_BASE_URL=https://dev-5aprb0lr.us.auth0.com | ||
|
||
NEXT_PUBLIC_BILLING_ENABLED=true | ||
NEXT_PUBLIC_MANAGED_WALLET_NETWORK_ID=mainnet | ||
NEXT_PUBLIC_MANAGED_WALLET_DENOM=usdc | ||
NEXT_PUBLIC_MASTER_WALLET_ADDRESS=akash1ss0d2yw38r6e7ew8ndye9h7kg62sem36zak4d5 | ||
|
||
NEXT_PUBLIC_STATS_APP_URL=https://stats.akash.network | ||
NEXT_PUBLIC_PROVIDER_PROXY_URL=https://providerproxy.cloudmos.io | ||
NEXT_PUBLIC_PROVIDER_PROXY_URL_WS=wss://providerproxy.cloudmos.io | ||
NEXT_PUBLIC_NODE_ENV=$NODE_ENV | ||
NEXT_PUBLIC_BASE_API_MAINNET_URL=https://api-mainnet-staging.cloudmos.io | ||
NEXT_PUBLIC_BASE_API_SANDBOX_URL=https://api-sandbox-staging.cloudmos.io | ||
NEXT_PUBLIC_BASE_API_TESTNET_URL=$NEXT_PUBLIC_BASE_API_MAINNET_URL | ||
NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_BASE_API_MAINNET_URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.