The post belongs to NectarCommerce and Extension Framework Awareness Series
- NectarCommerce Vision
- Extension Framework Game Plan
- Introduction to Metaprogramming
- Ecto Model Schema Extension
- Ecto Model Support Functions Extension
- Phoenix Router Extension
- Phoenix View Extension
- Running Multiple Elixir Apps Together
- Extension Approach Explained
- Learning from failures: First Experiment at NectarCommerce Extension Approach
- Developing NectarCommerce Extensions
- Building an exrm release including NectarCommerce
Building an exrm release including NectarCommerce
You can read more about how to build an exrm release for an umbrella project here. Following the example outlined in the repository, the main app for our case will be the User Store Application. Letâ€™s get started and try to build an exrm release:
Note: We are going to build our release in Dev environment, the only thing that should change for production is the configuration. Some of the options may already be switched off for the production release. See Phoenix Guides for how to build production exrm release for phoenix applications.
Update deps of umbrella to include exrm and run
mix deps.get to install them.
Run the mix release command. Letâ€™s try it with the dev environment for now.
Letâ€™s examine the output and keep on continuing:
In the end we can see:
Letâ€™s try accessing it. Running with no args gives us the output:
We need to start the application to access the user_app and nectar, so letâ€™s do that. We are using foreground to see the console output, it can also be started to run as a background service. Doing that:
and we see
It seems to be unable to start the endpoint because the code reloader is missing. We can add it to the applications, but since it has no reason for belonging in the release, we will comment out the config for now in dev.exs and set code_reload: false in config.exs, doing that and building a new release.
It is working. Now to try accessing the server, it fails with connection refused, the server is not starting automatically.
Going over the phoenix endpoint configuration, we need to set server: true in endpoint configuration which is done automatically when running mix phoenix.server, doing that and rebuilding the release.
Itâ€™s alive! But we are getting 500 error. Hopping over to the logs(remember we are running it in the foreground mode)
It fails because guardian is not loaded. This was one of the missing dependencies which were not included in running applications. There were four of them:
Since we have already tackled the last one, letâ€™s add the first three in the application list in nectar.
And trying again:
Success. Similarly, we can copy over the config for production environment when building our exrm release. Now we can deploy the user app as the main application, See phoenix guides for details on how to configure and build exrm releases for production.
Running Migrations for an Exrm Release
You can always run
mix release.clean -- implode to clean up your workspace.
Our aim with these posts is to start a dialog with the Elixir community on validity and technical soundness of our approach. We would really appreciate your feedback and reviews, and any ideas/suggestions/pull requests for improvements to our current implementation or entirely different and better way to do things to achieve the goals we have set out for NectarCommerce.
Enjoy the Elixir potion !!