|
| 1 | +.. _`quick start umbrella`: |
| 2 | + |
| 3 | +Getting Started Umbrella Guide |
| 4 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 5 | + |
| 6 | +This guide is a follow up of the :ref:`quick start` guide. If you haven't applied it until the end of the :bash:`Provision a Database` part, you should do so and come back after. |
| 7 | + |
| 8 | +Git Submodules |
| 9 | +-------------- |
| 10 | + |
| 11 | +If you organised your code base on `Git submodules`_, you may have some troubles cloning your repository. |
| 12 | + |
| 13 | +Unfortunately, you won't be able to do it in a secure way. This is due to two reasons |
| 14 | + |
| 15 | +1) There is no hook called before the submodules clone command |
| 16 | + |
| 17 | +2) You can't use env variable nor can you import a SSH key |
| 18 | + |
| 19 | +Therefore, you will have to go to your :bash:`.gitmodules` file, and add your username and password before each url. As it isn't secured, it is strongly advised to create another use and set only the read rights. |
| 20 | + |
| 21 | +.. code-blokc:: git |
| 22 | + |
| 23 | + [submodule "my_app"] |
| 24 | + path = apps/my_app |
| 25 | + url = https://username:password@github.com/my_project/my_repo |
| 26 | + |
| 27 | +By doing so, you may need to update the pushurl of the submodule repository to be equal to the base url: |
| 28 | + |
| 29 | +.. code-block:: bash |
| 30 | +
|
| 31 | + git config remote.origin.pushurl https://github.com/my_project/my_repo |
| 32 | +
|
| 33 | +.. Note:: If you find a solution which doesn't expose the password, please let us know, so we can provide a more secured guide to everyone. |
| 34 | + |
| 35 | +Umbrella Base Setup |
| 36 | +---------- |
| 37 | + |
| 38 | +.. Important:: Be certain to follow the part first paragraph of the :ref:`umbrella`. This should be enough if you only have one Phoenix. |
| 39 | + |
| 40 | +Multiple Phoenix App |
| 41 | +-------------------- |
| 42 | + |
| 43 | +Once you finished to setup `phoenix_static_buildpack.config` as describe in the previous part, there is more to be done. |
| 44 | + |
| 45 | +First, create a :bash:`.buildpacks` file and make sure you have something like the following. |
| 46 | + |
| 47 | +.. code-block:: bash |
| 48 | +
|
| 49 | + https://github.com/HashNuke/heroku-buildpack-elixir |
| 50 | + https://github.com/gjaldon/heroku-buildpack-phoenix-static |
| 51 | + https://github.com/gigalixir/gigalixir-buildpack-mix.git |
| 52 | +
|
| 53 | +Depending of your deployment preference, this file will be modified later on the :ref:`modifying existing app` chapter. |
| 54 | + |
| 55 | +Once the buildpack is created, you will have to add another file, called :bash:`compile`, which contains bash commands. This file is called by the heroku-buildpack-phoenix-static, and will overwrite the existing one, which focus on a single phoenix app. |
| 56 | + |
| 57 | +.. code-block:: bash |
| 58 | +
|
| 59 | + # app_root/compile |
| 60 | +
|
| 61 | + # Build first phoenix app |
| 62 | + # Set variables |
| 63 | + phoenix_dir=$build_dir/apps/my_app |
| 64 | + assets_dir=$build_dir/apps/my_app/assets |
| 65 | + info "Phoenix dir ${phoenix_dir}" |
| 66 | + |
| 67 | + # Go to the asset dir |
| 68 | + cd $assets_dir |
| 69 | + info "Caching node modules" |
| 70 | +
|
| 71 | + cp -R node_modules $cache_dir |
| 72 | + PATH=$assets_dir/node_modules/.bin:$PATH |
| 73 | + install_bower_deps |
| 74 | + |
| 75 | + npm run deploy |
| 76 | + export PATH=$(p=$(echo $PATH | tr ":" "\n" | grep -v "/$assets_dir/node_modules/.bin" | tr "\n" ":"); echo ${p%:}) |
| 77 | + rm -rf $assets_dir/node_modules |
| 78 | + |
| 79 | + cd $phoenix_dir |
| 80 | + mix "phx.digest" |
| 81 | + mix "phx.digest.clean" |
| 82 | + |
| 83 | + # Build second phoenix app |
| 84 | + # Set variables |
| 85 | + phoenix_dir=$build_dir/apps/another_app |
| 86 | + assets_dir=$build_dir/apps/another_app/assets |
| 87 | + info "Phoenix dir ${phoenix_dir}" |
| 88 | + |
| 89 | + # Get node deps |
| 90 | + install_and_cache_deps |
| 91 | + npm run deploy |
| 92 | + export PATH=$(p=$(echo $PATH | tr ":" "\n" | grep -v "/$assets_dir/node_modules/.bin" | tr "\n" ":"); echo ${p%:}) |
| 93 | + rm -rf $assets_dir/node_modules |
| 94 | + |
| 95 | + cd $phoenix_dir |
| 96 | + mix "phx.digest" |
| 97 | + mix "phx.digest.clean" |
| 98 | +
|
| 99 | +As you can see, the first and the second app don't use the same commands. It is because the first app should be the one pointed by :bash:`phoenix_relative_path` in the :bash:`phoenix_static_buildpack.config` file. |
| 100 | + |
| 101 | +As it it point by this configuration, some action will be already done, such as creating the node_modules folder. |
| 102 | + |
| 103 | +.. _Git submodules: https://git-scm.com/book/en/v2/Git-Tools-Submodules |
0 commit comments