Remove Twemoji stuff from MastoFE
[akkoma] / lib / pleroma / config / release_runtime_provider.ex
1 defmodule Pleroma.Config.ReleaseRuntimeProvider do
2 @moduledoc """
3 Imports `runtime.exs` and `{env}.exported_from_db.secret.exs` for elixir releases.
4 """
5 @behaviour Config.Provider
6
7 @impl true
8 def init(opts), do: opts
9
10 @impl true
11 def load(config, _opts) do
12 with_defaults = Config.Reader.merge(config, Pleroma.Config.Holder.release_defaults())
13
14 config_path = System.get_env("PLEROMA_CONFIG_PATH") || "/etc/pleroma/config.exs"
15
16 with_runtime_config =
17 if File.exists?(config_path) do
18 runtime_config = Config.Reader.read!(config_path)
19
20 with_defaults
21 |> Config.Reader.merge(pleroma: [config_path: config_path])
22 |> Config.Reader.merge(runtime_config)
23 else
24 warning = [
25 IO.ANSI.red(),
26 IO.ANSI.bright(),
27 "!!! #{config_path} not found! Please ensure it exists and that PLEROMA_CONFIG_PATH is unset or points to an existing file",
28 IO.ANSI.reset()
29 ]
30
31 IO.puts(warning)
32 with_defaults
33 end
34
35 exported_config_path =
36 config_path
37 |> Path.dirname()
38 |> Path.join("prod.exported_from_db.secret.exs")
39
40 with_exported =
41 if File.exists?(exported_config_path) do
42 exported_config = Config.Reader.read!(with_runtime_config)
43 Config.Reader.merge(with_runtime_config, exported_config)
44 else
45 with_runtime_config
46 end
47
48 with_exported
49 end
50 end