gjaldon/heroku-buildpack-phoenix-static

Support for multiple phoenix applications under an Umbrella App

Opened this issue · 5 comments

So, I run multiple phoenix applications and each have their own assets.

To get around cd'ing into all the different applications and running the npm deploy script in each..

I just have a custom compile script that looks like this:

cd $build_dir
mix cmd "npm install || true"
mix cmd "npm run deploy || true"
mix phoenix.digest

You can run mix cmd which will run the command in each of all the child applications.

mix phoenix.digest also does run in all of the phoenix applications as well.

I feel like you can use these same commands in a single application, and even in umbrella applications.

We ended up using something like this where we had multiple Phoenix apps with assets but with a router which didn't have any assets. The router failed to mix ph[oeni]x when priv/static did not exist so we ended up with this solution.

This approach can support Phoenix 1.2 or 1.3 apps. Use yarn by ensuring there is a yarn.lock file in each assets directory.

cd $build_dir

# Phoenix 1.2
mix cmd --app app_a "(yarn install && yarn run deploy) || true"
mix cmd --app app_a mix phoenix.digest

# Phoenix 1.3
mix cmd --app app_b "(cd assets && yarn install && yarn run deploy) || true"
mix cmd --app app_b mix phx.digest

/cc @JonRowe

Since this seems to be the simplest way to achieve this, it'd be nice to add some instructions to the README

What is the status on this ?
I would be willing to make this feature happen but I'm not sure where I should start. Any idea ?

A couple of things need to happen,phx.digest needs to not error in an umbrella context if theres no assets folder, a task needs to be able to exist for installing assets that runs across the umbrella.

Specifically the install_and_cache_deps() in build.sh also needs to either support multiple assets directories or have a means to be easily disabled:

install_and_cache_deps() {