Add a new app to the umbrella

This is a guide how to add a new umbrella app in the VaaS umbrella project. We will mostly use this guide for two purposes, creating a new umbrella app or porting/refactoring VaasWeb into a new umbrella app. Let's start!

First you need to navigate to the correct folder in the umbrella app, which is vaas-elixir/apps and you can run the following command (remove flags if you need to) to create a new umbrella app:

mix phx.new.web vaas_feed --no-ecto --no-html --no-webpack

Set different port

The next step is to change the port, so we don't run into errors where they complain about occupied ports (the infamous address already used, aka :eaddrinuse). We have the convention where we add 1 to the highest previous assigned port number. For example VaasWeb uses port 4000, VaasFeed uses port 4001, so the next port would be 4002 if we create a new app (and no other apps are using 4002 yet).

We can find the configuration options in elixir-vaas/apps/YOUR_NEW_APP/config/dev.exs, where we can set the port number. Note that we don't need to concern ourselves about port config in elixir-vaas/apps/YOUR_NEW_APP/config/prod.exs.

Create Aliases

When this is done, you can spin up all the apps from the root with mix phoenix.server, but what if you only want to run or test your new app? We can do that with aliases, which you can find in mix.exs located at the root of the umbrella project. Add the dev and test specific aliases for your app so you can run it independently:

defmodule Vaas.Mixfile do
  @moduledoc false
  use Mix.Project

  # Removed other config and functions for brevity

  defp aliases do
    [
      "test.core": ["cmd --app vaas_core mix test"],
      "test.feed": ["cmd --app vaas_feed mix test"],
      "test.web": ["cmd --app vaas_web mix test"],
      "run.core": ["cmd --app vaas_core mix phx.server"],
      "run.feed": ["cmd --app vaas_feed mix phx.server"],
      "run.web": ["cmd --app vaas_web mix phx.server"],
    ]
  end
end

Heroku Setup

First you need to create a new application for your umbrella app. Secondly you need to attach the Postgres add-on if you intend to use VaasCore. Use the heroku addons:attach command to attach the Postgres add-on to your new app. See the example we used to connect the Postgres add-on to mychannels-vaas-dfp-preview:

heroku addons:attach postgresql-rectangular-56433 --as=HEROKU_POSTGRESQL_GREEN -a mychannels-vaas-dfp-preview

Set Config Variables

This is an easy step to do and add the necessary config variables needed to run the umbrella project with your app. Best approach is to copy the config variables of a similar application, but don't forget to set the unique APP_NAME to the correct value.

Add Build Packs

Add the following two buildpacks:

  • https://github.com/HashNuke/heroku-buildpack-elixir.git
  • https://github.com/gjaldon/heroku-buildpack-phoenix-static.git

Add domain/update DNS settings

Last Updated: 2/28/2019, 3:20:56 PM