philss / rustler_precompiled

Use precompiled NIFs from trusted sources in your Elixir code
181 stars 27 forks source link

Using precompiled on private project without publishing to hex #26

Closed 123mitnik closed 2 years ago

123mitnik commented 2 years ago

I'm sorry if this is already somewhere covered, but I can't find how we can use the lib for downloading the binaries from an external source without publishing to hex.

What would be the workflow if:

Thank You !

philss commented 2 years ago

hey @123mitnik :wave:

you have a private project and would like to deploy to prod without publishing to hex

I had to do this while testing some of the release process. What I did was really just use GitHub Releases to create a new release and point to the repository at my mix.exs. I think this is the way to go, using tags to ensure that you are using an specific version.

can you include the pre-build binaries inside the project itself - i.e. basically skipping the rust build process - only the elixir project compilation to be performed (inside the code - i see there is an option to read from cache - but is there an option to explicitly load local pre-build without package publishing or uploading to external servers - load from local path)?

There is no explicit option for that, but you could "force" the cache dir to be something known by setting the MIX_XDG env dir (see https://hexdocs.pm/mix/1.13.4/Mix.html#module-environment-variables) to "true" and setting the XDG_CACHE_HOME to a path you know. And then you can use the mix rustler_precompiled.download --all to download all the artifacts to that dir. If you want, you can distribute everything together, because the cache dir will have priority over downloading from the internet. But remember that you must set the MIX_XDG to "true" and XDG_CACHE_HOME to the same path that you downloaded the artifacts before. Note that this may affect the cache of other things used by Mix.

philss commented 2 years ago

Another important thing that I remembered: you need to add the metadata file to version control.

123mitnik commented 2 years ago

Thank You @philss Philip ! Much appreciated