First
[anni] / config / docker.exs
1 import Config
2
3 config :pleroma, Pleroma.Web.Endpoint,
4   url: [host: System.get_env("DOMAIN", "localhost"), scheme: "https", port: 443],
5   http: [ip: {0, 0, 0, 0}, port: 4000]
6
7 config :pleroma, :instance,
8   name: System.get_env("INSTANCE_NAME", "Pleroma"),
9   email: System.get_env("ADMIN_EMAIL"),
10   notify_email: System.get_env("NOTIFY_EMAIL"),
11   limit: 5000,
12   registrations_open: false,
13   healthcheck: true
14
15 config :pleroma, Pleroma.Repo,
16   adapter: Ecto.Adapters.Postgres,
17   username: System.get_env("DB_USER", "pleroma"),
18   password: System.fetch_env!("DB_PASS"),
19   database: System.get_env("DB_NAME", "pleroma"),
20   hostname: System.get_env("DB_HOST", "db"),
21   port: System.get_env("DB_PORT", "5432"),
22   pool_size: 10
23
24 # Configure web push notifications
25 config :web_push_encryption, :vapid_details, subject: "mailto:#{System.get_env("NOTIFY_EMAIL")}"
26
27 config :pleroma, :database, rum_enabled: false
28 config :pleroma, :instance, static_dir: "/var/lib/pleroma/static"
29 config :pleroma, Pleroma.Uploaders.Local, uploads: "/var/lib/pleroma/uploads"
30
31 # We can't store the secrets in this file, since this is baked into the docker image
32 if not File.exists?("/var/lib/pleroma/secret.exs") do
33   secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
34   signing_salt = :crypto.strong_rand_bytes(8) |> Base.encode64() |> binary_part(0, 8)
35   {web_push_public_key, web_push_private_key} = :crypto.generate_key(:ecdh, :prime256v1)
36
37   secret_file =
38     EEx.eval_string(
39       """
40       import Config
41
42       config :pleroma, Pleroma.Web.Endpoint,
43         secret_key_base: "<%= secret %>",
44         signing_salt: "<%= signing_salt %>"
45
46       config :web_push_encryption, :vapid_details,
47         public_key: "<%= web_push_public_key %>",
48         private_key: "<%= web_push_private_key %>"
49       """,
50       secret: secret,
51       signing_salt: signing_salt,
52       web_push_public_key: Base.url_encode64(web_push_public_key, padding: false),
53       web_push_private_key: Base.url_encode64(web_push_private_key, padding: false)
54     )
55
56   File.write("/var/lib/pleroma/secret.exs", secret_file)
57 end
58
59 import_config("/var/lib/pleroma/secret.exs")
60
61 # For additional user config
62 if File.exists?("/var/lib/pleroma/config.exs"),
63   do: import_config("/var/lib/pleroma/config.exs"),
64   else:
65     File.write("/var/lib/pleroma/config.exs", """
66     import Config
67
68     # For additional configuration outside of environmental variables
69     """)