chore(build): Fix relx config for emqx config files overlay
This commit is contained in:
parent
f6f6fe47da
commit
075c40aa05
1
Makefile
1
Makefile
|
@ -1,5 +1,6 @@
|
||||||
REBAR_VERSION = 3.14.3-emqx-2
|
REBAR_VERSION = 3.14.3-emqx-2
|
||||||
REBAR = ./rebar3
|
REBAR = ./rebar3
|
||||||
|
export PKG_VSN ?= $(shell git describe --tags --always)
|
||||||
|
|
||||||
PROFILE ?= emqx
|
PROFILE ?= emqx
|
||||||
PROFILES := emqx emqx-edge check test
|
PROFILES := emqx emqx-edge check test
|
||||||
|
|
168
rebar.config.erl
168
rebar.config.erl
|
@ -33,17 +33,17 @@ test_deps() ->
|
||||||
].
|
].
|
||||||
|
|
||||||
profiles() ->
|
profiles() ->
|
||||||
[ {'emqx', [ {relx, relx('emqx')}
|
[ {'emqx', [ {erl_opts, [no_debug_info]}
|
||||||
, {erl_opts, [no_debug_info]}
|
, {relx, relx('emqx')}
|
||||||
]}
|
]}
|
||||||
, {'emqx-pkg', [ {relx, relx('emqx-pkg')}
|
, {'emqx-pkg', [ {erl_opts, [no_debug_info]}
|
||||||
, {erl_opts, [no_debug_info]}
|
, {relx, relx('emqx-pkg')}
|
||||||
]}
|
]}
|
||||||
, {'emqx-edge', [ {relx, relx('emqx-edge')}
|
, {'emqx-edge', [ {erl_opts, [no_debug_info]}
|
||||||
, {erl_opts, [no_debug_info]}
|
, {relx, relx('emqx-edge')}
|
||||||
]}
|
]}
|
||||||
, {'emqx-edge-pkg', [ {relx, relx('emqx-edge-pkg')}
|
, {'emqx-edge-pkg', [ {erl_opts, [no_debug_info]}
|
||||||
, {erl_opts, [no_debug_info]}
|
, {relx, relx('emqx-edge-pkg')}
|
||||||
]}
|
]}
|
||||||
, {check, [ {erl_opts, [debug_info]}
|
, {check, [ {erl_opts, [debug_info]}
|
||||||
]}
|
]}
|
||||||
|
@ -99,47 +99,56 @@ relx_apps(ReleaseType) ->
|
||||||
, emqx
|
, emqx
|
||||||
, {mnesia, load}
|
, {mnesia, load}
|
||||||
, {ekka, load}
|
, {ekka, load}
|
||||||
, {emqx_retainer, load}
|
]
|
||||||
, {emqx_management, load}
|
++ [bcrypt || provide_bcrypt_release(ReleaseType)]
|
||||||
, {emqx_dashboard, load}
|
++ relx_apps_per_rel(ReleaseType)
|
||||||
, {emqx_bridge_mqtt, load}
|
++ [{N, load} || N <- relx_plugin_apps(ReleaseType)].
|
||||||
, {emqx_sn, load}
|
|
||||||
, {emqx_coap, load}
|
|
||||||
, {emqx_stomp, load}
|
|
||||||
, {emqx_auth_http, load}
|
|
||||||
, {emqx_auth_mysql, load}
|
|
||||||
, {emqx_auth_jwt, load}
|
|
||||||
, {emqx_auth_mnesia, load}
|
|
||||||
, {emqx_web_hook, load}
|
|
||||||
, {emqx_recon, load}
|
|
||||||
, {emqx_rule_engine, load}
|
|
||||||
, {emqx_sasl, load}
|
|
||||||
, {emqx_telemetry, load}
|
|
||||||
] ++ do_relx_apps(ReleaseType) ++ [bcrypt || provide_bcrypt_release(ReleaseType)].
|
|
||||||
|
|
||||||
do_relx_apps(cloud) ->
|
relx_apps_per_rel(cloud) ->
|
||||||
[ {emqx_lwm2m, load}
|
[ {observer, load}
|
||||||
, {emqx_auth_ldap, load}
|
|
||||||
, {emqx_auth_pgsql, load}
|
|
||||||
, {emqx_auth_redis, load}
|
|
||||||
, {emqx_auth_mongo, load}
|
|
||||||
, {emqx_lua_hook, load}
|
|
||||||
, {emqx_exhook, load}
|
|
||||||
, {emqx_exproto, load}
|
|
||||||
, {emqx_prometheus, load}
|
|
||||||
, {emqx_psk_file, load}
|
|
||||||
, {emqx_plugin_template, load}
|
|
||||||
, {observer, load}
|
|
||||||
, luerl
|
, luerl
|
||||||
, xmerl
|
, xmerl
|
||||||
];
|
];
|
||||||
do_relx_apps(_) ->
|
relx_apps_per_rel(edge) ->
|
||||||
|
[].
|
||||||
|
|
||||||
|
relx_plugin_apps(ReleaseType) ->
|
||||||
|
[ emqx_retainer
|
||||||
|
, emqx_management
|
||||||
|
, emqx_dashboard
|
||||||
|
, emqx_bridge_mqtt
|
||||||
|
, emqx_sn
|
||||||
|
, emqx_coap
|
||||||
|
, emqx_stomp
|
||||||
|
, emqx_auth_http
|
||||||
|
, emqx_auth_mysql
|
||||||
|
, emqx_auth_jwt
|
||||||
|
, emqx_auth_mnesia
|
||||||
|
, emqx_web_hook
|
||||||
|
, emqx_recon
|
||||||
|
, emqx_rule_engine
|
||||||
|
, emqx_sasl
|
||||||
|
, emqx_telemetry
|
||||||
|
] ++ relx_plugin_apps_per_rel(ReleaseType).
|
||||||
|
|
||||||
|
relx_plugin_apps_per_rel(cloud) ->
|
||||||
|
[ emqx_lwm2m
|
||||||
|
, emqx_auth_ldap
|
||||||
|
, emqx_auth_pgsql
|
||||||
|
, emqx_auth_redis
|
||||||
|
, emqx_auth_mongo
|
||||||
|
, emqx_lua_hook
|
||||||
|
, emqx_exhook
|
||||||
|
, emqx_exproto
|
||||||
|
, emqx_prometheus
|
||||||
|
, emqx_psk_file
|
||||||
|
, emqx_plugin_template
|
||||||
|
];
|
||||||
|
relx_plugin_apps_per_rel(edge) ->
|
||||||
[].
|
[].
|
||||||
|
|
||||||
relx_overlay(ReleaseType) ->
|
relx_overlay(ReleaseType) ->
|
||||||
[ {mkdir,"etc/"}
|
[ {mkdir,"log/"}
|
||||||
, {mkdir,"etc/emqx.d/"}
|
|
||||||
, {mkdir,"log/"}
|
|
||||||
, {mkdir,"data/"}
|
, {mkdir,"data/"}
|
||||||
, {mkdir,"data/mnesia"}
|
, {mkdir,"data/mnesia"}
|
||||||
, {mkdir,"data/configs"}
|
, {mkdir,"data/configs"}
|
||||||
|
@ -147,30 +156,69 @@ relx_overlay(ReleaseType) ->
|
||||||
, {template, "data/loaded_plugins.tmpl", "data/loaded_plugins"}
|
, {template, "data/loaded_plugins.tmpl", "data/loaded_plugins"}
|
||||||
, {template, "data/loaded_modules.tmpl", "data/loaded_modules"}
|
, {template, "data/loaded_modules.tmpl", "data/loaded_modules"}
|
||||||
, {template,"data/emqx_vars","releases/emqx_vars"}
|
, {template,"data/emqx_vars","releases/emqx_vars"}
|
||||||
, {copy,"_build/default/lib/cuttlefish/cuttlefish","bin/"}
|
, {copy,"bin/emqx","bin/emqx"}
|
||||||
, {copy,"bin/*","bin/"}
|
, {copy,"bin/emqx_ctl","bin/emqx_ctl"}
|
||||||
, {template,"etc/*.conf","etc/"}
|
, {copy,"bin/install_upgrade.escript", "bin/install_upgrade.escript"}
|
||||||
, {template,"etc/emqx.d/*.conf","etc/emqx.d/"}
|
, {copy,"bin/emqx","bin/emqx-{{release_version}}"} %% for relup
|
||||||
, {copy,"priv/emqx.schema","releases/{{release_version}}/"}
|
, {copy,"bin/emqx_ctl","bin/emqx_ctl-{{release_version}}"} %% for relup
|
||||||
, {copy, "etc/certs","etc/"}
|
, {copy,"bin/install_upgrade.escript", "bin/install_upgrade.escript-{{release_version}}"} %% for relup
|
||||||
, {copy,"bin/emqx.cmd","bin/emqx.cmd-{{release_version}}"}
|
, {template,"bin/emqx.cmd","bin/emqx.cmd"}
|
||||||
, {copy,"bin/emqx_ctl.cmd","bin/emqx_ctl.cmd-{{release_version}}"}
|
, {template,"bin/emqx_ctl.cmd","bin/emqx_ctl.cmd"}
|
||||||
, {copy,"bin/emqx","bin/emqx-{{release_version}}"}
|
, {copy,"bin/nodetool","bin/nodetool"}
|
||||||
, {copy,"bin/emqx_ctl","bin/emqx_ctl-{{release_version}}"}
|
|
||||||
, {copy,"bin/install_upgrade.escript", "bin/install_upgrade.escript-{{release_version}}"}
|
|
||||||
, {copy,"bin/nodetool","bin/nodetool-{{release_version}}"}
|
, {copy,"bin/nodetool","bin/nodetool-{{release_version}}"}
|
||||||
|
, {copy,"_build/default/lib/cuttlefish/cuttlefish","bin/cuttlefish"}
|
||||||
, {copy,"_build/default/lib/cuttlefish/cuttlefish","bin/cuttlefish-{{release_version}}"}
|
, {copy,"_build/default/lib/cuttlefish/cuttlefish","bin/cuttlefish-{{release_version}}"}
|
||||||
] ++ do_relx_overlay(ReleaseType).
|
, {copy,"priv/emqx.schema","releases/{{release_version}}/"}
|
||||||
|
] ++ etc_overlay(ReleaseType).
|
||||||
|
|
||||||
do_relx_overlay(cloud) ->
|
etc_overlay(ReleaseType) ->
|
||||||
[ {template,"etc/emqx_cloud.d/*.conf","etc/emqx.d/"}
|
PluginApps = relx_plugin_apps(ReleaseType),
|
||||||
, {template,"etc/emqx_cloud.d/vm.args","etc/vm.args"}
|
Templates = emqx_etc_overlay(ReleaseType) ++
|
||||||
|
lists:append([plugin_etc_overlays(App) || App <- PluginApps]),
|
||||||
|
[ {mkdir, "etc/"}
|
||||||
|
, {mkdir, "etc/plugins"}
|
||||||
|
, {copy, "{{base_dir}}/lib/emqx/etc/certs","etc/"}
|
||||||
|
] ++
|
||||||
|
lists:map(
|
||||||
|
fun({From, To}) -> {template, From, To};
|
||||||
|
(FromTo) -> {template, FromTo, FromTo}
|
||||||
|
end, Templates)
|
||||||
|
++ extra_overlay(ReleaseType).
|
||||||
|
|
||||||
|
extra_overlay(cloud) ->
|
||||||
|
[ {copy,"{{base_dir}}/lib/emqx_lwm2m/lwm2m_xml","etc/"}
|
||||||
|
, {copy, "{{base_dir}}/lib/emqx_psk_file/etc/psk.txt", "etc/psk.txt"}
|
||||||
];
|
];
|
||||||
do_relx_overlay(edge) ->
|
extra_overlay(edge) ->
|
||||||
[ {template,"etc/emqx_edge.d/*.conf","etc/emqx.d/"}
|
[].
|
||||||
, {template,"etc/emqx_edge.d/vm.args.edge","etc/vm.args"}
|
emqx_etc_overlay(cloud) ->
|
||||||
|
emqx_etc_overlay_common() ++
|
||||||
|
[ {"etc/emqx_cloud.d/vm.args","etc/vm.args"}
|
||||||
|
];
|
||||||
|
emqx_etc_overlay(edge) ->
|
||||||
|
emqx_etc_overlay_common() ++
|
||||||
|
[ {"etc/emqx_edge.d/vm.args","etc/vm.args"}
|
||||||
].
|
].
|
||||||
|
|
||||||
|
emqx_etc_overlay_common() ->
|
||||||
|
["etc/acl.conf", "etc/emqx.conf", "etc/ssl_dist.conf",
|
||||||
|
%% TODO: check why it has to end with .paho
|
||||||
|
%% and why it is put to etc/plugins dir
|
||||||
|
{"etc/acl.conf.paho", "etc/plugins/acl.conf.paho"}].
|
||||||
|
|
||||||
|
plugin_etc_overlays(App0) ->
|
||||||
|
App = atom_to_list(App0),
|
||||||
|
ConfFiles = find_conf_files(App),
|
||||||
|
%% NOTE: not filename:join here since relx translates it for windows
|
||||||
|
[{"{{base_dir}}/lib/"++ App ++"/etc/" ++ F, "etc/plugins/" ++ F}
|
||||||
|
|| F <- ConfFiles].
|
||||||
|
|
||||||
|
%% NOTE: for apps fetched as rebar dependency (there is so far no such an app)
|
||||||
|
%% the overlay should be hand-coded but not to rely on build-time wildcards.
|
||||||
|
find_conf_files(App) ->
|
||||||
|
Dir = filename:join(["apps", App, "etc"]),
|
||||||
|
filelib:wildcard("*.conf", Dir).
|
||||||
|
|
||||||
env(Name, Default) ->
|
env(Name, Default) ->
|
||||||
case os:getenv(Name) of
|
case os:getenv(Name) of
|
||||||
"" -> Default;
|
"" -> Default;
|
||||||
|
|
Loading…
Reference in New Issue