View Source Mix.Release (Mix v1.10.4)

Defines the release structure and convenience for assembling releases.

Link to this section Summary

Functions

The Mix.Release struct has the following read-only fields

Copies the given application specification into the release.

Copies the ebin directory at source to target respecting release options such a :strip_beams.

Copies ERTS if the release is configured to do so.

Copies the cookie to the given path.

Makes the start_erl.data file with the ERTS version and release versions.

Strips a beam file for a release.

Link to this section Types

@type application() :: atom()
@type mode() :: :permanent | :transient | :temporary | :load | :none
@type t() :: %{
  name: atom(),
  version: String.t(),
  path: String.t(),
  version_path: String.t() | {:from_app, application()},
  applications: %{required(application()) => keyword()},
  boot_scripts: %{required(atom()) => [{application(), mode()}]},
  erts_version: charlist(),
  erts_source: charlist() | nil,
  config_providers: [{module(), term()}],
  options: keyword(),
  steps: [(t() -> t()) | :assemble, ...]
}

Link to this section Functions

The Mix.Release struct has the following read-only fields:

  • :name - the name of the release as an atom
  • :version - the version of the release as a string or {:from_app, app_name}
  • :path - the path to the release root
  • :version_path - the path to the release version inside the release
  • :applications - a map of application with their definitions
  • :erts_source - the erts source as a charlist (or nil)
  • :erts_version - the erts version as a charlist

The following fields may be modified as long as they keep their defined types:

  • :boot_scripts - a map of boot scripts with the boot script name as key and a keyword list with all applications that are part of it and their modes as value
  • :config_providers - a list of {config_provider, term} tuples where the first element is a module that implements the Config.Provider behaviour and term is the value given to it on Config.Provider.init/1
  • :options - a keyword list with all other user supplied release options
  • :overlays - a list of extra files added to the release. If you have a custom step adding extra files to a release, you can add these files to the :overlays field so they are also considered on further commands, such as tar/zip. Each entry in overlays is the relative path to the release root of each file
  • :steps - a list of functions that receive the release and returns a release. Must also contain the atom :assemble which is the internal assembling step. May also contain the atom :tar to create a tarball of the release.
@spec copy_app(t(), application()) :: boolean()

Copies the given application specification into the release.

It assumes the application exists in the release.

Link to this function

copy_ebin(release, source, target)

View Source
@spec copy_ebin(t(), Path.t(), Path.t()) :: boolean()

Copies the ebin directory at source to target respecting release options such a :strip_beams.

@spec copy_erts(t()) :: boolean()

Copies ERTS if the release is configured to do so.

Returns true if the release was copied, false otherwise.

Link to this function

make_boot_script(release, path, modes, prepend_paths \\ [])

View Source
@spec make_boot_script(t(), Path.t(), [{application(), mode()}], [String.t()]) ::
  :ok | {:error, String.t()}

Makes boot scripts.

It receives a path to the boot file, without extension, such as releases/0.1.0/start and this command will write start.rel, start.boot, and start.script to the given path, returning {:ok, rel_path} or {:error, message}.

The boot script uses the RELEASE_LIB environment variable, which must be accordingly set with --boot-var and point to the release lib dir.

Link to this function

make_cookie(release, path)

View Source
@spec make_cookie(t(), Path.t()) :: :ok

Copies the cookie to the given path.

If a cookie option was given, we compare it with the contents of the file (if any), and ask the user if they want to override.

If there is no option, we generate a random one the first time.

Link to this function

make_start_erl(release, path)

View Source
@spec make_start_erl(t(), Path.t()) :: :ok

Makes the start_erl.data file with the ERTS version and release versions.

Link to this function

make_sys_config(release, sys_config, config_provider_path)

View Source
@spec make_sys_config(t(), keyword(), Config.Provider.config_path()) ::
  :ok | {:error, String.t()}

Makes the sys.config structure.

If there are config providers, then a value is injected into the :elixir application configuration in sys_config to be read during boot and trigger the providers.

It uses the following release options to customize its behaviour:

  • :reboot_system_after_config
  • :start_distribution_during_config
  • :prune_runtime_sys_config_after_boot

In case there are no config providers, it doesn't change sys_config.

@spec strip_beam(binary()) ::
  {:ok, binary()} | {:error, :beam_lib, :beam_lib.chnk_rsn()}

Strips a beam file for a release.

This keeps only significant chunks necessary for the VM operation, discarding documentation, debug info, compile information and others.

The exact chunks that are kept are not documented and may change in future versions.