.env- -
For advanced scenarios, use docker-compose.override.yml or environment‑specific Compose files, but .env- files keep configuration simple.
Because the actual .env file is hidden from Git, other developers cloning your repository won't know what configuration variables the project requires. To fix this, create a .env.example file.
Do you need help writing a to manage your environments? For advanced scenarios, use docker-compose
(or .env-prod ): Contains highly sensitive production credentials and optimized performance settings.
When a new developer joins a project, they shouldn't have to guess which API keys are required. An .env.example file provides a blueprint, ensuring everyone has the same foundation. 3. Security Do you need help writing a to manage your environments
Only template files like .env-sample belong in public source control. Add specific environment files to your .gitignore file immediately upon project initialization:
Here are some common issues you may encounter when working with .env files: An .env.example file provides a blueprint
# .github/workflows/security.yml name: Block .env- files on: [push, pull_request] jobs: check-env-files: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Ban .env- pattern run: | if find . -type f -name ".env-*" | grep -q .; then echo "::error::Found .env- files. Rename them immediately." exit 1 fi
| Feature | .env- files | YAML / JSON | | ---------------------- | ---------------------- | ------------------------------ | | Simplicity | Key‑value, no nesting | Supports hierarchies & arrays | | Shell compatibility | Directly source -able | Needs parsing | | 12‑Factor compliance | ✅ Yes | ❌ No (often files are checked in) | | Standard tooling | dotenv everywhere | Custom parsers per language | | Type safety | Strings only | Native types (numbers, booleans) |