Packages
Library for building docker images of Elixir projects. Supports a plugin system which can allows the generated Dockerfile to be extended at various points.
Current section
18 Versions
Jump to
Current section
18 Versions
Compare versions
8
files changed
+67
additions
-6
deletions
| @@ -1,5 +1,11 @@ | |
| 1 1 | # Changelog |
| 2 2 | |
| 3 | + ## v0.6.0 |
| 4 | + |
| 5 | + ### Enhancements |
| 6 | + * Support custom plugins in own project |
| 7 | + * Add `before_assets_compile` callback in Assets plugin |
| 8 | + |
| 3 9 | ## v0.5.1 |
| 4 10 | |
| 5 11 | ### Bug fixes |
| @@ -10,7 +10,7 @@ by adding `docker_build` to your list of dependencies in `mix.exs`: | |
| 10 10 | ```elixir |
| 11 11 | def deps do |
| 12 12 | [ |
| 13 | - {:docker_build, "~> 0.5.0", runtime: false, only: :dev} |
| 13 | + {:docker_build, "~> 0.6.0", runtime: false, only: :dev} |
| 14 14 | ] |
| 15 15 | end |
| 16 16 | ``` |
| @@ -75,6 +75,7 @@ The following additional config values are available: | |
| 75 75 | * `:umbrella_apps` - list of apps in an umbrella project. If not set then the project is |
| 76 76 | assumed to be a non-umbrella project. |
| 77 77 | * `:release_manager` - By default, the built-in release mechanism is used, however, if you wish to use distillery, set this to `:distillery` |
| 78 | + * `:plugin_paths` - list of path to source code for custom plugins in your project (see below). Defaults to `["docker_build/lib"]`. |
| 78 79 | |
| 79 80 | ### Using assets |
| 80 81 | |
| @@ -91,7 +92,7 @@ The default configuration is: | |
| 91 92 | If you use the `Webpack` plugin and don't need to change any `Assets` default, you don't |
| 92 93 | need to explicitly include it as the `Webpack` plugin will include it automatically. |
| 93 94 | |
| 94 | - ### Adding an ssh to the build stage |
| 95 | + ### Adding an ssh key to the build stage |
| 95 96 | |
| 96 97 | You can add this in `deploy/ssh_keys`. Add a public and private key, e.g. |
| 97 98 | `id_rsa` and `id_rsa.pub`. They will be copied to the `/root/.ssh` folder in the build |
| @@ -161,6 +162,12 @@ config :docker_build, DockerBuild.Build, | |
| 161 162 | |
| 162 163 | There are several plugins already included in the project. |
| 163 164 | |
| 165 | + ### Custom plugins |
| 166 | + |
| 167 | + You can also create your own custom plugin in your project. You should put the source code for this in |
| 168 | + `docker_build/lib` so it is outside the normal compile paths for Elixir and thefore not included in the build. You can change this |
| 169 | + using the `:plugin_paths` config key. |
| 170 | + |
| 164 171 | ## Troubleshooting |
| 165 172 | |
| 166 173 | ### Host key verification failed error |
| @@ -6,8 +6,9 @@ | |
| 6 6 | {<<"files">>, |
| 7 7 | [<<"lib">>,<<"lib/mix">>,<<"lib/mix/tasks">>,<<"lib/mix/tasks/build.ex">>, |
| 8 8 | <<"lib/docker_build">>,<<"lib/docker_build/docker_file_generator.ex">>, |
| 9 | - <<"lib/docker_build/docker_file.ex">>,<<"lib/docker_build/plugins.ex">>, |
| 10 | - <<"lib/docker_build/plugins">>,<<"lib/docker_build/plugins/webpack.ex">>, |
| 9 | + <<"lib/docker_build/code.ex">>,<<"lib/docker_build/docker_file.ex">>, |
| 10 | + <<"lib/docker_build/plugins.ex">>,<<"lib/docker_build/plugins">>, |
| 11 | + <<"lib/docker_build/plugins/webpack.ex">>, |
| 11 12 | <<"lib/docker_build/plugins/known_hosts.ex">>, |
| 12 13 | <<"lib/docker_build/plugins/assets_plugins.ex">>, |
| 13 14 | <<"lib/docker_build/plugins/elm.ex">>, |
| @@ -19,4 +20,4 @@ | |
| 19 20 | [{<<"GitHub">>,<<"https://github.com/chazsconi/elixir_docker_build">>}]}. |
| 20 21 | {<<"name">>,<<"docker_build">>}. |
| 21 22 | {<<"requirements">>,[]}. |
| 22 | - {<<"version">>,<<"0.5.1">>}. |
| 23 | + {<<"version">>,<<"0.6.0">>}. |
| @@ -0,0 +1,27 @@ | |
| 1 | + defmodule DockerBuild.Code do |
| 2 | + @moduledoc "Loads extra source code" |
| 3 | + def require_all(paths) when is_list(paths) do |
| 4 | + for path <- paths do |
| 5 | + for file <- list_all_files(path) do |
| 6 | + Code.require_file(file) |
| 7 | + end |
| 8 | + end |
| 9 | + end |
| 10 | + |
| 11 | + defp list_all_files(filepath) do |
| 12 | + expand(File.ls(filepath), filepath) |
| 13 | + end |
| 14 | + |
| 15 | + defp expand({:ok, files}, path) do |
| 16 | + files |
| 17 | + |> Enum.flat_map(&list_all_files("#{path}/#{&1}")) |
| 18 | + end |
| 19 | + |
| 20 | + defp expand({:error, _}, path) do |
| 21 | + if String.ends_with?(path, ".ex") do |
| 22 | + [path] |
| 23 | + else |
| 24 | + [] |
| 25 | + end |
| 26 | + end |
| 27 | + end |
| @@ -21,6 +21,11 @@ defmodule DockerBuild.Config do | |
| 21 21 | config |
| 22 22 | end |
| 23 23 | |
| 24 | + # Get exta code for plugins |
| 25 | + # This is so the code does not need to be in the normal code path of the project |
| 26 | + plugin_paths = Keyword.get(opts, :plugin_paths, ["docker_build/lib"]) |
| 27 | + DockerBuild.Code.require_all(plugin_paths) |
| 28 | + |
| 24 29 | env = Keyword.fetch!(opts, :env) |
| 25 30 | |
| 26 31 | plugin_configs = |
Loading more files…