Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/rebar3_docker_build.erl
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ do(RState) ->
{ok, RState2} ->
Config = rebar3_docker_util:config(RState2),
Params = template_parameters(RState2, Config),
TemplateFile = filename:join([code:priv_dir(rebar3_docker),
"templates", "Dockerfile"]),
TemplateFile = template_file(RState2, Config),
Template = bbmustache:parse_file(TemplateFile),
Data = bbmustache:compile(Template, Params,
[{key_type, atom}, {escape_fun, fun(X) -> X end}]),
Expand Down Expand Up @@ -86,6 +85,15 @@ template_parameters(RState, Config) ->
runtime_packages => [#{name => N}
|| N <- maps:get(runtime_packages, Config)]
}.
template_file(RState, Config) ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space ?

case maps:get(template, Config, undefined) of
undefined ->
rebar_api:info("Using default template to generate the Dockerfile", []),
filename:join([code:priv_dir(rebar3_docker), "templates", "Dockerfile"]);
Bin ->
rebar_api:info("Using custom template from docker config to generate the Dockerfile", []),
filename:join([rebar_state:dir(RState), Bin])
end.

escape_string(Str) when is_binary(Str) ->
iolist_to_binary(io_lib:format("\"~s\"",
Expand Down
1 change: 1 addition & 0 deletions src/rebar3_docker_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{erlang_version, binary},
{builder_image, binary},
{appname, binary},
{template, binary},
{build_packages, [list, binary]},
{git_url_rewrites, [list, [tuple, [binary, binary]]]},
{runtime_packages, [list, binary]},
Expand Down