Packages
Mix task to create a docker image of your application release. Installation: `mix archive.install hex edib` More detailed information about release image building at: https://github.com/edib-tool/elixir-docker-image-builder
Current section
12 Versions
Jump to
Current section
12 Versions
Compare versions
13
files changed
+305
additions
-252
deletions
| @@ -1,5 +1,12 @@ | |
| 1 1 | # EDIB mix task |
| 2 2 | |
| 3 | + [](https://hex.pm/packages/edib) |
| 4 | + [](http://hexdocs.pm/edib/) |
| 5 | + [](https://github.com/edib-tool/mix-edib/blob/master/LICENSE) |
| 6 | + [](https://travis-ci.org/edib-tool/mix-edib) |
| 7 | + [](https://coveralls.io/r/edib-tool/mix-edib) |
| 8 | + [](http://inch-ci.org/github/edib-tool/mix-edib) |
| 9 | + |
| 3 10 | A mix task for [EDIB (elixir docker image builder)](https://github.com/edib-tool/elixir-docker-image-builder). |
| 4 11 | |
| 5 12 | <!-- |
| @@ -12,48 +19,33 @@ A mix task for [EDIB (elixir docker image builder)](https://github.com/edib-tool | |
| 12 19 | <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> |
| 13 20 | ## TOC |
| 14 21 | |
| 15 | - - [Install](#install) |
| 16 | - - [mix archive](#mix-archive) |
| 17 | - - [Or as project dependency](#or-as-project-dependency) |
| 22 | + - [Installation](#installation) |
| 18 23 | - [Usage](#usage) |
| 19 24 | - [Help](#help) |
| 20 25 | - [Options](#options) |
| 26 | + - [Name, prefix, tag](#name-prefix-tag) |
| 27 | + - [Silent mode (quiet mode)](#silent-mode-quiet-mode) |
| 28 | + - [Volume mappings](#volume-mappings) |
| 29 | + - [Docker related](#docker-related) |
| 21 30 | |
| 22 31 | <!-- END doctoc generated TOC please keep comment here to allow auto update --> |
| 23 32 | <!-- moduledoc: Mix.Tasks.Edib --> |
| 24 33 | EDIB creates a docker image of your application release. |
| 25 34 | |
| 26 | - ## Install |
| 27 | - |
| 28 | - ### mix archive |
| 35 | + ## Installation |
| 29 36 | |
| 30 37 | Just run this and confirm: |
| 31 38 | |
| 32 | - mix archive.install http://git.io/edib-0.5.1.ez |
| 39 | + mix archive.install http://git.io/edib-0.6.0.ez |
| 33 40 | |
| 34 | - And don't forget to add `exrm` to your project: |
| 41 | + Don't forget to add `exrm` to your project: |
| 35 42 | |
| 36 43 | defp deps do |
| 37 44 | [ |
| 38 | - {:exrm, "~> 0.19"} |
| 45 | + {:exrm, "~> 1.0"}, |
| 39 46 | ] |
| 40 47 | end |
| 41 48 | |
| 42 | - ### Or as project dependency |
| 43 | - |
| 44 | - In mix.exs: |
| 45 | - |
| 46 | - defp deps do |
| 47 | - [ |
| 48 | - {:exrm, "~> 0.19"}, |
| 49 | - {:edib, "~> 0.5"} |
| 50 | - ] |
| 51 | - end |
| 52 | - |
| 53 | - Then run: |
| 54 | - |
| 55 | - mix deps.get edib && mix deps.compile edib |
| 56 | - |
| 57 49 | ## Usage |
| 58 50 | |
| 59 51 | mix edib |
| @@ -64,52 +56,69 @@ Then run: | |
| 64 56 | |
| 65 57 | ## Options |
| 66 58 | |
| 67 | - # Override the (repository) name of the docker image |
| 59 | + ### Name, prefix, tag |
| 60 | + |
| 61 | + Override the (repository) name of the docker image |
| 62 | + |
| 68 63 | mix edib --name <NAME> |
| 69 64 | mix edib -n <NAME> |
| 70 65 | |
| 71 | - # Set only a specific prefix for the docker image name (default: local) |
| 66 | + Set only a specific prefix for the docker image name (default: local) |
| 67 | + |
| 72 68 | mix edib --prefix <PREFIX> |
| 73 69 | mix edib -p <PREFIX> |
| 74 70 | |
| 75 | - # Set a specific tag for the docker image |
| 71 | + Set a specific tag for the docker image |
| 72 | + |
| 76 73 | mix edib --tag <TAG> |
| 77 74 | mix edib -t <TAG> |
| 78 75 | |
| 76 | + If `--name` and `--prefix` are given, the name option takes precedence |
| 77 | + (prefix will be ignored). |
| 78 | + |
| 79 | + ### Silent mode (quiet mode) |
| 80 | + |
| 79 81 | # Silence build output of EDIB (will be logged to `.edib.log` instead) |
| 80 82 | mix edib --silent |
| 81 83 | mix edib -s |
| 82 84 | |
| 83 | - If `--name` and `--prefix` are given, the name option takes precedence |
| 84 | - (prefix will be ignored). |
| 85 | + ### Volume mappings |
| 86 | + |
| 87 | + Map additional volumes for use while building the release |
| 85 88 | |
| 86 | - # Map additional volumes for use while building the release |
| 87 89 | mix edib --mapping <FROM>:<TO>[:<OPTION>] |
| 88 90 | mix edib -m <FROM>:<TO>[:<OPTION>] |
| 89 91 | |
| 90 92 | For common cases there are some mapping shorthands: |
| 91 93 | |
| 92 | - # Include the host user's SSH keys for private GitHub repositories: |
| 94 | + Include the host user's SSH keys for private GitHub repositories |
| 95 | + |
| 93 96 | mix edib --ssh-keys |
| 94 97 | |
| 95 | - # Include host user's .hex/packages cache |
| 96 | - # |
| 97 | - # Can improve build times when the host's .hex cache is available for |
| 98 | - # every build run (tip for Travis CI: use their directory caching) |
| 98 | + Include host user's .hex/packages cache |
| 99 | + |
| 100 | + Can improve build times when the host's .hex cache is available for |
| 101 | + every build run (tip for Travis CI: use their directory caching) |
| 102 | + |
| 99 103 | mix edib --hex |
| 100 104 | |
| 101 | - # Include host user's .npm package cache |
| 102 | - # |
| 103 | - # Can improve build times when the host's .npm cache is available for |
| 104 | - # every build run (tip for Travis CI: use their directory caching) |
| 105 | + Include host user's .npm package cache |
| 106 | + |
| 107 | + Can improve build times when the host's .npm cache is available for |
| 108 | + every build run (tip for Travis CI: use their directory caching) |
| 109 | + |
| 105 110 | mix edib --npm |
| 106 111 | |
| 112 | + ### Docker related |
| 113 | + |
| 107 114 | Docker flags (mostly for debug purposes): |
| 108 115 | |
| 109 | - # Run the build step privileged |
| 116 | + Run the build step privileged |
| 117 | + |
| 110 118 | mix edib --privileged |
| 111 119 | |
| 112 | - # Do not remove intermediate containers on build runs |
| 120 | + Do not remove intermediate containers on build runs |
| 121 | + |
| 113 122 | mix edib --no-rm |
| 114 123 | |
| 115 124 | <!-- endmoduledoc: Mix.Tasks.Edib --> |
| @@ -2,7 +2,7 @@ | |
| 2 2 | {<<"build_tools">>,[<<"mix">>]}. |
| 3 3 | {<<"description">>, |
| 4 4 | <<"Mix task to create a docker image of your application release.\n\nMore detailed information about release image building at:\n\nhttps://github.com/edib-tool/elixir-docker-image-builder">>}. |
| 5 | - {<<"elixir">>,<<"~> 1.0">>}. |
| 5 | + {<<"elixir">>,<<"~> 1.2">>}. |
| 6 6 | {<<"files">>, |
| 7 7 | [<<"lib/edib/build_config/artifact.ex">>, |
| 8 8 | <<"lib/edib/build_config/artifact/builder.ex">>, |
| @@ -28,4 +28,4 @@ | |
| 28 28 | {<<"maintainers">>,[<<"Christoph Grabo">>]}. |
| 29 29 | {<<"name">>,<<"edib">>}. |
| 30 30 | {<<"requirements">>,[]}. |
| 31 | - {<<"version">>,<<"0.5.1">>}. |
| 31 | + {<<"version">>,<<"0.6.0">>}. |
| @@ -11,6 +11,7 @@ defmodule EDIB.BuildConfig.Artifact do | |
| 11 11 | |
| 12 12 | def from_cli_options(options), |
| 13 13 | do: EDIB.BuildConfig.Artifact.Parser.from_cli_options(options) |
| 14 | + |
| 14 15 | def to_command(artifact_config), |
| 15 16 | do: EDIB.BuildConfig.Artifact.Builder.build(artifact_config) |
| 16 17 | end |
| @@ -2,11 +2,12 @@ defmodule EDIB.BuildConfig.Artifact.Builder do | |
| 2 2 | @moduledoc false |
| 3 3 | |
| 4 4 | alias EDIB.Defaults |
| 5 | - alias EDIB.BuildConfig.Artifact.ImageSettings |
| 6 | - alias EDIB.BuildConfig.Artifact.Volumes |
| 5 | + alias EDIB.BuildConfig.Artifact |
| 6 | + alias EDIB.BuildConfig.Artifact.{ImageSettings, Volumes} |
| 7 7 | |
| 8 8 | def build(artifact_config) do |
| 9 | - {:ok, artifact_config, []} |
| 9 | + artifact_config |
| 10 | + |> maybe_artifact_config |
| 10 11 | |> set_edib_tool |
| 11 12 | |> set_settings |
| 12 13 | |> set_volumes |
| @@ -18,6 +19,11 @@ defmodule EDIB.BuildConfig.Artifact.Builder do | |
| 18 19 | |
| 19 20 | ### Internals |
| 20 21 | |
| 22 | + defp maybe_artifact_config(%Artifact{} = artifact_config), |
| 23 | + do: {:ok, artifact_config, []} |
| 24 | + defp maybe_artifact_config(_), |
| 25 | + do: {:error, "Not a valid artifact config given"} |
| 26 | + |
| 21 27 | defp set_edib_tool({:ok, config, command_list}) do |
| 22 28 | {:ok, config, [Defaults.edib_tool | command_list]} |
| 23 29 | end |
| @@ -20,36 +20,40 @@ defmodule EDIB.BuildConfig.Artifact.ImageSettings do | |
| 20 20 | ~s(-e "#{setting}") |
| 21 21 | end |
| 22 22 | |
| 23 | - defp package_name({options, vars}) do |
| 24 | - options |> Dict.get(:name) |> maybe_package_name(options, vars) |
| 25 | - end |
| 23 | + defp package_name({%{name: name} = options, vars}), |
| 24 | + do: maybe_package_name(name, options, vars) |
| 25 | + defp package_name({options, vars}), |
| 26 | + do: {options, vars} |
| 26 27 | |
| 27 28 | defp maybe_package_name(nil, options, vars), |
| 28 29 | do: {options, vars} |
| 29 30 | defp maybe_package_name(name, options, vars), |
| 30 31 | do: {options, ["RELEASE_NAME=#{name}" | vars]} |
| 31 32 | |
| 32 | - defp package_tag({options, vars}) do |
| 33 | - options |> Dict.get(:tag) |> maybe_package_tag(options, vars) |
| 34 | - end |
| 33 | + defp package_tag({%{tag: tag} = options, vars}), |
| 34 | + do: maybe_package_tag(tag, options, vars) |
| 35 | + defp package_tag({options, vars}), |
| 36 | + do: {options, vars} |
| 35 37 | |
| 36 38 | defp maybe_package_tag(nil, options, vars), |
| 37 39 | do: {options, vars} |
| 38 40 | defp maybe_package_tag(tag, options, vars), |
| 39 41 | do: {options, ["RELEASE_TAG=#{tag}" | vars]} |
| 40 42 | |
| 41 | - defp package_prefix({options, vars}) do |
| 42 | - options |> Dict.get(:prefix) |> maybe_package_prefix(options, vars) |
| 43 | - end |
| 43 | + defp package_prefix({%{prefix: prefix} = options, vars}), |
| 44 | + do: maybe_package_prefix(prefix, options, vars) |
| 45 | + defp package_prefix({options, vars}), |
| 46 | + do: {options, vars} |
| 44 47 | |
| 45 48 | defp maybe_package_prefix(nil, options, vars), |
| 46 49 | do: {options, vars} |
| 47 50 | defp maybe_package_prefix(prefix, options, vars), |
| 48 51 | do: {options, ["RELEASE_PREFIX=#{prefix}" | vars]} |
| 49 52 | |
| 50 | - defp with_test_run({options, vars}) do |
| 51 | - options |> Dict.get(:test, false) |> maybe_with_test_run(options, vars) |
| 52 | - end |
| 53 | + defp with_test_run({%{test: test} = options, vars}), |
| 54 | + do: maybe_with_test_run(test, options, vars) |
| 55 | + defp with_test_run({options, vars}), |
| 56 | + do: {options, vars} |
| 53 57 | |
| 54 58 | defp maybe_with_test_run(true, options, vars), |
| 55 59 | do: {options, ["TEST=true" | vars]} |
Loading more files…