pg

35d08af · gmorell · 2026-04-27 23:18

4 files +63 -23

Files changed

modified .gitignore
+4 −0
@@ -35,3 +35,7 @@ diogramos-*.tar
35 35 npm-debug.log
36 36 /assets/node_modules/
37 37
38 +# Populated secret manifests — only the *.example.yml templates are tracked.
39 +app-secrets.yml
40 +*.secret.yml
41 +
modified app.yml
+26 −9
@@ -28,30 +28,47 @@ spec:
28 28 name: diogramos
29 29 spec:
30 30 containers:
31 − - image: r.g.gmp.io/diogramos/diogramos:latest
31 + - image: r.g.gmp.io/neiam/diogramos:latest
32 32 imagePullPolicy: Always
33 33 name: diogramos
34 34 ports:
35 35 - containerPort: 4000
36 36 env:
37 37 - name: PHX_HOST
38 − value: diogramos.gmp.io
38 + value: diogramos.neiam.co
39 39 - name: PORT
40 40 value: "4000"
41 41 - name: PHX_SERVER
42 42 value: "true"
43 + - name: POOL_SIZE
44 + value: "10"
45 +
43 46 - name: SECRET_KEY_BASE
44 47 valueFrom:
45 48 secretKeyRef:
46 49 name: elixir-args
47 50 key: secret_key_base
48 − - name: DATABASE_URL
51 +
52 + # Postgres creds come from the StackGres-managed auth secret
53 + # (named after the SGCluster in pg.yml). runtime.exs reads
54 + # these directly — no URL composition — so passwords with
55 + # special characters don't get mangled by URL parsing.
56 + - name: POSTGRES_HOST
57 + value: postgres
58 + - name: POSTGRES_PORT
59 + value: "5432"
60 + - name: POSTGRES_DB
61 + value: diogramos
62 + - name: POSTGRES_USER
49 63 valueFrom:
50 64 secretKeyRef:
51 − name: elixir-args
52 − key: database_url
53 − - name: POOL_SIZE
54 − value: "10"
65 + name: postgres
66 + key: superuser-username
67 + - name: POSTGRES_PASSWORD
68 + valueFrom:
69 + secretKeyRef:
70 + name: postgres
71 + key: superuser-password
55 72 readinessProbe:
56 73 httpGet:
57 74 path: /
@@ -91,10 +108,10 @@ metadata:
91 108 spec:
92 109 tls:
93 110 - hosts:
94 − - diogramos.gmp.io
111 + - diogramos.neiam.co
95 112 secretName: diogramos-tls
96 113 rules:
97 − - host: diogramos.gmp.io
114 + - host: diogramos.neiam.co
98 115 http:
99 116 paths:
100 117 - path: /
modified config/runtime.exs
+33 −14
@@ -24,22 +24,41 @@ config :diogramos, DiogramosWeb.Endpoint,
24 24 http: [port: String.to_integer(System.get_env("PORT", "4000"))]
25 25
26 26 if config_env() == :prod do
27 − database_url =
28 − System.get_env("DATABASE_URL") ||
29 − raise """
30 − environment variable DATABASE_URL is missing.
31 − For example: ecto://USER:PASS@HOST/DATABASE
32 − """
33 −
34 27 maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
28 + pool_size = String.to_integer(System.get_env("POOL_SIZE") || "10")
29 +
30 + # Prefer discrete POSTGRES_* env vars (composes safely even when the
31 + # password contains URL-significant characters like @ / : + & — which
32 + # is common with StackGres / KubeDB-generated passwords). Fall back to
33 + # DATABASE_URL when those aren't present.
34 + cond do
35 + System.get_env("POSTGRES_HOST") ->
36 + config :diogramos, Diogramos.Repo,
37 + hostname: System.get_env("POSTGRES_HOST"),
38 + port: String.to_integer(System.get_env("POSTGRES_PORT") || "5432"),
39 + username:
40 + System.get_env("POSTGRES_USER") ||
41 + raise("POSTGRES_USER is required when POSTGRES_HOST is set"),
42 + password:
43 + System.get_env("POSTGRES_PASSWORD") ||
44 + raise("POSTGRES_PASSWORD is required when POSTGRES_HOST is set"),
45 + database: System.get_env("POSTGRES_DB") || "diogramos",
46 + pool_size: pool_size,
47 + socket_options: maybe_ipv6
35 48
36 − config :diogramos, Diogramos.Repo,
37 − # ssl: true,
38 − url: database_url,
39 − pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
40 − # For machines with several cores, consider starting multiple pools of `pool_size`
41 − # pool_count: 4,
42 − socket_options: maybe_ipv6
49 + System.get_env("DATABASE_URL") ->
50 + config :diogramos, Diogramos.Repo,
51 + url: System.get_env("DATABASE_URL"),
52 + pool_size: pool_size,
53 + socket_options: maybe_ipv6
54 +
55 + true ->
56 + raise """
57 + Database configuration missing. Set either:
58 + - POSTGRES_HOST + POSTGRES_USER + POSTGRES_PASSWORD (preferred), or
59 + - DATABASE_URL (e.g. ecto://USER:PASS@HOST/DATABASE)
60 + """
61 + end
43 62
44 63 # The secret key base is used to sign/encrypt cookies and other secrets.
45 64 # A default value is used in config/dev.exs and config/test.exs but you

Parents: 0ff0d66