dotCMS / dotCMS/core

.env files should not be committed

Open
#32,475 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Team : Platform
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
  1. Security Risk: .env files may accidentally contain sensitive data
  2. Developer Workflow: Developers must manually revert or remove changes to tracked .env files before creating pull requests
  3. Inconsistent Protection: Current .gitignore only excludes .env files under /core-web/**/.env instead 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.example template instead
  • e2e/dotcms-e2e-node/frontend/.env - Empty file with no configuration

GitIgnore Update:

  • Change from /core-web/**/.env to .env for global protection
  • This will prevent .env files from being committed in any directory

Replacement Strategy:

  • Create .env.example files where needed to provide configuration templates
  • Update documentation to instruct developers to copy .env.example to .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 .env files from repository (docker/docker-compose-examples/analytics/.env, e2e/dotcms-e2e-node/frontend/.env)
  • [ ] Update .gitignore to globally exclude .env files (change /core-web/**/.env to .env)
  • [ ] Create .env.example template for analytics configuration
  • [ ] Verify application defaults work without .env files present
  • [ ] Test that developers can create local .env files without Git tracking them
  • [ ] Update relevant documentation to reference .env.example usage pattern
  • [ ] Consider updating LTS branch .gitignore files to prevent future issues

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.