Marea.Plugins.Docker behaviour (marea v0.0.1-rc.1)

Copy Markdown View Source

Docker subcommands and schema: build docker, build show-dockerfile, build show-docker-versions.

Optional. Enable by listing Marea.Plugins.Docker under plugins: in marea.yaml. Other plugins that build container images (notably Marea.Plugins.Helm) declare Marea.Plugins.Docker in their plugin_deps.

Schema contributions:

  • Marea.Plugins.Base.marea_release_types/1 adds :elixir and :dockerfile_dir to the release type: enum.
  • docker: block on every deploy and every release (Dockerfile template, Elixir/OTP versions, build args, platform, etc).
  • validate_release/2 refinement enforcing that docker keys match the release type:.

See the Docker Plugin guide.

Summary

Callbacks

Enrich the EEx assigns passed to the generated Dockerfile.

Functions

Runs docker build for the release, tagging the result as <release>:<git_vsn> and <release>:latest. Public so other plugins (e.g. Marea.Plugins.Helm) can reuse the image-build step.

Resolves the per-release Docker config: defaults merged with the deploy's docker: block, the release's docker: block, and any CLI overrides (--template, --platform, --elixir-vsn). Sets :type from the release's build type and lazily detects Elixir version when not provided.

Detects the local Elixir version (System.version/0 of the Elixir used for build). Used as the default for docker.elixir_vsn.

Renders the Dockerfile template named name with assigns. Looks under <marea_dir>/templates/ first, then falls back to the built-in docker/ templates in Marea.Templates.

For :elixir releases, copies project sources into <state_dir>/build, rsyncs path-dependencies, and writes a generated Dockerfile from the configured template. No-op for :dockerfile_dir releases.

Callbacks

marea_dockerfile_assigns(assigns, config)

@callback marea_dockerfile_assigns(assigns :: keyword(), config :: Marea.Config.t()) ::
  {:cont, [keyword() | Marea.Config.t()]} | term()

Enrich the EEx assigns passed to the generated Dockerfile.

Invoked while rendering the Dockerfile for :elixir-type releases. Receives the base assigns (currently :elixir_vsn, :rebuild_deps, :path_deps, plus the extension points :extra_stages and :extra_app_steps) and the active Marea.Config.t/0. Plugins typically append rendered Dockerfile fragments to :extra_stages (additional FROM … AS … stages inserted between the build and app stages) and/or :extra_app_steps (extra COPY/RUN lines inside the final app stage). Return {:cont, [assigns, config]} to pass control on.

See Marea.Plugins.Docker.Python for an example.

Functions

build_image(config, docker)

@spec build_image(Marea.Config.t(), map()) :: Marea.Config.t()

Runs docker build for the release, tagging the result as <release>:<git_vsn> and <release>:latest. Public so other plugins (e.g. Marea.Plugins.Helm) can reuse the image-build step.

config(config)

@spec config(Marea.Config.t()) :: map()

Resolves the per-release Docker config: defaults merged with the deploy's docker: block, the release's docker: block, and any CLI overrides (--template, --platform, --elixir-vsn). Sets :type from the release's build type and lazily detects Elixir version when not provided.

Public so plugins that compose docker builds (e.g. Marea.Plugins.Helm for build helm) can reuse the same resolution.

elixir_vsn(config)

@spec elixir_vsn(Marea.Config.t()) :: String.t()

Detects the local Elixir version (System.version/0 of the Elixir used for build). Used as the default for docker.elixir_vsn.

expand_template(config, name, assigns)

@spec expand_template(Marea.Config.t(), String.t(), keyword()) ::
  String.t() | no_return()

Renders the Dockerfile template named name with assigns. Looks under <marea_dir>/templates/ first, then falls back to the built-in docker/ templates in Marea.Templates.

make_env(config, docker)

@spec make_env(Marea.Config.t(), map()) :: Marea.Config.t()

For :elixir releases, copies project sources into <state_dir>/build, rsyncs path-dependencies, and writes a generated Dockerfile from the configured template. No-op for :dockerfile_dir releases.

Public so other plugins (e.g. Marea.Plugins.Helm) can reuse the build-context staging.