top | item 21842881

Ask HN: What do you use to start your dev environment faster?

15 points| closingin | 6 years ago | reply

Hello there !

I was wondering what you all use to setup/start your dev envs (nodejs envs most of time for me) ? I used to run some vagrant with virtualbox, but there are a lot of problems with inotify so livereload is difficult to setup and/or not efficient enough depending on the solution you find.

Or maybe do you just /npm start|docker-compose up|rails server|.+/ all of your repos manually? This is what I actually do for small projects, but you always have to help people get your stack up and running.

Tell me how you ease onboarding on your projects! Thanks for your sharing :)

22 comments

order
[+] gls2ro|6 years ago|reply
I am currently using the following combination:

- https://github.com/DarthSim/overmind for running whatever is needed inside a project which has multiple things (like rails and webpacker). It is great because it uses tmux.

- A custom file (.dev-start) I put in my parent folder /project which describes what to execute in child folders (like /project/fe and /project/backend). Possible what this files does could be done with overmind but this is a setup I had before discovering overmind

- A bashrc script (a combination of bash script and bash aliases) which is executed on “cd” command and searches for .dev-start and if exists will execute. In the same script I also search for .browser-wip which is just a simple file with all the URLs I think I need to be open in browser while working on current project. If this file exists then it will open in default browser all links from there.

[+] closingin|6 years ago|reply
Ah this looks interesting! Gonna take a look at this, thx!
[+] SkyLinx|6 years ago|reply
I work with Docker and Kubernetes do my dev environment is actually in my cluster rather than locally. I use Okteto to manage this dev env so I can even switch computers and all I need is the source code of my app and one 'okteto up' command, and I'm ready to go
[+] closingin|6 years ago|reply
This might be a little bit too overkill for my current needs, but I'll definitely keep this one in my bag! Thanks for sharing!
[+] Raed667|6 years ago|reply
The "trick" that saved me a lot of time, and my laptop from overheating, is to work on one project at a time.

Need to change the API? Do that and deploy it. Need to change a React app that uses the API? run it locally and call a private instance of the server instead of running both in parallel..

[+] closingin|6 years ago|reply
I get what you mean, but my question is more about how you can run your dev environment when your "project" requires you to have multiple things running (a react spa, a rails backend, three microservices, two databases, ...). Understand "do you have one single command to run all of your resources or do you start them one by one?".

Thanks for your reply though ! Your solution might fit people who have dedicated instances for projects.

[+] potta_coffee|6 years ago|reply
Docker-compose is the best thing I've found for sharing dev environments so far. You do have to help people, but if you do a good job, they'll learn and then they can help other people too.
[+] haecceity|6 years ago|reply
Aren’t node projects just npm i; npm start? Maybe clearer documentation would help. Like step by step what commands to run to build and run. It's weird I see some projects that expect contributors to figure that out themselves. Or maybe they don't want contributors.
[+] closingin|6 years ago|reply
I'm more asking about how you start an entire dev environment, like when you have your front 1, front 2, api 1, microservice 1-2-3-4, ... that all need to be running in order for you to start working.

For example: using pm2 to start your entire stack in one command (only when it's all nodejs obviously)

It's not really related to the tech you use for every project :)

[+] hauxir|6 years ago|reply
docker and docker-compose with the project root mounted as /app usually does the trick for me.
[+] dvaletin|6 years ago|reply
We are using docker-compose with mounting your local files inside of the container. You can either switch do docker or mount your local folder in VM via vagrant. Not sure live reload will work with the latter solution, but works pretty well with docker.
[+] bg117|6 years ago|reply
Try to use script files with actual commands that does the work instead of typing in commands each time. Saves lot of time and effort.
[+] t_m_|6 years ago|reply
> I used to run some vagrant with virtualbox, but there are a lot of problems with inotify so livereload is difficult to setup. Which livereload tool do you use?
[+] closingin|6 years ago|reply
Whatever the livereload tool is (in this case it was a webpack watcher on osx), the problem is that a change on the host isn't forwarded to the guest correctly when using shared folders, so the socket server doesn't send the update notification to the browser. :/

You have three options to work around this : - use a polling based approach - use a plugin like https://github.com/adrienkohlbecker/vagrant-fsnotify which internally uses `touch` (this is the one i used to choose) - use an ssh mount (not sure about this one, it's been a long time)

All of these workarounds have their downsides, so I'm wondering if someone has another great approach to get a stack up and running when you have a lot of dependencies (not speaking about packages, but different sub-projects)

[+] muzani|6 years ago|reply
I'm a big fan of the idea that a build should be done with one command line. Mine is 'npm run d' for dev, 'npm run p' for production.

This is a nice chart: https://xkcd.com/1205/

If you're doing it daily and it takes half an hour, you could probably dedicate 5 weeks to optimizing this.

If you're doing builds like me, it's more like 20 builds a day, each taking an extra minute. That's about a month worth of optimizing.

[+] kyle_v|6 years ago|reply
In one vscode tab ‘cd client’ ‘npm start’ in another ‘cd server’ ‘npm run dev’
[+] ydnaclementine|6 years ago|reply
tmuxinator to open all of my panels, services etc for each project with a single command