Building an exrm release including NectarCommerce

The post belongs to NectarCommerce and Extension Framework Awareness Series

  1. NectarCommerce Vision
  2. Extension Framework Game Plan
  3. Introduction to Metaprogramming
  4. Ecto Model Schema Extension
  5. Ecto Model Support Functions Extension
  6. Phoenix Router Extension
  7. Phoenix View Extension
  8. Running Multiple Elixir Apps Together
  9. Extension Approach Explained
  10. Learning from failures: First Experiment at NectarCommerce Extension Approach
  11. Developing NectarCommerce Extensions
  12. 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.

Step 1: Update deps of umbrella to include exrm and run mix deps.get to install them.

Step 2: 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 be run as a background service. See here

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:

  1. guardian
  2. arc
  3. comeonin
  4. phoenix_live_reload

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.

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 !!