Files
firezone/config/dev.exs
Andrew Dryga 28fe571543 Small improvements to make setup process easier for OS contributors (#1171)
* Remove _build folders for umbrella apps

For umbrella apps everything goes into /_build directory so there no need to ignore directories that should never be created

* Change mix aliases to be more aligned with what OS community would expect

1. We want ecto.create and ecto.migrate to be run on each tests, this will simplify setup steps (no need to run migrations manually)

2. ecto.remigrate is not needed because now you can just run ecto.drop and on tests migrations would be executed anyways.

* Rename docker-compose step name in CONTRIBUTING.md

The step was renamed here: dd67baf629 (diff-67a4805fdcc6145d7b3ada2a6099a9b2e91c9d0fd108c22f95d2f01d219793d1R10)

* Remove .devcontainer

This an is opinionated change. Right now devcontainer doesn't work but should be easy to fix (with renaming step name), but at the same time it forces developers that use VS code to have unified development environment (including plugins for the editor itself).

I feel like it's not a good path to go for OS and for small team - everyone should be allowed to use setup they like. Especially for people like me that tend to recompile ls-elixir for Elixir plugin from master branch.

Plus it's yet another thing to maintain while nobody on the team is using it, which means it will be always causing issues.

* Make fz_http mix.exs aliases aligned with umbrella app ones

* Redirect stderr to stdout in a command called from dev.exs

Otherwise I'm getting this on my MacOS (that has a `route` implementation that doesn't show interfaces) when `mix phx.server` is executed:
```
usage: route [-dnqtv] command [[modifiers] args]
```

* Fix race condition due to static device field values

Both public_key and name are unique and we should not use static values for field covered by unique index, otherwise deadlocks and slow tests are expected.

* Remove unwanted transaction block

The changeset code doesn't have any code that accesses the database and individual Ecto.SQL commands are already wrapped in transactions by default, so there is no need to start it manually and hold for longer than expected (while irrelevant Elixir code is running).

* Use netstat to identify egress interface on MacOS

* Rename uninstall.sh to omnibus-uninstall.sh

* Fix uninstall path in omnibus_build.yml
2022-12-06 15:07:45 -08:00

141 lines
4.0 KiB
Elixir

import Config
# Configure your database
if url = System.get_env("DATABASE_URL") do
config :fz_http, FzHttp.Repo,
url: url,
show_sensitive_data_on_connection_error: true,
pool_size: 10
else
config :fz_http, FzHttp.Repo,
username: "postgres",
password: "postgres",
database: "firezone_dev",
ssl: false,
ssl_opts: [],
parameters: [],
hostname: "localhost",
show_sensitive_data_on_connection_error: true,
pool_size: 10
end
# For development, we disable any cache and enable
# debugging and code reloading.
config :fz_http, FzHttpWeb.Endpoint,
http: [port: 13000],
debug_errors: true,
code_reloader: true,
check_origin: ["//127.0.0.1", "//localhost"],
watchers: [
node: ["esbuild.js", "dev", cd: Path.expand("../apps/fz_http/assets", __DIR__)]
]
get_egress_interface = fn ->
egress_interface_cmd =
case :os.type() do
{:unix, :darwin} -> "netstat -rn -finet | grep '^default' | awk '{print $NF;}'"
{_os_family, _os_name} -> "route | grep '^default' | grep -o '[^ ]*$'"
end
System.cmd("/bin/sh", ["-c", egress_interface_cmd], stderr_to_stdout: true)
|> elem(0)
|> String.trim()
end
egress_interface = System.get_env("EGRESS_INTERFACE") || get_egress_interface.()
{fz_wall_cli_module, _} =
Code.eval_string(System.get_env("FZ_WALL_CLI_MODULE", "FzWall.CLI.Sandbox"))
config :fz_wall,
nft_path: System.get_env("NFT_PATH", "nft"),
egress_interface: egress_interface,
cli: fz_wall_cli_module
{fz_vpn_mod, _} =
Code.eval_string(System.get_env("FZ_VPN_WG_ADAPTER", "FzVpn.Interface.WGAdapter.Live"))
config :fz_vpn,
supervised_children: [FzVpn.Interface.WGAdapter.Sandbox, FzVpn.Server, FzVpn.StatsPushService],
wireguard_private_key_path: "priv/wg_dev_private_key",
wg_adapter: fz_vpn_mod
# Auth
local_auth_enabled = System.get_env("LOCAL_AUTH_ENABLED") == "true"
# Configure strategies
identity_strategy =
{:identity,
{Ueberauth.Strategy.Identity,
[
callback_methods: ["POST"],
uid_field: :email
]}}
providers =
[
{local_auth_enabled, identity_strategy}
]
|> Enum.filter(fn {key, _val} -> key end)
|> Enum.map(fn {_key, val} -> val end)
config :ueberauth, Ueberauth, providers: providers
# ## SSL Support
#
# In order to use HTTPS in development, a self-signed
# certificate can be generated by running the following
# Mix task:
#
# mix phx.gen.cert
#
# Note that this task requires Erlang/OTP 20 or later.
# Run `mix help phx.gen.cert` for more information.
#
# The `http:` config above can be replaced with:
#
# https: [
# port: 4001,
# cipher_suite: :strong,
# keyfile: "priv/cert/selfsigned_key.pem",
# certfile: "priv/cert/selfsigned.pem"
# ],
#
# If desired, both `http:` and `https:` keys can be
# configured to run both http and https servers on
# different ports.
# Watch static and templates for browser reloading.
config :fz_http, FzHttpWeb.Endpoint,
secret_key_base: "5OVYJ83AcoQcPmdKNksuBhJFBhjHD1uUa9mDOHV/6EIdBQ6pXksIhkVeWIzFk5SD",
live_view: [
signing_salt: "t01wa0K4lUd7mKa0HAtZdE+jFOPDDejX"
],
live_reload: [
patterns: [
~r"apps/fz_http/priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"apps/fz_http/priv/gettext/.*(po)$",
~r"apps/fz_http/lib/fz_http_web/(live|views)/.*(ex)$",
~r"apps/fz_http/lib/fz_http_web/templates/.*(eex)$"
]
]
# Do not include metadata nor timestamps in development logs
config :logger, :console, format: "[$level] $message\n"
# Set a higher stacktrace during development. Avoid configuring such
# in production as building large stacktraces may be expensive.
config :phoenix, :stacktrace_depth, 20
# Initialize plugs at runtime for faster development compilation
config :phoenix, :plug_init_mode, :runtime
config :fz_http,
private_clients: ["172.28.0.0/16"],
wireguard_allowed_ips: "172.28.0.0/16",
cookie_secure: false,
telemetry_module: FzCommon.MockTelemetry,
local_auth_enabled: local_auth_enabled
config :fz_http, FzHttpWeb.Mailer, adapter: Swoosh.Adapters.Local, from_email: "dev@firez.one"