mirror of
https://github.com/bonfire-networks/bonfire-app.git
synced 2024-05-18 09:02:41 +00:00
Improve config & rel
This commit is contained in:
parent
0766462145
commit
374b3248ef
|
@ -9,6 +9,10 @@ IO.puts("🔥 Welcome to Bonfire!")
|
||||||
host = System.get_env("HOSTNAME", "localhost")
|
host = System.get_env("HOSTNAME", "localhost")
|
||||||
server_port = String.to_integer(System.get_env("SERVER_PORT", "4000"))
|
server_port = String.to_integer(System.get_env("SERVER_PORT", "4000"))
|
||||||
public_port = String.to_integer(System.get_env("PUBLIC_PORT", "4000"))
|
public_port = String.to_integer(System.get_env("PUBLIC_PORT", "4000"))
|
||||||
|
test_instance = System.get_env("TEST_INSTANCE")
|
||||||
|
|
||||||
|
yes? = ~w(true yes 1)
|
||||||
|
no? = ~w(false no 0)
|
||||||
|
|
||||||
repos =
|
repos =
|
||||||
if Code.ensure_loaded?(Beacon.Repo),
|
if Code.ensure_loaded?(Beacon.Repo),
|
||||||
|
@ -16,7 +20,7 @@ repos =
|
||||||
else: [Bonfire.Common.Repo]
|
else: [Bonfire.Common.Repo]
|
||||||
|
|
||||||
repos =
|
repos =
|
||||||
if System.get_env("TEST_INSTANCE") == "yes",
|
if test_instance in yes?,
|
||||||
do: repos ++ [Bonfire.Common.TestInstanceRepo],
|
do: repos ++ [Bonfire.Common.TestInstanceRepo],
|
||||||
else: repos
|
else: repos
|
||||||
|
|
||||||
|
@ -40,14 +44,20 @@ System.get_env("DATABASE_URL") || System.get_env("POSTGRES_PASSWORD") || System.
|
||||||
and POSTGRES_USER (default: postgres) and POSTGRES_HOST (default: localhost)
|
and POSTGRES_USER (default: postgres) and POSTGRES_HOST (default: localhost)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
maybe_repo_ipv6 = if System.get_env("ECTO_IPV6") in yes?, do: [:inet6], else: []
|
||||||
|
|
||||||
repo_connection_config =
|
repo_connection_config =
|
||||||
if System.get_env("DATABASE_URL") do
|
if System.get_env("DATABASE_URL") do
|
||||||
[url: System.get_env("DATABASE_URL")]
|
[
|
||||||
|
url: System.get_env("DATABASE_URL"),
|
||||||
|
socket_options: maybe_repo_ipv6
|
||||||
|
]
|
||||||
else
|
else
|
||||||
[
|
[
|
||||||
username: System.get_env("POSTGRES_USER", "postgres"),
|
username: System.get_env("POSTGRES_USER", "postgres"),
|
||||||
password: System.get_env("POSTGRES_PASSWORD", "postgres"),
|
password: System.get_env("POSTGRES_PASSWORD", "postgres"),
|
||||||
hostname: System.get_env("POSTGRES_HOST", "localhost")
|
hostname: System.get_env("POSTGRES_HOST", "localhost"),
|
||||||
|
socket_options: maybe_repo_ipv6
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -90,12 +100,13 @@ config :bonfire,
|
||||||
dir: cute_gifs_dir
|
dir: cute_gifs_dir
|
||||||
]
|
]
|
||||||
|
|
||||||
|
phx_server = System.get_env("PHX_SERVER")
|
||||||
use_cowboy? = System.get_env("PLUG_SERVER") == "cowboy"
|
use_cowboy? = System.get_env("PLUG_SERVER") == "cowboy"
|
||||||
|
|
||||||
config :bonfire, Bonfire.Web.Endpoint,
|
config :bonfire, Bonfire.Web.Endpoint,
|
||||||
server:
|
server:
|
||||||
config_env() != :test or System.get_env("TEST_INSTANCE") == "yes" or
|
phx_server not in no? and
|
||||||
System.get_env("START_SERVER") == "yes",
|
(config_env() != :test or test_instance in yes? or phx_server in yes?),
|
||||||
url: [
|
url: [
|
||||||
host: host,
|
host: host,
|
||||||
port: public_port
|
port: public_port
|
||||||
|
@ -152,7 +163,7 @@ IO.puts("Note: Starting database connection pool of #{pool_size}")
|
||||||
database =
|
database =
|
||||||
case config_env() do
|
case config_env() do
|
||||||
:test ->
|
:test ->
|
||||||
"bonfire_test_#{System.get_env("TEST_INSTANCE")}_#{System.get_env("MIX_TEST_PARTITION")}"
|
"bonfire_test_#{test_instance}_#{System.get_env("MIX_TEST_PARTITION")}"
|
||||||
|
|
||||||
:dev ->
|
:dev ->
|
||||||
System.get_env("POSTGRES_DB", "bonfire_dev")
|
System.get_env("POSTGRES_DB", "bonfire_dev")
|
||||||
|
@ -227,7 +238,7 @@ case System.get_env("GRAPH_DB_URL") do
|
||||||
pool_size: pool_size
|
pool_size: pool_size
|
||||||
end
|
end
|
||||||
|
|
||||||
if (config_env() == :prod or System.get_env("OTEL_ENABLED") == "1") and
|
if (config_env() == :prod or System.get_env("OTEL_ENABLED") in yes?) and
|
||||||
(System.get_env("OTEL_EXPORTER_OTLP_ENDPOINT") || System.get_env("OTEL_LIGHTSTEP_API_KEY") ||
|
(System.get_env("OTEL_EXPORTER_OTLP_ENDPOINT") || System.get_env("OTEL_LIGHTSTEP_API_KEY") ||
|
||||||
System.get_env("OTEL_HONEYCOMB_API_KEY")) do
|
System.get_env("OTEL_HONEYCOMB_API_KEY")) do
|
||||||
config :opentelemetry_exporter,
|
config :opentelemetry_exporter,
|
||||||
|
|
|
@ -88,8 +88,7 @@ config :exsync,
|
||||||
|
|
||||||
# use Ecto sandbox?
|
# use Ecto sandbox?
|
||||||
config :bonfire,
|
config :bonfire,
|
||||||
sql_sandbox:
|
sql_sandbox: System.get_env("PHX_SERVER") != "yes" and System.get_env("TEST_INSTANCE") != "yes"
|
||||||
System.get_env("START_SERVER") != "yes" and System.get_env("TEST_INSTANCE") != "yes"
|
|
||||||
|
|
||||||
{chromedriver_path, _} = System.cmd("sh", ["-c", "command -v chromedriver"])
|
{chromedriver_path, _} = System.cmd("sh", ["-c", "command -v chromedriver"])
|
||||||
|
|
||||||
|
|
4
justfile
4
justfile
|
@ -222,7 +222,7 @@ recompile *args='':
|
||||||
just compile --force $args
|
just compile --force $args
|
||||||
|
|
||||||
dev-test:
|
dev-test:
|
||||||
@MIX_ENV=test START_SERVER=yes just dev-run
|
@MIX_ENV=test PHX_SERVER=yes just dev-run
|
||||||
|
|
||||||
# Run the app in dev mode, as a background service
|
# Run the app in dev mode, as a background service
|
||||||
dev-bg: init
|
dev-bg: init
|
||||||
|
@ -565,7 +565,7 @@ test-federation-dance-positions:
|
||||||
TEST_INSTANCE=yes MIX_ENV=test just mix deps.clean bonfire --build
|
TEST_INSTANCE=yes MIX_ENV=test just mix deps.clean bonfire --build
|
||||||
|
|
||||||
test-federation-live-DRAGONS *args='':
|
test-federation-live-DRAGONS *args='':
|
||||||
FEDERATE=yes START_SERVER=yes HOSTNAME=$(just local-tunnel-hostname) PUBLIC_PORT=443 just test --only live_federation $@
|
FEDERATE=yes PHX_SERVER=yes HOSTNAME=$(just local-tunnel-hostname) PUBLIC_PORT=443 just test --only live_federation $@
|
||||||
|
|
||||||
load_testing:
|
load_testing:
|
||||||
TEST_INSTANCE=yes just mix bonfire.load_testing
|
TEST_INSTANCE=yes just mix bonfire.load_testing
|
||||||
|
|
3
rel/overlays/bin/migrate
Normal file
3
rel/overlays/bin/migrate
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
cd -P -- "$(dirname -- "$0")"
|
||||||
|
exec ./bonfire eval Bonfire.Common.Repo.migrate
|
1
rel/overlays/bin/migrate.bat
Normal file
1
rel/overlays/bin/migrate.bat
Normal file
|
@ -0,0 +1 @@
|
||||||
|
call "%~dp0\bonfire" eval Bonfire.Common.Repo.migrate
|
3
rel/overlays/bin/no_server
Normal file
3
rel/overlays/bin/no_server
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
cd -P -- "$(dirname -- "$0")"
|
||||||
|
PHX_SERVER=no exec ./bonfire start
|
2
rel/overlays/bin/no_server.bat
Normal file
2
rel/overlays/bin/no_server.bat
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
set PHX_SERVER=no
|
||||||
|
call "%~dp0\bonfire" start
|
3
rel/overlays/bin/server
Normal file
3
rel/overlays/bin/server
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
cd -P -- "$(dirname -- "$0")"
|
||||||
|
PHX_SERVER=yes exec ./bonfire start
|
2
rel/overlays/bin/server.bat
Normal file
2
rel/overlays/bin/server.bat
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
set PHX_SERVER=yes
|
||||||
|
call "%~dp0\bonfire" start
|
|
@ -29,7 +29,7 @@ Mix.Task.run("ecto.migrate")
|
||||||
|
|
||||||
# Ecto.Adapters.SQL.Sandbox.mode(repo(), :manual)
|
# Ecto.Adapters.SQL.Sandbox.mode(repo(), :manual)
|
||||||
|
|
||||||
# if System.get_env("START_SERVER") !="yes" do
|
# if System.get_env("PHX_SERVER") !="yes" do
|
||||||
Ecto.Adapters.SQL.Sandbox.mode(repo(), :auto)
|
Ecto.Adapters.SQL.Sandbox.mode(repo(), :auto)
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue