Environment variables are a simple mechanism for separating configuration from code. They're key-value pairs that are set in your shell, ready for running applications to read.
Processes don't necessarily execute directly in your shell, however:
Example 3: Passing environment variables using Docker Compose
is a flexible infrastructure orchestration platform that makes it simple to build CI/CD pipelines for your infrastructure. Pipelines are structured as stacks that run jobs inside an isolated Docker container.
When you're using Spacelift, you can define environment variables for your stack by heading to the Environment tab. Here, you can add new key-value environment variable pairs and choose between creating a plain environment variable or a protected secret. The values will then be made available to the jobs in your stack.
to provide API keys, credentials, signatures, and similar protected data types.
2. Ensure your containerized processes are designed to be configured using environment variables
It may sound simple, but many containerization problems stem from developers not designing apps to use environment variables for configuration. Whereas config files may be favored for traditional deployments, adjusting apps to use environment variables instead makes them easier to operate as containers.
3. Prefer .env files and Compose configuration
Using a file-based approach to environment variables makes it easier to check their values, keep track of changes, and provide sensible defaults without making users remember which variables your app requires. Settings can still be easily overridden by specifying multiple .env files when a container starts.
4. Use a consistent environment variable naming scheme
Ensuring all your environment variables have a consistent prefix such as MYAPP_ helps avoid any possible conflicts with keys that are already consumed by other processes on your users' machines.
Remember that, although environment variables are ideal for many situations, they aren't your only option. If you need a very large number of variables or support for typed values, it may still be preferable to use a config file you can or book a demo with one of our engineers.
Written by James Walker
SOCIAL SHARE CARD GENERATOR