.env files should not be committed
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 970
- Forks
- 486
- Avg merge
- 3d 33m
- Merged PRs (30d)
- 170
Description
Description
This PR addresses security and workflow issues with .env files in the repository by implementing proper .gitignore patterns and removing committed .env files.
Background
.env files are commonly used by developers to override environment variables for various systems (Docker Compose, Node apps, etc.). While example files (.env.example) can be safely committed as templates, actual .env files should never be checked in because they may contain sensitive information like API keys, database credentials, or other secrets.
Current Issues
- Security Risk:
.envfiles may accidentally contain sensitive data - Developer Workflow: Developers must manually revert or remove changes to tracked
.envfiles before creating pull requests - Inconsistent Protection: Current
.gitignoreonly excludes.envfiles under/core-web/**/.envinstead of globally
Changes
Files to Remove:
docker/docker-compose-examples/analytics/.env- Contains default configuration values (localhost URLs, demo credentials) that should be provided via.env.exampletemplate insteade2e/dotcms-e2e-node/frontend/.env- Empty file with no configuration
GitIgnore Update:
- Change from
/core-web/**/.envto.envfor global protection - This will prevent
.envfiles from being committed in any directory
Replacement Strategy:
- Create
.env.examplefiles where needed to provide configuration templates - Update documentation to instruct developers to copy
.env.exampleto.env - Ensure application code provides sensible defaults for all environment variables
Note: Files like .env.ci and .env.dev remain committed as they contain non-sensitive configuration suitable for version control.
Security Confirmation
The docker/docker-compose-examples/analytics/.env file has been reviewed and contains only default/demo values (localhost URLs, admin@dotcms.com/admin credentials) rather than production secrets. It is safe to remove.
Additional Considerations
Even after updating .gitignore, developers switching to older branches may still see .env files as committable. Consider updating .gitignore in LTS branches to prevent this issue.
Acceptance Criteria
- [ ] Remove
.envfiles from repository (docker/docker-compose-examples/analytics/.env,e2e/dotcms-e2e-node/frontend/.env) - [ ] Update
.gitignoreto globally exclude.envfiles (change/core-web/**/.envto.env) - [ ] Create
.env.exampletemplate for analytics configuration - [ ] Verify application defaults work without
.envfiles present - [ ] Test that developers can create local
.envfiles without Git tracking them - [ ] Update relevant documentation to reference
.env.exampleusage pattern - [ ] Consider updating LTS branch
.gitignorefiles to prevent future issues
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the repository .gitignore and inspect docker/docker-compose-examples/analytics/.env and e2e/dotcms-e2e-node/frontend/.env, along with any existing .env.example files and related documentation. Verify the named files are removed, local .env files are ignored globally, and the analytics configuration remains documented with suitable defaults.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker-compose, git
- Domain
- devops, documentation, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100