#
View Source Mix.Release (Mix v1.15.7)

Defines the release structure and convenience for assembling releases.

# Summary

## Types

application()
mode()
t()

## Functions

%Mix.Release{}

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

copy_app(release, app)

Copies the given application specification into the release.

copy_ebin(release, source, target)

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

copy_erts(release)

Copies ERTS if the release is configured to do so.

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

Makes boot scripts.

make_cookie(release, path)

Copies the cookie to the given path.

make_start_erl(release, path)

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

make_sys_config(release, sys_config, config_provider_path)

Makes the `sys.config` structure.

rel_templates_path(release, path)

Finds a template path for the release.

strip_beam(binary, options \\ [])

Strips a beam file for a release.

# Types

Link to this type

# application()

View Source

    @type application() :: atom()

Link to this type

# mode()

View Source

    @type mode() :: :permanent | :transient | :temporary | :load | :none

Link to this type

# t()

View Source

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

# Functions

Link to this function

# %Mix.Release{}

View Source (struct)

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
- `: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.

Link to this function

# copy_app(release, app)

View Source

    @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`.

Link to this function

# copy_erts(release)

View Source

    @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`.

Link to this function

# rel_templates_path(release, path)

View Source

Finds a template path for the release.

Link to this function

# strip_beam(binary, options \\ [])

View Source

    @spec strip_beam(
      binary(),
      keyword()
    ) :: {:ok, binary()} | {:error, :beam_lib, term()}

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.