Packages & Dependencies

What Packages are Available for My Gigalixir App?

Gigalixir’s stacks are based on Heroku’s stacks, so anything you find here, you can find on Gigalixir. https://devcenter.heroku.com/articles/stack-packages#installed-ubuntu-packages

To find what stack you are on, run gigalixir apps:info or gigalixir ps. If you are on gigalixir-18, check the heroku-18 column. This is the same for all other stacks.

For information on available stacks, lifecycle phases, and how to upgrade, see the Stacks documentation.

You can also explore and verify by SSH’ing into your container. For example:

gigalixir ps:ssh
convert --help

How Do I Install System Packages with the Apt Buildpack?

The most common way to install system-level packages (such as ffmpeg, libvips, wkhtmltopdf, etc.) is with the Heroku Apt Buildpack.

This works with both Elixir Releases and Mix deployment modes.

Step 1: Create an Aptfile

Create a file called Aptfile in the root of your project. List the Ubuntu packages you need, one per line. For example, to install ffmpeg:

ffmpeg

You can list multiple packages:

ffmpeg
libvips42
imagemagick

The available packages depend on which stack your app is running on. Gigalixir stacks are based on Ubuntu, so any package available in your stack’s Ubuntu version can be listed here.

Step 2: Add the Apt Buildpack to .buildpacks

Create or update the .buildpacks file in the root of your project. The apt buildpack must be listed before the other buildpacks.

For Elixir Releases:

https://github.com/heroku/heroku-buildpack-apt
https://github.com/gigalixir/gigalixir-buildpack-elixir
https://github.com/gigalixir/gigalixir-buildpack-phoenix-static
https://github.com/gigalixir/gigalixir-buildpack-releases

For Mix mode:

https://github.com/heroku/heroku-buildpack-apt
https://github.com/gigalixir/gigalixir-buildpack-elixir
https://github.com/gigalixir/gigalixir-buildpack-phoenix-static
https://github.com/gigalixir/gigalixir-buildpack-mix

Step 3: Deploy

That’s it! Deploy your app as usual with git push gigalixir and the packages will be installed during the build.

The releases buildpack automatically detects the apt buildpack and includes the installed packages and their library paths in your release. No extra configuration is needed.

Note
Apt-installed packages increase the size of your deployment slug. If you are approaching the 512MB slug size limit, consider whether all listed packages are necessary.

How Do I Install Other Extra Binaries?

You can use any Heroku-compatible buildpack to install additional binaries. Add the buildpack to your .buildpacks file before the Gigalixir buildpacks.

For example, if you need Rust installed, your .buildpacks file might look like:

https://github.com/emk/heroku-buildpack-rust
https://github.com/gigalixir/gigalixir-buildpack-elixir
https://github.com/gigalixir/gigalixir-buildpack-phoenix-static
https://github.com/gigalixir/gigalixir-buildpack-mix

For Rust specifically, also be sure to run echo "RUST_SKIP_BUILD=1" > RustConfig since you just need the Rust binaries, and don’t want to build a Rust project.

How Do I Use a Private Git Dependency?

If you want to use a private git repository as a dependency in mix.exs, our recommended approach is to use the netrc buildpack found at https://github.com/timshadel/heroku-buildpack-github-netrc

To use the buildpack, insert it in your .buildpacks file above the Elixir and Phoenix buildpacks. For example, if you are using Elixir Releases, your .buildpacks file will look like:

https://github.com/timshadel/heroku-buildpack-github-netrc
https://github.com/gigalixir/gigalixir-buildpack-elixir
https://github.com/gigalixir/gigalixir-buildpack-phoenix-static
https://github.com/gigalixir/gigalixir-buildpack-releases

Next, create a personal access token by following https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/

Just make sure you give the token "repo" access so that it can access your private repository.

Add your personal access token as a config var by running:

gigalixir config:set -a $APP_NAME GITHUB_AUTH_TOKEN="$GITHUB_TOKEN"

The last step is to add the dependency to your mix.exs file. Add it as you would any other git dependency, but be sure you use the HTTPS url and not the SSH url. For example:

{:foo, git: "https://github.com/jesseshieh/foo.git", override: true}

That should be it.

Alternatively, you could also put your Github username and personal access token directly into the git url, but it’s generally not a good idea to check in secrets to source control.

You could use System.get_env interpolated inside the git url, but then you run the risk of the secrets getting saved to mix.lock.

What’s Next?