APP_ENV
environment variable is typically set based on the environment in which the application is running.
Its value corresponds to the specific environment, such as “development”, “staging” or “production”.
This variable helps the application identify its current environment and load the corresponding configuration.
For the web application, by setting the environment variable APP_ENV
,
the application can determine the environment in which it is running and download the appropriate configuration file:
APP_ENV | File |
---|---|
development | .env.development |
staging | .env.staging |
production | .env.production |
.env
file that houses its environment-specific configuration.
This file typically contains variables like API keys, secrets, or other sensitive information.
To ensure security, it’s crucial to add the .env
file to the .gitignore
file,
preventing it from being tracked and committed to the repository.
When deploying to Kubernetes,
you’ll need to include the appropriate environment-specific configuration files in your deployment manifests.
Kubernetes offers ConfigMaps and Secrets
for managing such configurations.
ConfigMaps are suitable for non-sensitive data,
while Secrets are recommended for sensitive information like API keys or database connection string.
Ensure that you create ConfigMaps or Secrets in your Kubernetes cluster
corresponding to the environment-specific files mentioned earlier.
Service | Description | Kubernetes Resource |
---|---|---|
Web | Next.js server that serves static files and API endpoints | Pod |
API | Backend server | Pod |
Scheduler | Service that runs cron jobs | Pod |
Migrator | Service that migrates database schema. It deploys before api through Helm pre-upgrade hook | Job |
Dependency | Description |
---|---|
ingress-nginx | Ingress controller for Kubernetes using Nginx as a reverse proxy and load balancer |
redis | Open source, advanced key-value store |
regcred | Bash script for creating Kubernetes Secret. Secret needs for authorizing in Container Registry when pulling images from cluster. Required only for Digital Ocean clusters |
Folder | Description |
---|---|
.github | GitHub Actions CI/CD pipelines for automated deployment on push in repo |
app | Helm charts for services |
bin | Utils scripts |
dependencies | Helm charts for dependencies |
script | Deployment script |