Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing docker-compose with Nix for development #28

Merged
merged 23 commits into from
Mar 5, 2024
Merged

Conversation

shivaraj-bh
Copy link
Member

@shivaraj-bh shivaraj-bh commented Mar 3, 2024

Preview:

nix run github:nixos-asia/website/ny-services-flake#preview

@shivaraj-bh shivaraj-bh marked this pull request as ready for review March 3, 2024 18:25
@shivaraj-bh shivaraj-bh requested a review from srid March 3, 2024 18:28
Copy link
Member

@srid srid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flow is pretty good!

I'd mention and link to https://nixos.asia/en/flake-parts in some capacity.

Comment on lines 81 to 83
### Redis

Redis and its clustered version are pretty straightforward:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you expand this to say what this provides? How does the redis cluster operate? How many nodes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Ever since I first started using [[nix]], I have enjoyed the [[why-dev|simplicity of setup]]: `nix develop`, make the code change and see it work. That's all well and good, but when your project keeps growing, you need to depend on external services like databases, message brokers, etc. And then a quick search will tell you that [docker](https://www.docker.com/) is the way to go. You include it, [add one more step](https://github.com/nammayatri/nammayatri/tree/f056bb994fbf9adefa454319032ca35c34ea65bc/Backend#other-tools) in the setup guide, increasing the barrier to entry for new contributors. Not to forget, eating up all my system resources on my not so powerful, company provided, macOS[^native-macos].

This, along with the fact that we can provide one command to do a lot of **cool things** (which you will see, as you continue to read), made us want to replace [docker-compose](https://docs.docker.com/compose/) with Nix in [Nammayatri](https://github.com/nammayatri/nammayatri) (to keep it simple, I will refer to it as NY from now on).
Copy link
Member

@srid srid Mar 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A brief intro to what NY project is (perhaps as a [!note]) is useful.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 100 to 103
Here's the screen grab of the devShell and the commands to run loadtest and the entire backend:
:::{.center}
![[ny-devshell.png]]
:::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

People unfamiliar with mission-control may not be able to relate to this. So maybe we should just mention the nix run part.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


By not depending on docker anymore, we can now run the entire NY backend with one command and its all defined in a [single place](https://github.com/nammayatri/nammayatri/blob/ccab8da607cfd8d4e9f7d28b55b83e22eec1af9b/Backend/nix/services/nammayatri.nix).

That is not all, we can also reuse this to do much more, like defining [loadtest](https://github.com/nammayatri/nammayatri/blob/ccab8da607cfd8d4e9f7d28b55b83e22eec1af9b/Backend/load-test/default.nix) config and run it in CI/local, again, with one command.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it in scope for this blog post to expand on the loadtest? In particular, emphasizing on how users can share services-flake modules, and then build on top of them. Here, we take the module to run entire NY stack, and then extend it to add a bunch of load-test processes, before bringing the whole thing end (as the load-test ends).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good idea to mention load-test because it is one of the things we are able to do as a result of adding services-flake. If that complicates things, I can probably remove it and talk about it in another post explaining how you can reuse services, courtesy of flake-parts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add a sentence or two introducing the users about it, and then dedicate another post on it as you see fit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied the second half from your comment to expand on load-test

@srid
Copy link
Member

srid commented Mar 3, 2024

One more thing: At the end of the post, I'd also include link to our Zulip for people wanting to 'comment' on the post.

(Though perhaps eventually we should include a after-note template for it; let me think about this)

@srid srid merged commit de7ff4a into master Mar 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants