# Environments
Environment refers to a set of variables loaded when the project runs. We must differentiate between frontend and backend set of environments.
In frontend everything is public and can be accessed from the browser, so we commit all the environments to this repo. The environment variables are used at build time and copied to the bundle.
However, for then backend, we only commit development and staging environments to this repo, while keeping production environment somewhere else. This production environment is loaded on CI to avoid leaking important keys and secrets.
Environments are defined in .env.[mode]
files where mode
can be anything: development
, staging
, production
, test
, etc.
Local changes can be included in .env.[mode].local
files, which are ignored by Git. These files are useful to apply a custom environment for your specific development process (say you need to use a different DB for a feature, etc).
The file .env
is a place to put common variables to all environments.
These files are loaded using multienv-loader
.
# Development
Contains variables for running the app locally during development. Each developer must install Docker and to lift the development environment, which includes a local PostgreSQL database, a Hasura server, and a Node.js Express server that runs the functions.
# Staging
Contains variables for running the app in the staging server. Staging mimics production but uses different servers and URLs.
# Production
Contains variables for running the app in the production server. The variables for the backend are located in a repo called v-wonderland-production/japanrabbit/api/.env.production
, and are downloaded at deploy time from the CI service.
# Test
Testing environment for unit, e2e and integration. They can be divided in different files such as .env.test
and .env.integration
as needed.