How to manage .env secrets across multiple projects

Learn how a solo developer uses Dopbase to manage .env secrets across multiple projects without keeping plaintext copies in every repository.

  • .env
Three project folders connect to one safe, and a developer stands beside it holding a key.
Three project folders connect to one safe, and a developer stands beside it holding a key.

AI coding tools have made it realistic for one developer to build and maintain several applications at once.

My own version of that story started after I was laid off. I began building applications that could help other people and, hopefully, generate some income.

Every application needed a .env file for database hosts, API keys, service credentials, and other environment-specific values. With one project that was manageable. By the third, handling separate secret files had become a chore of its own: creating a file was easy, but keeping every project’s values organized, current, and out of the wrong environment was not.

I wanted one place to manage those secrets without changing how my applications read environment variables, and I ended up using Dopbase.

What is Dopbase?

Dopbase is an open-source, self-hosted secrets manager built around projects, environments, and individual secret records. The current Dopbase 0.1.6 release packages its server, CLI, Admin UI, REST API, migrations, and SQLite storage into one executable.

Its structure matches the way I already organize applications:

Project
  └── Environment
        └── Secrets

A project can represent an application, while environments hold its development, staging, or production values.

Dopbase encrypts secret values before persistence. Its documented security model keeps the master key separate from the SQLite database.

When an application starts, dopbase run retrieves one environment and injects its values into the child process. It does not create another .env file, so my applications keep using normal environment variables and no working credentials are left inside each repository.

How I set up Dopbase

I started with a local installation and one low-risk development project, which kept the first test easy to inspect and reverse.

On macOS or Linux, the official installer downloads the matching release and verifies its checksum:

curl -fsSL https://dopbase.com/install.sh | sh
dopbase -v

Next, I started the local server:

dopbase server start

The server exposes its Admin UI at http://localhost:8840. I completed the initial setup on that page, then signed in through the CLI:

dopbase login

The quick-start guide covers the complete installation and first-run process.

Importing each project’s .env file

From an application’s directory, I created a Dopbase project and imported its development values:

dopbase init invoice-app/development --from .env

The command creates the project and environment, then stores each entry as an individual secret. I repeated that step from each application directory.

An existing project that needs another environment takes three commands:

dopbase env create invoice-app/staging
dopbase import invoice-app/staging .env.staging --dry-run
dopbase import invoice-app/staging .env.staging

The dry run shows which keys would change before the real import. Dopbase also validates the complete file before updating server state.

Check the imported keys and run the application successfully before removing any original plaintext file.

Running an application with the right secrets

Starting an application now requires an explicit project and environment:

dopbase run invoice-app/development -- bun run dev

Dopbase retrieves the selected values and passes them to the child process. Managed values override matching variables inherited from the parent process.

The application reads DATABASE_URL, API_KEY, and its other variables exactly as before. Only the storage and delivery changed. For a Node.js example, see how to move from dotenv to runtime injection.

This was useful across different stacks because the command after -- can be any application command:

dopbase run api-service/development -- cargo run
dopbase run marketing-site/development -- bun run dev
dopbase run automation-worker/development -- python app.py

Each command names its environment, so I am less likely to load values from the wrong local file without noticing.

Why this workflow feels more efficient

Each application now has a named project, and each deployment context has a named environment, so I no longer need an informal folder system for working secrets. When a value changes I update it in one specific environment, and I know where the current value is.

The same command pattern works across my projects, whatever their language or framework. I choose the target, then start the application normally.

The repository can keep an .env.example with variable names and harmless placeholders, while working values stay outside the normal coding workspace. That helps with coding agents too, because any tool with workspace access can read an ignored .env file. The guides on AI agents reading .env files and keeping secrets outside AI coding workspaces explain that risk.

Dopbase does not make injected values invisible to the receiving application. A compromised child process can still print or misuse any secret it receives.

Production also needs stricter controls than local development. Use separate credentials and review the guide to separating development and production secrets.

Self-hosting also means managing TLS, network access, master-key protection, backups, monitoring, upgrades, and recovery tests yourself.

Common questions

Can Dopbase manage secrets for multiple projects?

Yes. Each application gets its own project with separate development, staging, and production environments.

Does Dopbase completely replace .env files?

Dopbase can replace plaintext .env files as permanent storage while still importing dotenv files and delivering values as environment variables.

Does dopbase run write secrets to disk?

It does not create a new .env file. It injects the selected values into the child process environment.

Can an AI coding agent read injected secrets?

Yes, if the agent receives those variables or controls the process using them. Keep routine agent work on fake or restricted values.

Is Dopbase free for solo developers?

Dopbase uses the Apache 2.0 license without per-seat fees. Self-hosted users still pay for infrastructure and handle operations.

Conclusion

After using Dopbase, I stopped treating every application’s .env file as a separate secret store that I had to manage manually. My applications use ordinary environment variables as before, and Dopbase stores the values centrally and loads the selected environment only when needed.

It helps most when I move between several projects in a week, because the project and environment names in each command show which values I am about to load.

If you want to try it, begin with one low-risk development application. Import its .env, verify the keys, run it through Dopbase, and test backup recovery before expanding further.