Ask HN: What clever tools/scripts do you use to manage development environments?

10 points by sebst ↗ HN
I see a lot of people using some scripts with tmux and dotenv/direnv.

I’m wondering if you have any clever productivity hacks for switching between different projects, managing infrastructure services, secrets, tools, versions etc.

9 comments

[ 3.2 ms ] story [ 33.3 ms ] thread
I’m ashamed to admit we have a discord channel for each project and we dump secrets there with access control to the channels based on who works on the project.

It’s peak startup opsec.

Earlier this year I made this https://doocot.sh/ for securely sharing secrets between people.

It's written in Go with no dependencies (or database). My intention was for an AWS image or something companies could run inhouse air-gapped from the Internet. Something like $10/m or so.

The cli is pretty easy to integrate with scripts: https://github.com/thisdougb/doocot

Longer term secrets were something I was looking at too. Pretty easy to extend this, but encroaches on Vault products and I felt that a harder sell to CTOs.

I've worked in infra/systems dev for years, and this sort of thing was bread and butter stuff.

Maybe I'll resurect it as an active project. What sort of feature/tool would get you to stop using Discord/Slack/etc for secrets?

Nothing fancy. Direnv with mise can handle most environment differences. Direnv with 1password integration adds secrets. Infrastructure lives as code in the `infrastructure/` directory of the project. Nix manages all tooling and native library requirements.
This feels pretty primitive, but you can write a startup script for each specific project e.g. say one called `project123` where when you run it from the terminal, it switches to your project directory, starts Docker, runs the local dev startup command, opens your IDE, pulls from Git, opens the GitHub page of issues assigned to you, open a browser pointing to your localhost server etc. and whatever common stuff you need to do each day.

Add some scripting at the start to close windows/programs that might be sticking around from other projects, and now you can switch between projects with a lot less friction.

I always try to automate this because you get situations where you e.g. want to quickly fix a typo in a project, run tests, and push a commit, but because you fumbled on some dev step you forgot to do, you burn 15 mins figuring out why the dev environment won't start.

For NodeJS I like to use a .env.local that can be copied to .env to provide all the configuration necessary for local development. I use a .nvmrc to pin the nodejs version managed by nvm, and all package.json scripts use packages installed to that project not globally, and "scripts" run `nvm exec npx ...`. All of this means when I go into the directory it automatically use the right node, the right packages, the right secrets and configuration, and the next project can use an entirely different combination of versions and packages.

Infrastructure I put into a docker compose file, everything gets a non-default port to coexist, .env.local is preconfigured with relevant addresses.

Databases I use Sequelize migration and seeder scripts to create and populate.