Environment variables

In Re-Earth, environment variables are used to store and manage configuration settings that the application can access during runtime. They are typically used to store sensitive information, such as API keys, database connection details, or other configuration values that may vary across different environments (e.g., development, staging, production).

Untitled

To work with environment variables in Re-Earth, you can follow these general steps:

  1. Identify the environment variables you need: Determine which configuration values you want to store as environment variables. These can be specific to the Re-Earth app.
  2. Set environment variables: Depending on your deployment environment, you can set environment variables differently. This can include using a configuration file, a command-line interface, or a hosting platform's interface.
  3. Access environment variables in Re-Earth: In your Re-Earth application's codebase, you can access environment variables using the programming language or framework you are using. Most languages provide a way to access environment variables through libraries or APIs. Refer to the documentation or resources specific to your chosen language or framework to learn how to access environment variables.
  4. Use environment variables in your application: Once you have accessed the environment variables, you can use them in your Re-Earth application as needed. This can include retrieving API keys, connecting to databases, or adjusting other application settings based on the values stored in the environment variables.

In Re-Earth, you can work with environment variables by following these additional steps:

  1. Define environment variables: Determine the specific names and values of the environment variables you want to use. These can be specific configuration settings or custom variables you need for your application.
  2. Use environment variables in Re-Earth configuration: Depending on how Re-Earth is configured, you can access environment variables in the configuration files or code specific to Re-Earth. This can include configuration files for the backend, front end, or any deployment scripts.
  3. Access environment variables in the code: In your Re-Earth application's codebase, you can access the environment variables using the appropriate methods or libraries for the programming language you're using. Common approaches include using libraries like dotenv or accessing environment variables directly through the language's built-in functionality.
  4. Deploying with environment variables: When deploying Re-Earth to a production environment or hosting platform, you'll need to configure the environment variables specific to that platform. Most hosting platforms provide ways to set environment variables through their user interfaces or deployment configurations.
  5. Set environment variables locally: If you're running Re-Earth on your local machine for development, you can set environment variables in your development environment. This can be done through command-line tools, IDE settings, or by using a .env file. Make sure to keep sensitive information secure and avoid committing sensitive data to version control.

The application environment variables should be provided in a .env file as follows:

.env

REEARTH_AUTH0_DOMAIN=hogehoge.auth0.com
REEARTH_AUTH0_AUDIENCE=reearth
REEARTH_AUTH0_CLIENTID=xxxxx
REEARTH_AUTH0_CLIENTSECRET=xxxxxxx

These environment variables are loaded through the GoDotEnv library. Then the app configs are loaded through the envconfig library as follows:

Name Is Required Default Value Description
PORT true 8080 int to configure the server port
REEARTH_DB true mongodb://localhost string to declare database connection string
REEARTH_AUTH0_DOMAIN true Auth config for more details: Link
REEARTH_AUTH0_AUDIENCE true Auth config for more details: Link
REEARTH_AUTH0_CLIENTID true Auth config for more details: Link
REEARTH_AUTH0_CLIENTSECRET false Auth config for more details: Link
REEARTH_AUTH0_WEBCLIENTID false Auth config for more details: Link
REEARTH_GRAPHQL_COMPLEXITYLIMIT false 4000 Set complexity limit for graphql: Link
REEARTH_GCS_BUCKETNAME false
REEARTH_GCS_PUBLICATIONCACHECONTROL false
GOOGLE_CLOUD_PROJECT false
REEARTH_WEB false A map will be injected and exposed as /reearth_config.json for more details see the FE section.
REEARTH_PROFILER false string to select profiler type, for now, the only supported type is gcp
REEARTH_TRACER false string to select tracer type, for now, the supported types are gcp, jaeger
REEARTH_TRACERSAMPLE 0 float64 sample fraction for cloud tracer
REEARTH_ASSETBASEURL string
REEARTH_ORIGINS []string comma-separated values of allowed origins
REEARTH_SIGNUPSECRET string