~singpolyma/soapbox-fly

ref: 716f71c87d9ffb769f47980d0d340ff426ff2141 soapbox-fly/config.exs -rw-r--r-- 2.8 KiB
716f71c8Stephen Paul Weber Fix db config migration a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import Config

config :pleroma, Pleroma.Web.Endpoint,
  url: [host: System.get_env("DOMAIN", "localhost"), scheme: "https", port: 443],
  http: [ip: {0, 0, 0, 0}, port: 8080]

config :pleroma, :instance,
  name: System.get_env("INSTANCE_NAME", "Pleroma"),
  email: System.get_env("ADMIN_EMAIL"),
  notify_email: System.get_env("NOTIFY_EMAIL"),
  limit: 5000,
  registrations_open: false,
  invites_enabled: true,
  allow_relay: true,
  healthcheck: true

config :pleroma, Pleroma.Repo,
  adapter: Ecto.Adapters.Postgres,
  database: "pleroma",
  socket_dir: "/var/run/postgresql",
  pool_size: 10

if System.get_env("MAILGUN_API_KEY") do
  config :pleroma, Pleroma.Emails.Mailer,
    enabled: true,
    adapter: Swoosh.Adapters.Mailgun,
    api_key: System.fetch_env!("MAILGUN_API_KEY"),
    domain: System.fetch_env!("MAILGUN_DOMAIN")
end

# Configure web push notifications
config :web_push_encryption, :vapid_details, subject: "mailto:#{System.get_env("NOTIFY_EMAIL")}"

config :pleroma, :database, rum_enabled: false
config :pleroma, :instance, static_dir: "/data/pleroma/static"
config :pleroma, Pleroma.Uploaders.Local, uploads: "/data/pleroma/uploads"

config :pleroma, :static_fe, enabled: false
config :pleroma, :uri_schemes, valid_schemes: ["http", "https", "irc", "xmpp", "tel", "sms", "ssh", "mailto"]
config :esshd,
  enabled: true,
  priv_dir: "/data/pleroma/ssh_keys",
  handler: "Pleroma.BBS.Handler",
  port: 2222,
  password_authenticator: "Pleroma.BBS.Authenticator"

# We can't store the secrets in this file, since this is baked into the docker image
if not File.exists?("/data/pleroma/secret.exs") do
  secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
  signing_salt = :crypto.strong_rand_bytes(8) |> Base.encode64() |> binary_part(0, 8)
  {web_push_public_key, web_push_private_key} = :crypto.generate_key(:ecdh, :prime256v1)

  secret_file =
    EEx.eval_string(
      """
      import Config

      config :pleroma, Pleroma.Web.Endpoint,
        secret_key_base: "<%= secret %>",
        signing_salt: "<%= signing_salt %>"

      config :web_push_encryption, :vapid_details,
        public_key: "<%= web_push_public_key %>",
        private_key: "<%= web_push_private_key %>"
      """,
      secret: secret,
      signing_salt: signing_salt,
      web_push_public_key: Base.url_encode64(web_push_public_key, padding: false),
      web_push_private_key: Base.url_encode64(web_push_private_key, padding: false)
    )

  File.write("/data/pleroma/secret.exs", secret_file)
end

import_config("/data/pleroma/secret.exs")

# For additional user config
if File.exists?("/data/pleroma/config.exs"),
  do: import_config("/data/pleroma/config.exs"),
  else:
    File.write("/data/pleroma/config.exs", """
    import Config

    # For additional configuration outside of environmental variables
    """)